# Admin API
business
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 stream or generate a report on conversions, using server script or an external application 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 a Chrome Developers tools to investigate the set of parameters which you can use in different requests.
- Open Chrome, then View → Developer → Developer tools.
- Switch to Network, opt-in Fetch/XHR.
- Click on a request, then switch to Payload.
TIP
To get better performance, Keitaro combines multiple requests in one. These requests Keitaro makes 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);
2
3
4
5
String your-api-key
must be replaced to valid API Key.
# Creating Admin Api request
To create valid request you should:
Use an authorization key (a key that prevents third-party users from getting information).
Use the correct type of request
Set mandatory parameters (required for entity creation requests, e.g. 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 our 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 already create a campaign. The rest of the campaign settings will be set by default.
# Swagger documentation
This 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 here is to log in:
Select 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
and alias
and any additional ones we want to specify when creating the campaign.
Press Execute and see our 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 there will be a description of the error.
If you have basic querying skills - you can try to work with Admin API from third-party application, 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 into your service.
Example:
Will generate 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]
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, '');
← Click API Keitaro CLI →