Skip to content

Ingest API

The Ingest API is used to send tracking data (visitors, users, logins, payments, custom events) to SimpleStats. Even though the composer client package is dedicated to Laravel, the API basically works with every client! So if you'd like to use the tool, even if you're not using Laravel, you may just trigger the API requests manually.

TIP

Looking to read your analytics data programmatically? Check out the Query API.

Authentication

In order to use the API, you should authenticate your request by including your API token as a bearer token value:

Authorization: Bearer API_TOKEN_HERE

TIP

You'll receive an API token after creating a new project, our you can find your existing API tokens inside the app on the project page.

Headers

Make sure you have the following content type headers are set on every request:

Accept: application/json Content-Type: application/json

URI

SimpleStats API is hosted on the following base URI:

https://simplestats.io/api/v1/

Errors

SimpleStats uses standard HTTP response codes to communicate the outcome of API requests. These codes offer immediate insight into whether a request has been successful, encountered an error, or requires additional action.

CodeDescription
200Everything is ok.
400Valid data was given but the request has failed.
401No valid API Key was given.
404The request resource could not be found.
422The payload has missing required parameters or invalid data was given.
429Too many attempts.
500Request failed due to an internal error in SimpleStats.
503SimpleStats is offline for maintenance.

Rate Limit

Rate limits depend on your subscription plan and are applied per project (API token) per minute. See Plans and Limits for details.

If you exceed your rate limit, the API will return a 429 Too Many Requests response.

Endpoints

At the moment, only the create endpoints are available. But if the id already exists on our side, the record gets updated with the new data.

Create Visitor

HTTP Request

POST /api/v1/stats-visitor

Core parameters:

KeyTypeDescription
timestring requiredThe time when the user has registerd.
Format: Y-m-d H:i:s P, before or equal now
ipstring nullableThe ip of the user. (does not get stored)
user_agentstring nullableThe user_agent of the user. (does not get stored)
track_refererstring nullableThe http tracking referer of the user.
track_sourcestring nullableThe tracking source of the user.
track_mediumstring nullableThe tracking medium of the user.
track_campaignstring nullableThe tracking campaign of the user.
track_termstring nullableThe tracking term of the user.
track_contentstring nullableThe tracking content of the user.
page_entrystring nullableThe tracking page_entry of the user.
Optional parameters
KeyTypeDescription
location_countrystring nullableThe location country of the user. (If the ip is set, we take the country that refers to it.)
location_regionstring nullableThe location region of the user. (If the ip is set, we take the region that refers to it.)
location_citystring nullableThe location city of the user. (If the ip is set, we take the city that refers to it.)
device_typestring nullableThe device type of the user. (If the user_agent is set, we take the device type that refers to it.)
device_platformstring nullableThe device platform (OS) of the user. (If the user_agent is set, we take the device platform that refers to it.)
device_browserstring nullableThe device browser of the user. (If the user_agent is set, we take the device browser that refers to it.)
page_entrystring nullableThe page entry point of the user.
propertiesobject nullableCustom properties to group analytics by, as a name: value map (e.g. {"ab_test": "B"}). Values must be scalar. Max 50 names per request. See custom properties.

Payload

json
{
    "ip": "127.0.0.1",
    "user_agent": "Mozilla/5.0 (Linux; Android 13; Pixel 6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/112.0.0.0 Mobile Safari/537.36",
    "track_source": "test",
    "time": "2024-04-04"
}

Response

json
{
    "message": "Stats Visitor Request accepted.",
    "visitor_hash": "9a7c4f2e8b1d6a3c5e0f7b2d4a8c1e6f"
}

TIP

If no visitor_hash is given, it gets generated from time, ip and user_agent. The returned visitor_hash can be used to reference this visitor in other endpoints (payments, custom events, custom properties).

Create User

HTTP Request

POST /api/v1/stats-user

Core parameters:

