Skip to main content

Getting a list of country targeting rules

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

The instruction below shows how to get a list of country targeting rules for a URL.

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

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

  • Open the statistics of the short link.
  • Copy the link ID.

3) Install prerequisites for requests.​

pip install requests

Now everything is ready to run the following snippet. It will get a list of country targeting rules for a URL.

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

📘

Please, replace link_idString with an appropriate value.

import requests

url = "https://api.short.io/link_country/link_idString"

headers = {
'accept': "application/json",
'authorization': "<<apiKey>>"
}

response = requests.request("GET", url, headers=headers)

print(response.text)

5) Launch the file.​

python filename.py

6) JSON Response (list of country targeting rules).​

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

[
{
id: 24151,
country: 'GA',
originalURL: 'https://toolbox.googleapps.com/apps/dig/#CAA/',
createdAt: '2020-06-01T10:37:18.000Z',
updatedAt: '2020-06-01T10:37:18.000Z',
link_idString: "lnk_49n_UcaN"
}
]