---
updatedAt: 2025-11-05T21:12:15.000Z
agentTools:
  projectIndex: https://developers.short.io/llms.txt
---

# Link Statistics

Returns detailed statistics for link in a given period

> 📘 Information below might be outdated - please visit our recently updated [API Reference](https://developers.short.io/reference/)

The instruction below shows how to get detailed statistics for a link.

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

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

![](https://files.readme.io/5cdd546-Screen_Shot_2021-08-11_at_2.57.06_PM.png "Screen Shot 2021-08-11 at 2.57.06 PM.png")

### **2)** Copy an ID of a short link you want to get detailed statistics.

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

![](https://files.readme.io/a5095df-1.png "1.png")

![](https://files.readme.io/4fabaa5-Screen_Shot_2021-08-11_at_3.15.24_PM.png "Screen Shot 2021-08-11 at 3.15.24 PM.png")

### **3)** Install prerequisites for requests.

```python
pip install requests
```
```javascript Node.js
npm install --save axios

npm install qs
```

Now everything is ready to run the following snippet. It will send detailed statistics of a short URL.

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

> 📘
>
> Please, replace LINK\_ID and Period with appropriate values.

> 👍
>
> Available periods for statistics: today, yesterday, total, week, month, lastmonth, last7, last30 and custom.

```python
import requests

url = "https://api-v2.short.io/statistics/link/linkID"

querystring = {"period":"total","tzOffset":"0"}

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

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

print(response.text)
```
```javascript Node.js
const qs = require('qs')
const axios = require('axios');

axios.get('https://api-v2.short.io/statistics/link/linkID', {
    params: {
        period: 'total', 
        tzOffset: '0'
},
headers: {
    accept:'*/*',
    authorization: '<<apiKey>>'
}
})
.then(function (response) {
  console.log(response.data);
})
.catch(function (response) {
  console.log(response);
});
```
```ruby
require 'uri'
require 'net/http'
require 'openssl'

url = URI("https://api-v2.short.io/statistics/link/linkID?period=total&tzOffset=0")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE

request = Net::HTTP::Get.new(url)
request["accept"] = '*/*'
request["authorization"] = '<<apiKey>>'

response = http.request(request)
puts response.read_body
```

### **5)** Launch the file.

```python
python filename.py
```
```javascript Node.js
node filename.js
```
```ruby Ruby
ruby filename.rb
```

### **6)** JSON Response.

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

```json
{
  totalClicks: 42,
  humanClicks: 8,
  humanClicksChange: '0',
  totalClicksChange: '0',
  clickStatistics: { datasets: [ [Object] ] },
  interval: {
    startDate: null,
    endDate: null,
    prevStartDate: null,
    prevEndDate: null
  },
  referer: [],
  social: [],
  browser: [
    { score: 6, browser: 'Chrome' },
    { score: 1, browser: 'Safari' },
    { score: 1, browser: 'Firefox' }
  ],
  country: [
    { score: 4, country: 'US', countryName: 'United States' },
    { score: 3, country: 'FR', countryName: 'France' },
    { score: 1, country: 'DE', countryName: 'Germany' }
  ],
  city: [
    { score: 2, city: '4744870', name: 'Ashburn' },
    { score: 2, city: '5714964', name: 'Boardman' },
    { score: 1, city: '2921232', name: 'Gera' }
  ],
  os: [ { score: 5, os: 'Windows' }, { score: 3, os: 'Mac OS X' } ]
}
```

### **7)** How to request statistics for a custom period

> 🚧
>
> startDate and endDate parameters require date format in milliseconds from epoch.\
> Here you can convert your date: <https://www.epochconverter.com/>

```python
pip install arrow
```

```python
import requests
import arrow

url = "https://api-v2.short.cm/statistics/link/linkID"

querystring = {"period":"custom","tzOffset":"0","startDate": arrow.get('2020-05-01T21:23:58.970460+07:00').timestamp * 1000,"endDate": arrow.get('2020-05-04T21:23:58.970460+07:00').timestamp * 1000}

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

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

print(response.text)
```
```javascript Node.js
const qs = require('qs')
const axios = require('axios');

axios.get('https://api-v2.short.cm/statistics/link/283366412', {
    params: {
        period: 'total', 
        tzOffset: '0',
        startDate: new Date("2020-04-30T15:56:53").valueOf(), 
        endDate: new Date("2020-05-05T15:56:53").valueOf()
},
headers: {
    accept:'*/*',
    authorization: '<<apiKey>>'
}
})
.then(function (response) {
  console.log(response.data);
})
.catch(function (response) {
  console.log(response);
});
```
```ruby
require 'uri'
require 'net/http'
require 'openssl'

url = URI("https://api-v2.short.cm/statistics/link/linkID?period=total&tzOffset=0&startDate=1588231150000&endDate=1588663150000")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE

request = Net::HTTP::Get.new(url)
request["accept"] = '*/*'
request["authorization"] = '<<apiKey>>'

response = http.request(request)
puts response.read_body
```

```json
{
  totalClicks: 21,
  humanClicks: 7,
  humanClicksChange: '0',
  totalClicksChange: '0',
  clickStatistics: { datasets: [ [Object] ] },
  interval: {
    startDate: '2020-04-30T12:56:53.000Z',
    endDate: '2020-05-05T12:56:53.000Z',
    prevStartDate: null,
    prevEndDate: null
  },
  referer: [ { score: 1, referer: 't.co' } ],
  browser: [
    { score: 4, browser: 'Chrome' },
    { score: 1, browser: 'Mobile Safari' }
  ],
  country: [
    { score: 6, country: 'US', countryName: 'United States' },
    { score: 1, country: 'DE', countryName: 'Germany' }
  ],
  city: [
    { score: 2, city: '4744870', name: 'Ashburn' },
    { score: 1, city: '4509177', name: 'Columbus' },
    { score: 1, city: '5714964', name: 'Boardman' }
  ],
  os: [
    { score: 3, os: 'Windows' },
    { score: 2, os: 'Mac OS X' },
    { score: 1, os: 'iOS' },
    { score: 1, os: 'Linux' }
  ]
}
```