# Admin API

business

Keitaro exposes REST-type Admin API to control tracker programmatically.

# Admin API Reference

See admin-api.docs.keitaro.io.

# How to use Admin API

Keitaro performs all requests from control panel through Admin API, so you can explore behavior for different requests by using a Chrome Developers tools to investigate the set of parameters which you can use in different requests.

  1. Open Chrome, then View → Developer → Developer tools.
  2. Switch to Network, opt-in Fetch/XHR.
  3. Click on a request, then switch to Payload.

Tips

To get better performance, Keitaro combines multiple requests in one. These requests Keitaro makes through ?batch (or ?bulk) entrypoint.

Video

# Making a request

Example:

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://example.com/admin_api/v1/campaigns');
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Api-Key: your-api-key'));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
echo curl_exec($ch);
1
2
3
4
5

String your-api-key must be replaced to valid API Key.

# Code generation

Use swagger-codegen to generate the code.

Example:

Generates golang files to 'output' folder.

Available languages:

$ swagger-codegen langs
 Available languages: [
 dart, aspnetcore, csharp, csharp-dotnet2, go, go-server, 
 dynamic-html, html, html2, java, jaxrs-cxf-client, jaxrs-cxf, inflector, 
 jaxrs-cxf-cdi, jaxrs-spec, jaxrs-jersey, jaxrs-di, jaxrs-resteasy-eap, 
 jaxrs-resteasy, micronaut, spring, nodejs-server, openapi, 
 openapi-yaml, kotlin-client, kotlin-server, php, python, 
 python-flask, r, ruby, scala, scala-akka-http-server, 
 swift3, swift4, swift5, typescript-angular, typescript-axios, typescript-fetch, 
 javascript]
1
2
3
4
5
6
7
8
9
10

We need your help

If you found an issue while working with Admin API on any of these languages, please tell us by sending an email to support@keitaro.io.

# Third-party libraries

# FAQ

Why some entry-points respond with status '400 Bad Request' on POST request?

Try to send empty POST content:

curl_setopt($ch, CURLOPT_POSTFIELDS, '');
1