Getting a list of short links

This tutorial will help you If you want to get a list of short links for a given domain

To get a list of short links

  1. Create a secret API key from the Integrations and API menu: https://app.short.io/settings/integrations/api-key
  2. Get the ID of the domain which short links you want to display:
  • In the Short.io Dashboard open the Domain Settings and copy the domain ID from your browser's address bar:
  1. Then you may need to install prerequisites for HTTP requests (if necessary, depending on your programming language and its version).
  2. Use the following code snippets to get the list of links:

📘

Please note that there is a limitation on the number of links that the API can return. Consequently, the limit value must be less than 150.

Replace DOMAIN_ID, LIMIT and APIKEY with the appropriate values.

<?php

$curl = curl_init();

curl_setopt_array($curl, [
  CURLOPT_URL => "https://api.short.io/api/links?domain_id=<<domain_id>>&limit=<<limit>>",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "GET",
  CURLOPT_HTTPHEADER => [
    "Authorization: <<apiKey>>",
    "accept: application/json"
  ],
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
  echo "cURL Error #:" . $err;
} else {
  echo $response;
}

import requests

url = "https://api.short.io/api/links?domain_id=<<domain_id>>&limit=<<limit>>"

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

response = requests.get(url, headers=headers)

print(response.text)
const url = 'https://api.short.io/api/links?domain_id=<<domain_id>>&limit=<<limit>>';
const options = {
  method: 'GET',
  headers: {accept: 'application/json', Authorization: '<<apiKey>>'}
};

fetch(url, options)
  .then(res => res.json())
  .then(json => console.log(json))
  .catch(err => console.error(err));
HttpRequest request = HttpRequest.newBuilder()
    .uri(URI.create("https://api.short.io/api/links?domain_id=<<domain_id>>&limit=<<limit>>"))
    .header("accept", "application/json")
    .header("Authorization", "<<apiKey>>")
    .method("GET", HttpRequest.BodyPublishers.noBody())
    .build();
HttpResponse<String> response = HttpClient.newHttpClient().send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
using System.Net.Http.Headers;
var client = new HttpClient();
var request = new HttpRequestMessage
{
    Method = HttpMethod.Get,
    RequestUri = new Uri("https://api.short.io/api/links?domain_id=<<domain_id>>&limit=<<limit>>"),
    Headers =
    {
        { "accept", "application/json" },
        { "Authorization", "<<apiKey>>" },
    },
};
using (var response = await client.SendAsync(request))
{
    response.EnsureSuccessStatusCode();
    var body = await response.Content.ReadAsStringAsync();
    Console.WriteLine(body);
}
  1. Review the JSON response which should resemble the following:
{
  "count": 4,
  "links": [
    {
      "originalURL": "YOUR_LONG_URL",
      "path": "slug1",
      "idString": "lnk_4Th1_8MAbEywPHUsk11111",
      "id": "lnk_4Th1_8MAbEywPHUsk11111",
      "shortURL": "http://mydomain.fr/slug1",
      "secureShortURL": "https://mydomain.fr/slug1",
      "cloaking": false,
      "title": "Link Title",
      "tags": [],
      "createdAt": "2024-10-29T08:00:47.490Z",
      "skipQS": false,
      "archived": false,
      "DomainId": 11111,
      "OwnerId": 11111,
      "hasPassword": false,
      "source": "website",
      "User": {
        "id": 11111,
        "name": "YourName",
        "email": "youremailaddress",
        "photoURL": "youremailaddress/2zHS33ejyfE11111"
      }
    },
    {
      "originalURL": "YOUR_LONG_URL2",
      "path": "slug2",
      "idString": "lnk_4Th1_YUSVK9T92Dewx11111",
      "id": "lnk_4Th1_YUSVK9T92Dewx11111",
      "shortURL": "http://mydomain.fr/slug2",
      "secureShortURL": "https://mydomain.fr/slug2",
      "cloaking": false,
      "title": "Link Title",
      "tags": [],
      "createdAt": "2024-10-29T07:59:57.487Z",
      "skipQS": false,
      "archived": false,
      "DomainId": 11111,
      "OwnerId": 11111,
      "hasPassword": false,
      "source": "website",
      "User": {
        "id": 11111,
        "name": "YourName",
        "email": "youremailaddress",
        "photoURL": "youremailaddress/2zHS33ejyfE11111"
      }
    },
    {
      "originalURL": "YOUR_LONG_URL3",
      "path": "slug3",
      "idString": "lnk_4Th1_b4cX4HwE0OTal11111",
      "id": "lnk_4Th1_b4cX4HwE0OTal11111",
      "shortURL": "http://mydomain.fr/slug3",
      "secureShortURL": "https://mydomain.fr/slug3",
      "cloaking": false,
      "title": "Link Title",
      "tags": [],
      "createdAt": "2024-10-29T07:57:43.527Z",
      "skipQS": false,
      "archived": false,
      "DomainId": 11111,
      "OwnerId": 11111,
      "hasPassword": false,
      "source": "website",
      "User": {
        "id": 11111,
        "name": "YourName",
        "email": "youremailaddress",
        "photoURL": "youremailaddress/2zHS33ejyfE11111"
      }
    },
    {
      "originalURL": "YOUR_LONG_URL4",
      "path": "slug4",
      "idString": "lnk_4Th1_ZhVH0yrWn58CnJ11111",
      "id": "lnk_4Th1_ZhVH0yrWn58CnJ11111",
      "shortURL": "http://mydomain.fr/slug4",
      "secureShortURL": "https://mydomain.fr/slug4",
      "cloaking": false,
      "title": "Link Title",
      "tags": [],
      "createdAt": "2024-10-29T07:55:00.334Z",
      "skipQS": false,
      "archived": false,
      "DomainId": 11111,
      "OwnerId": 11111,
      "hasPassword": false,
      "source": "website",
      "User": {
        "id": 11111,
        "name": "YourName",
        "email": "youremailaddress",
        "photoURL": "youremailaddress/2zHS33ejyfE11111"
      }
    }
  ],
  "nextPageToken": null
}

The following page provides more information about the settings for obtaining a list of links: https://developers.short.io/reference/get_api-links