KeyTypeDescription
idmixed requiredThe user id.
timestring requiredThe time when the user has registerd.
Format: Y-m-d H:i:s P, before or equal now
ipstring nullableThe ip of the user. (does not get stored)
user_agentstring nullableThe user_agent of the user. (does not get stored)
track_refererstring nullableThe http tracking referer of the user.
track_sourcestring nullableThe tracking source of the user.
track_mediumstring nullableThe tracking medium of the user.
track_campaignstring nullableThe tracking campaign of the user.
track_termstring nullableThe tracking term of the user.
track_contentstring nullableThe tracking content of the user.
page_entrystring nullableThe tracking page_entry of the user.
Optional parameters
KeyTypeDescription
location_countrystring nullableThe location country of the user. (If the ip is set, we take the country that refers to it.)
location_regionstring nullableThe location region of the user. (If the ip is set, we take the region that refers to it.)
location_citystring nullableThe location city of the user. (If the ip is set, we take the city that refers to it.)
device_typestring nullableThe device type of the user. (If the user_agent is set, we take the device type that refers to it.)
device_platformstring nullableThe device platform (OS) of the user. (If the user_agent is set, we take the device platform that refers to it.)
device_browserstring nullableThe device browser of the user. (If the user_agent is set, we take the device browser that refers to it.)
page_entrystring nullableThe page entry point of the user.
visitor_hashstring nullableThe visitor_hash of the visitor this registration converted from. Links the user to its prior visit (for visit-to-registration timing).
propertiesobject nullableCustom properties to group analytics by, as a name: value map (e.g. {"ab_test": "B"}). Values must be scalar. Max 50 names per request. See custom properties.

Payload

json
{
    "id": 1,
    "track_source": "test",
    "time": "2024-04-04"
}

Response

json
{
    "message": "Stats User Request accepted.",
    "id": 1
}

Create Login

HTTP Request

POST /api/v1/stats-login

Parameters

KeyTypeDescription
stats_user_idinteger requiredThe id of the user trying to login.
timestring requiredThe time when the user tries to login.
Format: Y-m-d H:i:s P, before or equal now

Payload

json
{
    "stats_user_id": 1,
    "time": "2024-04-04"
}

Response

json
{
    "message": "Stats Login Request accepted.",
    "id": 1
}

Create Payment

HTTP Request

POST /api/v1/stats-payment

Parameters

KeyTypeDescription
idmixed requiredThe payment id.
stats_user_idinteger requiredThe user id associated with the payment.
visitor_hashstring nullableThe visitor hash.
timestring requiredThe time when the payment happened.
Format: Y-m-d H:i:s P, before or equal now
grossnumeric requiredThe gross amount of the payment in cents.
(e.g.: $1 = 100 Cent)
netnumeric requiredThe net amount of the payment in cents.
(e.g.: $1 = 100 Cent).
currencystring requiredThe ISO-4217 currency code of the payment.
(e.g.: EUR, USD, GBP ...)
subscription_intervalstring nullableThe billing interval for subscription payments: month or year. Omit or null for one-time payments.
subscription_planstring nullableThe subscription plan the payment belongs to (free-form, e.g. Starter, Business). Omit or null for one-time payments.

Payload

json
{
    "id": "1",
    "stats_user_id": "1",
    "gross": 2000,
    "net": 1800,
    "currency": "EUR",
    "subscription_interval": "month",
    "subscription_plan": "Business",
    "time": "2024-04-04"
}

Response

json
{
    "message": "Stats Payment Request accepted.",
    "id": "1"
}

Create Custom Event

HTTP Request

POST /api/v1/stats-custom-event

Parameters

KeyTypeDescription
idmixed requiredA unique identifier for this event.
namestring requiredThe event name (e.g. "Button Clicked"). Events with the same name are grouped.
stats_user_idmixed nullableThe user id associated with the event.
visitor_hashstring nullableThe visitor hash.
timestring requiredThe time when the event happened.
Format: Y-m-d H:i:s P, before or equal now

Payload

json
{
    "id": "evt-550e8400-e29b-41d4-a716-446655440000",
    "name": "Plan Upgraded",
    "stats_user_id": "1",
    "time": "2025-04-04"
}

Response

json
{
    "message": "Stats Custom Event Request accepted.",
    "id": "evt-550e8400-e29b-41d4-a716-446655440000"
}

Create Custom Property

HTTP Request

POST /api/v1/stats-custom-properties

Parameters

KeyTypeDescription
propertiesobject requiredCustom properties to group analytics by, as a name: value map (e.g. {"ab_test": "B"}). Values must be scalar. Max 50 names per request.
stats_user_idmixed nullableThe user id to attach the properties to. Required without visitor_hash.
visitor_hashstring nullableThe visitor hash to attach the properties to. Required without stats_user_id.
timestring requiredThe time the properties were current.
Format: Y-m-d H:i:s P, before or equal now

Payload

json
{
    "stats_user_id": "1",
    "properties": {
        "ab_test": "B"
    },
    "time": "2026-04-04"
}

Response

json
{
    "message": "Stats Custom Property Request accepted.",
    "id": "1"
}