High volume short link creation

If you need to create more, than 10 links per second this tutorial will help you

📘

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

Some short link creation use cases require the creation of large amount of links. We provide a special API for this use case

1. Find your API key

You need to find your API key here: https://app.short.cm/users/integrations/api-key

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

2. Upgrade your account

Please make sure you have a plan, which can fit all the links. We suggest you use Enterprise plan. It has no link limit and you should not worry about approaching link limits

3. Learn how does it work

You can send up to 1000 links per request in this format:

{
    domain: '<<domain_name>>',
    links: [{
      originalURL: 'http://yourlongdomain.com/yourlonglink',
    }, {
      originalURL: 'http://yourlongdomain.com/yourlonglink',
      cloaking: true
    }]
  }```
We will send list of responses:
```json
[
  {
    "id": 220974815,
    "originalURL": "http://yourlongdomain.com/yourlonglink",
    "DomainId": 63068,
    "archived": false,
    "path": "RPUcZh",
    "redirectType": null,
    "createdAt": "2019-10-13T13:22:17.888Z",
    "OwnerId": 48815,
    "updatedAt": "2019-10-13T13:22:17.888Z",
    "secureShortURL": "https://<<domain_name>>/RPUcZh",
    "shortURL": "https://<<domain_name>>/RPUcZh",
    "duplicate": false,
    "success": true
  },
  {
    "error": "Link expiration, link cloaking or password protection require upgrade to a personal plan",
    "status": 402,
    "success": false
  }
]

4. Copy the code

<?php
$curl = curl_init();
curl_setopt_array($curl, array(
  CURLOPT_URL => "https://api.short.io/links/bulk",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "POST",
  CURLOPT_POSTFIELDS => json_encode(
    array(
      'domain' => '<<domain_name>>',
      'links' => array(
        array(
          'originalURL' => 'http://yourlongdomain.com/yourlonglink',
        ),
        array(
          'originalURL' => 'http://yourlongdomain.com/yourlonglink',
          'cloaking' => true
        )
      )
    )
  ),
  CURLOPT_HTTPHEADER => array(
    "authorization: <<apiKey>>",
    "content-type: application/json"
  ),
));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
  echo "cURL Error #:" . $err;
} else {
  echo $response;
}
const got = require("got");
const options = {
  method: 'POST',
  headers: {
    authorization: '<<apiKey>>',
  },
  body: {
    domain: 'andrii22224324532.shortcm.li',
    links: [{
      originalURL: 'http://yourlongdomain.com/yourlonglink',
    }, {
      originalURL: 'http://yourlongdomain.com/yourlonglink2',
      cloaking: true
    }]
  },
  json: true
};
got("https://api.short.io/links/bulk", options).then(response => {
  console.log(response.body);
}).catch(e => {
  console.error(e.body);
});
package main
import (
    "bytes"
    "encoding/json"
    "fmt"
    "io/ioutil"
    "net/http"
)
type Link struct {
    OriginalURL string `json:"originalURL"`;
    Cloaking bool `json:"cloaking"`
}
type BulkLinkRequest struct {
    Domain string `json:"domain"`
    Links []Link `json:"links"`
}
func main() {
    client := &http.Client{}
    jsonData := BulkLinkRequest{
        Domain: "<<domain_name>>",
        Links: []Link{
            {OriginalURL: "http://yourlongdomain.com/yourlonglink"},
            {OriginalURL: "http://yourlongdomain.com/yourlonglink2", Cloaking: true},
        },
    }
    jsonValue, _ := json.Marshal(jsonData)
    req, err := http.NewRequest("POST", "https://api.short.io/links/bulk", bytes.NewBuffer(jsonValue))
    if err != nil {
        fmt.Printf("The request creation failed with error %s\n", err)
	return;
    }
    req.Header.Add("Content-Type", "application/json")
    req.Header.Add("Authorization", "<<apiKey>>")
    response, err := client.Do(req)
    if err != nil {
        fmt.Printf("The HTTP request failed with error %s\n", err)
	return;
    }
    data, _ := ioutil.ReadAll(response.Body)
    fmt.Println(string(data))
}
using RestSharp;
using System;
using System.Collections.Generic;
class Link
{
    string originalURL;
}
namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            var client = new RestClient("https://api.short.io/");
            client.AddDefaultHeader("Authorization", "<<apiKey>>");
            var req = new RestRequest("links/bulk", Method.POST, DataFormat.Json);
            var links = new List<object>
            {
                new { originalURL = "http://yourlongdomain.com/yourlonglink" },
                new
                {
                    originalURL = "http://yourlongdomain.com/yourlonglink",
                    cloaking = true
                }
            };
            req.AddJsonBody(new
            {
                domain = "<<domain_name>>",
                links,
            });
            var res = client.Execute(req);
            Console.WriteLine(res.Content);
        }
    }
}