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. For a complete example, see Static Sites on Cloudflare Workers.

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

Bots and referrer spam are rejected with {"message": "Bots are not allowed"} (status 200, so queued clients do not retry). For a spam referer the response also carries a skip list, e.g. "skip": [{"type": "referer", "value": "spam-domain.com", "ttl": 86400}]: skip sending visitors whose track_referer is this domain or one of its subdomains for ttl seconds. Ignore unknown type values, more may be added later.

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, quarter 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"
}

A new payment with a gross of 0 is no revenue (e.g. a payment method change at your payment provider), so it is not stored. Sending 0 for an already tracked payment id records a full refund: the payment is removed, so it no longer counts as revenue, paying user or active subscription.

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 Page Views ​

Page views are sent in batches. The Laravel client does this for you, use this endpoint only for your own integration. Page views do not count against the monthly event limit and have a rate limit bucket of their own, so they never slow down the other endpoints.

HTTP Request

POST /api/v1/stats-views

Parameters

KeyTypeDescription
batch_iduuid requiredGenerated once per batch and sent again unchanged on every retry. A batch that was already stored is not counted twice.
viewsarray required1 to 1,000 entries. Invalid entries are skipped one by one, the valid ones are stored.
views.*.hstring requiredThe visitor hash, exactly as sent with Create Visitor. Views of a hash the API never received are dropped after a retry window of about two hours.
views.*.tinteger requiredThe minute of the view as Unix timestamp in seconds (UTC). Older than 48 hours or in the future is clamped.
views.*.ninteger requiredThe number of views of this page in this minute (1 to 1,000).
views.*.pstring requiredThe page path, starting with /. Query string and fragment are dropped, a trailing slash is removed, case is kept.
meta.modestring optionalworker (bundled) or direct (one view per request), for diagnostics.

Every view is counted, including the first one of a visitor: the visitor event itself is no page view. A visitor counts at most 500 views per day.

Payload

json
{
    "batch_id": "9d6f1c1e-7c40-4f0a-b1a2-3e5d8a6b7c90",
    "views": [
        {"h": "a3f1c09e5b7d42e1a3f1c09e5b7d42e1", "t": 1794687300, "n": 2, "p": "/pricing"},
        {"h": "0b9e77aa12cd4f5560b9e77aa12cd4f5", "t": 1794687360, "n": 1, "p": "/"}
    ],
    "meta": {"mode": "worker"}
}

Response

json
{
    "message": "Stats Views Request accepted.",
    "batch_id": "9d6f1c1e-7c40-4f0a-b1a2-3e5d8a6b7c90",
    "accepted": 2,
    "rejected": 0,
    "duplicate": false
}

Once the monthly event limit is reached, the response is {"message": "Monthly event limit reached.", "pause": 3600}: stop sending views for pause seconds.

Create Hit ​

A hit is one page request, forwarded as it is by an edge function in front of a site without Laravel, for example a Cloudflare Worker. SimpleStats decides whether it is a page view (no prefetch, no asset, no redirect, no bot), and records the visitor with its referrer and campaign parameters together with the page view. Send every request, the filtering happens here.

HTTP Request

POST /api/v1/stats-hit

Parameters

KeyTypeDescription
urlstring requiredThe full URL of the request, including the query string (the campaign parameters are read from it).
methodstring requiredThe HTTP method of the request. Only GET counts.
statusinteger requiredThe status code of the response.
content_typestring nullableThe Content-Type of the response.
ipstring nullableThe IP of the visitor. (does not get stored)
user_agentstring nullableThe user agent of the visitor, not encoded. (does not get stored)
headersobject nullableThese request headers, lowercase: referer, accept, sec-fetch-dest, sec-fetch-mode, sec-purpose, purpose, x-moz, x-requested-with. Do not send other headers, cookies or credentials.
timestring nullableThe time of the request (Y-m-d H:i:s P). Defaults to now.

The visitor is recorded once per day (the first hit sets referrer, campaign and entry page), every hit that is a page view adds one view. Hits share the rate limit bucket of Create Page Views, and only the first hit of a visitor per day counts as an event.

Payload

json
{
    "url": "https://example.com/blog/hello?utm_source=newsletter",
    "method": "GET",
    "status": 200,
    "content_type": "text/html; charset=utf-8",
    "ip": "203.0.113.7",
    "user_agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36",
    "headers": {
        "referer": "https://www.google.com/",
        "accept": "text/html,application/xhtml+xml",
        "sec-fetch-dest": "document",
        "sec-fetch-mode": "navigate"
    }
}

Response

json
{
    "message": "Stats Hit Request accepted.",
    "tracked": true
}

A request that is no page view is answered with {"message": "Not counted as a page view.", "tracked": false}, also with status 200. Once the monthly event limit is reached, the response is {"message": "Monthly event limit reached.", "pause": 3600} and nothing is recorded.

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"
}