Skip to content

Instantly share code, notes, and snippets.

@Kugelschieber
Last active April 26, 2023 13:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Kugelschieber/43876968d3f029d7d5a31c23a6f27b21 to your computer and use it in GitHub Desktop.
Save Kugelschieber/43876968d3f029d7d5a31c23a6f27b21 to your computer and use it in GitHub Desktop.

Pirsch reading statistics example using the API

Step 0

Create a client ID and secret on the developer settings page and save the secret for later use.

Step 1

Get a temporary access token.

curl --location --request POST 'https://api.pirsch.io/api/v1/token' \
--header 'Content-Type: application/json' \
--data-raw '{
    "client_id": "INSERT_CLIENT_ID",
    "client_secret": "INSERT_CLIENT_SECRET"
}
'

Step 2

Use the access token in the Authorization header to get the domain (dashboard) ID.

curl --location --request GET 'https://api.pirsch.io/api/v1/domain' \
--header 'Authorization: Bearer INSERT_ACCESS_TOKEN'

Step 3

Read the visitor graphs or any other statistic you care about. Use a filter to limit the results.

curl --location --request GET 'https://api.pirsch.io/api/v1/statistics/visitor?id=INSERT_DASHBOARD_ID&from=2022-12-01&to=2022-12-09' \
--header 'Authorization: Bearer INSERT_ACCESS_TOKEN'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment