API Documentation
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.
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 instance, our you can find your existing API tokens inside the app on the instance 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.
Code | Description |
---|---|
200 | Everything is ok. |
400 | Valid data was given but the request has failed. |
401 | No valid API Key was given. |
404 | The request resource could not be found. |
422 | The payload has missing required parameters or invalid data was given. |
429 | Too many attempts. |
500 | Request failed due to an internal error in SimpleStats. |
503 | SimpleStats is offline for maintenance. |
Rate Limit
The rate limits for our API are 120 requests per minute by default. If you have special needs for more requests, please contact us to request more capacity.
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:
Key | Type | Description |
---|---|---|
time | string required | The time when the user has registerd. Format: Y-m-d H:i:s P , before or equal now |
ip | string nullable | The ip of the user. (does not get stored) |
user_agent | string nullable | The user_agent of the user. (does not get stored) |
track_referer | string nullable | The http tracking referer of the user. |
track_source | string nullable | The tracking source of the user. |
track_medium | string nullable | The tracking medium of the user. |
track_campaign | string nullable | The tracking campaign of the user. |
track_term | string nullable | The tracking term of the user. |
track_content | string nullable | The tracking content of the user. |
page_entry | string nullable | The tracking page_entry of the user. |
Optional parameters:
Key | Type | Description |
---|---|---|
location_country | string nullable | The location country of the user. (If the ip is set, we take the country that refers to it.) |
location_region | string nullable | The location region of the user. (If the ip is set, we take the region that refers to it.) |
location_city | string nullable | The location city of the user. (If the ip is set, we take the city that refers to it.) |
device_type | string nullable | The device type of the user. (If the user_agent is set, we take the device type that refers to it.) |
device_platform | string nullable | The device platform (OS) of the user. (If the user_agent is set, we take the device platform that refers to it.) |
device_browser | string nullable | The device browser of the user. (If the user_agent is set, we take the device browser that refers to it.) |
page_entry | string nullable | The page entry point of the user. |
Payload
{
"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
{
"message": "Request accepted."
}
Create User
HTTP Request
POST /api/v1/stats-user
Core parameters:
Key | Type | Description |
---|---|---|
id | mixed required | The user id. |
time | string required | The time when the user has registerd. Format: Y-m-d H:i:s P , before or equal now |
ip | string nullable | The ip of the user. (does not get stored) |
user_agent | string nullable | The user_agent of the user. (does not get stored) |
track_referer | string nullable | The http tracking referer of the user. |
track_source | string nullable | The tracking source of the user. |
track_medium | string nullable | The tracking medium of the user. |
track_campaign | string nullable | The tracking campaign of the user. |
track_term | string nullable | The tracking term of the user. |
track_content | string nullable | The tracking content of the user. |
page_entry | string nullable | The tracking page_entry of the user. |
Optional parameters:
Key | Type | Description |
---|---|---|
location_country | string nullable | The location country of the user. (If the ip is set, we take the country that refers to it.) |
location_region | string nullable | The location region of the user. (If the ip is set, we take the region that refers to it.) |
location_city | string nullable | The location city of the user. (If the ip is set, we take the city that refers to it.) |
device_type | string nullable | The device type of the user. (If the user_agent is set, we take the device type that refers to it.) |
device_platform | string nullable | The device platform (OS) of the user. (If the user_agent is set, we take the device platform that refers to it.) |
device_browser | string nullable | The device browser of the user. (If the user_agent is set, we take the device browser that refers to it.) |
page_entry | string nullable | The page entry point of the user. |
Payload
{
"id": 1,
"track_source": "test",
"time": "2024-04-04"
}
Response
{
"message": "Request accepted."
}
Create Login
HTTP Request
POST /api/v1/stats-login
Parameters
Key | Type | Description |
---|---|---|
stats_user_id | integer required | The id of the user trying to login. |
time | string required | The time when the user tries to login. Format: Y-m-d H:i:s P , before or equal now |
Payload
{
"stats_user_id": 1,
"time": "2024-04-04"
}
Response
{
"message": "Request accepted."
}
Create Payment
HTTP Request
POST /api/v1/stats-payment
Parameters
Key | Type | Description |
---|---|---|
id | mixed required | The payment id. |
stats_user_id | integer required | The user id associated with the payment. |
time | string required | The time when the payment happened. Format: Y-m-d H:i:s P , before or equal now |
gross | numeric required | The gross amount of the payment in cents. (e.g.: $1 = 100 Cent) |
net | numeric required | The net amount of the payment in cents. (e.g.: $1 = 100 Cent). |
currency | string required | The ISO-4217 currency code of the payment. (e.g.: EUR, USD, GBP ...) |
Payload
{
"id": "1",
"stats_user_id": "1",
"gross": 2000,
"net": 1800,
"currency": "EUR",
"time": "2024-04-04"
}
Response
{
"message": "Request accepted."
}