Skip to main content

Requesting Top Links by Columns

📘 Information below might be outdated - please visit our recently updated API Reference

The instruction below shows how to request top links.

1) Get your API key here: https://app.short.io/settings/integrations/api-key

  • Click "Create API key".
  • Add a Secret key.

Short.io API key creation page with Secret and Public key options

2) Copy an ID of a domain you want to request clickstream.

  • Open domain settings.
  • Copy the domain ID.

Domain settings gear icon in the Short.io dashboard

Domain ID highlighted in domain settings panel

3) Install prerequisites for requests.

pip install requests

Now everything is ready to run the following snippet. It will return a list of top links.

4) Create a file: filename.py/ .js/ .rb. Use the code snippet below.

📘

Please, replace domainID, column parameters with appropriate values.

👍

You can use path, method, st, proto, human, browser, browser_version, country, city, social, refhost, os, utm_medium, utm_source, utm_campaign, goal_completed, ab_path for the column parameter.

import requests

url = "https://api-v2.short.io/statistics/domain/domainID/top"

payload = {"period":"total","limit":10,"tzOffset":0,"column":"country"}
headers = {
'accept': "*/*",
'content-type': "application/json",
'authorization': "<<apiKey>>"
}

response = requests.request("POST", url, json=payload, headers=headers)

print(response.text)

5) Launch the file.

python filename.py

6) JSON Response.

Once you run the code, you will see the response.

[
{ score: '2730', column: 'US', displayName: 'United States' },
{ score: '2148', column: 'CN', displayName: 'China' },
{ score: '1601', column: 'SG', displayName: 'Singapore' },
{ score: '1554', column: 'DE', displayName: 'Germany' },
{ score: '1411', column: 'HK', displayName: 'Hong Kong' },
{ score: '1152', column: 'FR', displayName: 'France' },
{ score: '814', column: 'CA', displayName: 'Canada' },
{ score: '707', column: 'RU', displayName: 'Russia' },
{ score: '386', column: '', displayName: '' },
{ score: '313', column: 'IN', displayName: 'India' },
{ score: '236', column: 'GB', displayName: 'United Kingdom' },
{ score: '235', column: 'BR', displayName: 'Brazil' },
{ score: '185', column: 'UA', displayName: 'Ukraine' },
{ score: '97', column: 'NL', displayName: 'Netherlands' }
]