Introduction
Welcome to the Kindmetrics API. Here you can handle your domains and the statistics for your domains. You can show your most important data directly in your app for optimizing your flow.
Authentication
To authorize, use this code:
# With shell, you can just pass the correct header with each request
curl "https://app.kindmetrics.io/api/domains"
-H "Authorization: Bearer APIKEY"
Make sure to replace
APIKEY
with your API key.
Kindmetrics uses API keys to allow access to the API. You can get your API key at your api tokens page.
Kindmetrics expect the token to be an param (?token=APITOKEN
) or in the headers like below:
Authorization: Bearer APITOKEN
Domains
Get Your Domains
curl "https://app.kindmetrics.io/api/domains"
-H "Authorization: Bearer APIKEY"
The above command returns JSON structured like this:
[
{
"id": 1,
"address": "kindmetrics.io"
}
]
This endpoint retrieves all your domains.
HTTP Request
GET https://app.kindmetrics.io/api/domains
Retrieve one Domain
curl "https://app.kindmetrics.io/api/domains/1"
-H "Authorization: Bearer APIKEY"
The above command returns JSON structured like this:
{
"address": "kindmetrics.io",
"visitors": 3041,
"pageviews": 5643,
"bounce": 64,
"track_snippet": "<script src=\"https://kindmetrics.io/js/kind.js\" defer=\"true\" data-domain=\"kindmetrics.io\"></script>"
}
This endpoint retrieves one of your domains.
HTTP Request
GET https://app.kindmetrics.io/api/domains/1
Query Parameters
Parameter | Default | Description |
---|---|---|
to | Today | Date you want to show the stats to, can be today or earlier, not in the future, like: 2020-06-01 |
from | 7 days ago | Date where you want to show stats from, like: 2020-04-01 |
source_name | None | Source you want to filter on. Like Google or indiehackers.com |
medium_name | None | Group of sources you want to filter on, like Social or Search |
site_path | None | url path of your site you want to see aggregated stats for, like /blog |
goal_id | None | aggregate stats for goals - get goal id from the goal api endpoint |
Create an Domain
curl "https://app.kindmetrics.io/api/domains"
-X POST
-d {"domain": {"address": "kindmetrics.io", "time_zone": "Europe/Stockholm"}}
-H "Authorization: Bearer APIKEY"
The above command returns JSON structured like this:
{
"address": "kindmetrics.io",
"visitors": 0,
"pageviews": 0,
"bounce": 0,
"track_snippet": "<script src=\"https://kindmetrics.io/js/kind.js\" defer=\"true\" data-domain=\"kindmetrics.io\"></script>"
}
This endpoint retrieves one of your domains.
HTTP Request
POST https://app.kindmetrics.io/api/domains
Query Parameters
Parameter | Default | Description |
---|---|---|
address | none | domain address without www. prefix, as example kindmetrics.io |
time_zone | none | time zone in format Continent/City |
Domain stats
You can get all data you can see on the dashboard in different requests. They will be aggregated results and show the data based on the period you have chosen.
Retrieve Pages
curl "https://app.kindmetrics.io/api/domains/1/pages"
-H "Authorization: Bearer APIKEY"
The above command returns JSON structured like this:
[
{
"address": "/open-source-analytics",
"visitors": 12,
"percentage": 24
}
]
This endpoint retrieves pages stats for your domain.
HTTP Request
GET https://app.kindmetrics.io/api/domains/1/pages
Query Parameters
Parameter | Default | Description |
---|---|---|
to | Today | Date you want to show the stats to, can be today or earlier, not in the future, like: 2020-06-01 |
from | 7 days ago | Date where you want to show stats from, like: 2020-04-01 |
source_name | None | Source you want to filter on. Like Google or indiehackers.com |
medium_name | None | Group of sources you want to filter on, like Social or Search |
site_path | None | url path of your site you want to see aggregated stats for, like /blog |
goal_id | None | aggregate stats for goals - get goal id from the goal api endpoint |
Retrieve Entry Pages
curl "https://app.kindmetrics.io/api/domains/1/entry_pages"
-H "Authorization: Bearer APIKEY"
The above command returns JSON structured like this:
[
{
"address": "/open-source-analytics",
"visitors": 12,
"percentage": 24
}
]
This endpoint retrieves entry pages stats for your domain. Entry page is the first page the visitor visit when visiting your website.
HTTP Request
GET https://app.kindmetrics.io/api/domains/1/entry_pages
Query Parameters
Parameter | Default | Description |
---|---|---|
to | Today | Date you want to show the stats to, can be today or earlier, not in the future, like: 2020-06-01 |
from | 7 days ago | Date where you want to show stats from, like: 2020-04-01 |
source_name | None | Source you want to filter on. Like Google or indiehackers.com |
medium_name | None | Group of sources you want to filter on, like Social or Search |
site_path | None | url path of your site you want to see aggregated stats for, like /blog |
goal_id | None | aggregate stats for goals - get goal id from the goal api endpoint |
Retrieve Sources
curl "https://app.kindmetrics.io/api/domains/1/sources"
-H "Authorization: Bearer APIKEY"
The above command returns JSON structured like this:
[
{
"source": "indiehackers.com",
"medium": "social",
"visitors": 12,
"percentage": 24
}
]
This endpoint retrieves sources stats for your domain.
HTTP Request
GET https://app.kindmetrics.io/api/domains/1/sources
Query Parameters
Parameter | Default | Description |
---|---|---|
to | Today | Date you want to show the stats to, can be today or earlier, not in the future, like: 2020-06-01 |
from | 7 days ago | Date where you want to show stats from, like: 2020-04-01 |
source_name | None | Source you want to filter on. Like Google or indiehackers.com |
medium_name | None | Group of sources you want to filter on, like Social or Search |
site_path | None | url path of your site you want to see aggregated stats for, like /blog |
goal_id | None | aggregate stats for goals - get goal id from the goal api endpoint |
Retrieve Referrers
curl "https://app.kindmetrics.io/api/domains/1/referrers"
-H "Authorization: Bearer APIKEY"
The above command returns JSON structured like this:
[
{
"url": "https://www.indiehackers.com/",
"domain": "indiehackers.com",
"visitors": 12,
"percentage": 24
}
]
This endpoint retrieves referrer stats for your domain, usually used for seeing links for a specific source or medium on kindmetrics.
HTTP Request
GET https://app.kindmetrics.io/api/domains/1/referrers
Query Parameters
Parameter | Default | Description |
---|---|---|
to | Today | Date you want to show the stats to, can be today or earlier, not in the future, like: 2020-06-01 |
from | 7 days ago | Date where you want to show stats from, like: 2020-04-01 |
source_name | None | Source you want to filter on. Like Google or indiehackers.com |
medium_name | None | Group of sources you want to filter on, like Social or Search |
site_path | None | url path of your site you want to see aggregated stats for, like /blog |
goal_id | None | aggregate stats for goals - get goal id from the goal api endpoint |
Retrieve Countries
curl "https://app.kindmetrics.io/api/domains/1/countries"
-H "Authorization: Bearer APIKEY"
The above command returns JSON structured like this:
[
{
"name": "Sweden",
"visitors": 12,
"percentage": 24
}
]
This endpoint retrieves countries stats for your domain.
HTTP Request
GET https://app.kindmetrics.io/api/domains/1/countries
Query Parameters
Parameter | Default | Description |
---|---|---|
to | Today | Date you want to show the stats to, can be today or earlier, not in the future, like: 2020-06-01 |
from | 7 days ago | Date where you want to show stats from, like: 2020-04-01 |
source_name | None | Source you want to filter on. Like Google or indiehackers.com |
medium_name | None | Group of sources you want to filter on, like Social or Search |
site_path | None | url path of your site you want to see aggregated stats for, like /blog |
goal_id | None | aggregate stats for goals - get goal id from the goal api endpoint |
Retrieve Current Visitors
curl "https://app.kindmetrics.io/api/domains/1/current"
-H "Authorization: Bearer APIKEY"
The above command returns JSON structured like this:
{
"current": 3
}
This endpoint retrieves current visitors for your domain.
HTTP Request
GET https://app.kindmetrics.io/api/domains/1/current
Retrieve Goals
curl "https://app.kindmetrics.io/api/domains/1/goals"
-H "Authorization: Bearer APIKEY"
The above command returns JSON structured like this:
[
{
"name": "/sign_up",
"kind": "Path",
"conversions": 3
}
]
This endpoint retrieves current visitors for your domain.
HTTP Request
GET https://app.kindmetrics.io/api/domains/1/goals
Errors
The Kindmetrics API uses the following error codes:
Error Code | Meaning |
---|---|
400 | Bad Request -- Your request is invalid. |
401 | Unauthorized -- Your API key is wrong. |
403 | Forbidden -- You have no permission for that request |
404 | Not Found -- The specified domain could not be found. |
405 | Method Not Allowed -- You tried to access a domain with an invalid method. |
406 | Not Acceptable -- You requested a format that isn't json. |
429 | Too Many Requests |
500 | Internal Server Error -- We had a problem with our server. Try again later. |
503 | Service Unavailable -- We're temporarily offline for maintenance. Please try again later. |