# Admin API

expert team enterprise

Keitaro Admin API is an interface that allows you to manage the Keitaro tracker admin panel through incoming requests. That is, without entering the admin panel of the tracker, you can, for example, create a campaign with the necessary settings, change the content of the flow or generate a report on conversions, using server script or an external app like Postman.

# Admin API methods

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 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.

TIP

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

Video

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.

Bearer

It is possible to send API key as a bearer token:

curl_setopt($ch, CURLOPT_HTTPHEADER, array('Authorization: Bearer <your-api-key>'));`
1

# Creating Admin API request

To create a valid request you must

  1. Use an authorization key (a key that prevents third-party users from getting information).

  2. Use the correct type of request.

  3. Set mandatory parameters (required for entity creation requests, for example, campaign creation).

You can get the authentication key in the tracker, under Maintenance — Users — Admin API keys.

The following query type set is used when working with the Keitaro Admin API:

GET - to retrieve information, such as a list of tracker campaigns:

https://keitarosupport1.xyz/admin_api/v1/campaigns

POST - to build reports, as well as to create something, such as a new campaign in the tracker:

https://keitarosupport1.xyz/admin_api/v1/campaigns

Note that the request address looks the same: in both cases we are addressing to a "tracker entry point", which contains:

  • The address of the tracker is keitarosupport1.xyz
  • Further points to Admin API section — admin_api/v1/
  • Specific subsection of the tracker, campaigns — campaigns.

PUT - to update existing data in the tracker

DELETE - to delete data in the tracker.

We also need a list of required query parameters.

Look at documentation

Find the type of request you want to make, and there will also be a list of required parameters. The list of required parameters to create a campaign in the tracker includes: alias and name.

By setting only these two parameters, you can create a campaign. The rest of the campaign's settings will be set by default.

# Swagger documentation

It is an interface that combines our Admin API documentation and the ability to send real requests to the tracker. To get started here, open Maintenance — Users — Admin API keys, copy your key and click on the Documentation tab. You will be taken to the interactive mode, where you can work with requests.

The first thing you need to do is to log in:

Select the section, such as creating a campaign:

Press Try it out. This will give us the opportunity to edit our request body, which will be sent when the Execute button is pressed. Inside this body we set our required parameters name with alias, and any additional ones that we want to specify on creating the campaign.

Press Execute and see already sent request, the request address and the answer from the tracker:

If the request occurred with an error, you will see a different response status, and in the Response body field is a description of the error.

If you have basic querying skills — you can try to work with Admin API from third-party app, for example, Postman. Or you can try to write your own server script that will send request to Admin API.

# Other languages support

Swagger-codegen will be able to generate code in any language you can build in your service.

Example:

Generating golang files to output/ directory.

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
Found an error?

Please help us make this documentation better. If you find any inaccuracies or errors, please email us at support@keitaro.io.

# Third-party libraries

# FAQ

Why does an empty POST request get a '400 Bad Request' error?

Add to the code:

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