Integrating with our API

We plan to offer a number of integrations for web frameworks that are most commonly used. If we don't offer an integration for your platform yet, or if you'd rather build it yourself you can use the description below to find out how you send us the needed data. Don't hesitate to contact us if you have any questsions.

Note We can give you a discount if you decide to open source the code and we approve of its quality!

Events

Every API request you want to track is stored with us as an event in a project. After creating a project in our UI, you'll be presented with a token in the form cc-XXXXXXX. That token is used to identify your project in the API.

Our API is designed to receive events in batches. We advise you to buffer a number of requests (for example 25), or for a certain amount of time (for example 5 minutes + a random delay). When the limit is reached, sent us your events in one batch as POST request to https://api.callcounter.eu/api/v1/events/batch.json using the following details.

Danger Don't forget to empty the buffer when errors occur, or it might grow too big when a connection cannot be established.

Headers

We require two headers. The first one is:

Content-Type: application/json

The second one is the user agent, which needs a value that needs to be unique for your integration. For example:

User-Agent: callcounter-lua-gateway (0.1)

Example body

After setting the headers, fill the body with valid json such as below. Make sure you replace the project_token with your token and the events with actual request data.

{
"batch": {
"project_token": "cc-XXXXXXX",
"events": [
  {
    "created_at": "2021-04-23 11:58:57 +0200",
    "path": "/api/v1/events/batch.json"
    "method": "POST",
    "user_agent": "curl/7.35.0",
    "status": 200,
    "elapsed_time": 352
  },
  {
    "created_at": "2021-04-23 11:53:12 +0200",
    "path": "/api/v1/status.json"
    "method": "GET",
    "user_agent": "Wget/1.15 (linux-gnu)",
    "status": 200,
    "elapsed_time": 52
  },
  {
    "created_at": "2021-04-23 11:51:09 +0200",
    "path": "/api/v1/events/batch.json"
    "method": "POST",
    "user_agent": "curl/7.35.0",
    "status": 200,
    "elapsed_time": 497
  }
]
}
}

Note that elapsed time is the time the request took in microseconds, where 1000 microseconds equals 1 second.

Send the request

Now send this request as POST to https://api.callcounter.eu/api/v1/events/batch.json and you should receive a status code 200 response. Verify the data was saved correctly by signing in and viewing your project!