0% found this document useful (0 votes)
10 views11 pages

SHORTIO_ LINK GUIDE (1)

This document provides a guide on how to create short links using the Short.io API, including obtaining an API key and writing the necessary code in various programming languages. It also covers bulk link creation for high volume needs and outlines the parameters and responses associated with link creation. Additionally, it highlights the importance of checking for updated API references and offers examples of code snippets for implementation.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views11 pages

SHORTIO_ LINK GUIDE (1)

This document provides a guide on how to create short links using the Short.io API, including obtaining an API key and writing the necessary code in various programming languages. It also covers bulk link creation for high volume needs and outlines the parameters and responses associated with link creation. Additionally, it highlights the importance of checking for updated API references and offers examples of code snippets for implementation.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 11

Creating your first

short link on Short.io


📘
This page will help you to create your first link with our API

Information below might be outdated -


please visit our recently updated API
Reference
This guide will show you how to create short links with our API. First of all, you need to
check if you can solve the problem with our Zapier integration. It allows you to set up
common integrations without writing a single line of code.

To use our API you need to get your API key here:
https://app.short.io/settings/integrations/api-key

●​ Click "Create API key".


●​ Add a Secret key.

Then you need to install prerequisites for HTTP requests if they are needed in your
programming language

pythonnode.jsc#phpperl
pip install requests

And now you are ready to write actual source code. The following snippet will create a

📘
short URL with an auto-generated path for given long URL

Please replace example.com with your actual domain name

PHPPythonC#Gonode.js

<?php
$curl = curl_init();

curl_setopt_array($curl, array(
CURLOPT_URL => "https://api.short.io/links",
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(
'originalURL' => 'http://yourlongdomain.com/yourlonglink',
'domain' => 'example.com'
)),
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;
}

Once you will run this code, you will see a response:
JSON

{
"idString": "lnk_49n_okhPU",
"path": "xpsmpw",
"title": null,
"icon": null,
"archived": false,
"originalURL": "http://yourlongdomain.com/yourlonglink",
"iphoneURL": null,
"androidURL": null,
"splitURL": null,
"expiresAt": null,
"expiredURL": null,
"redirectType": null,
"cloaking": null,
"source": null,
"AutodeletedAt" :null,
"createdAt": "2019-10-11T16:47:06.000Z",
"updatedAt": "2019-10-11T16:47:06.000Z",
"DomainId": 15957,
"OwnerId": 48815,
"secureShortURL": "https://example.com/xpsmpw",
"shortURL": "https://example.com/xpsmpw"
}

Most important keys here are "shortURL" (the URL of the newly-created short link) and
"idString" (you will need to update or delete created URL)

That's all, you have created a link with our API. Our next articles will be about more
advanced short.io features

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:

JSON

{
domain: 'example.com',
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://example.com/RPUcZh",
"shortURL": "https://example.com/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


PHPnode.jsGoC#
<?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' => 'example.com',
'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;

login api keys

import requests

url = "https://api.short.io/links/opengraph/domainId/linkId"

response = requests.get(url)

print(response.text)

Create a new link


post https://api.short.io/links
This method creates a new link. If parameter "path" is omitted, it​
generates path by algorithm, chosen in domain settings.

Notes:

1.​ If URL with a given path already exists and originalURL of the URL in database is
equal to originalURL argument, it returns information about existing URL
2.​ If URL with a given path already exists and originalURL is different from originalURL
in database, it returns error with a status 409
3.​ If URL with a given originalURL exists, and no path is given, it returns information
about existing URL and does not create anything
4.​ If URL with a given originalURL exists, and custom path is given, it creates a new
short URL

Rate limit: 50/s


Log in to see full request history

time status user agent

Make a request to see history.


0 Requests This Month

Body Params
originalURL
string
required
Original URL
cloaking
boolean
Cloaking
truefalse
password
string
Link password
redirectType
integer | null
HTTP code for redirect
301301302307308
expiresAt
Link expiration date in milliseconds or ISO string

Option 1

Option 2
expiredURL
string | null
Expired URL
title
string
Link title
tags
array of strings
Array of link tags

ADD string
utmSource
string
set utm_source parameter to destination link
utmMedium
string
set utm_medium parameter to destination link
utmCampaign
string
set utm_campaign parameter to destination link
utmTerm
string
set utm_term parameter to destination link
utmContent
string
set utm_content parameter to destination link
ttl
Time to live in milliseconds or ISO string

Option 1

Option 2
path
string | null
Link slug
androidURL
string | null
Android URL
iphoneURL
string | null
iPhone URL
createdAt
Link creation date in milliseconds

Option 1

Option 2
clicksLimit
integer | null
≥1
disable link after specified number of clicks
passwordContact
boolean | null
Provide your email to users to get a password
truefalse
skipQS
boolean
Defaults to false
Skip query string merging
truefalse
archived
boolean
Defaults to false
Link is archived
truefalse
splitURL
string | null
Split URL
splitPercent
integer | null
1 to 100
Split URL percentage
integrationAdroll
string | null
Adroll integration
integrationFB
string | null
Facebook integration
integrationGA
string | null
Google Analytics integration
integrationGTM
string | null
Google Tag Manager integration
domain
string
required
Domain hostname
allowDuplicates
boolean
Defaults to false
Allow duplicates
truefalse
folderId
string
Folder ID
Responses

200

Default Response

400

Default Response

import requests

url = "https://api.short.io/links"

payload = {
"skipQS": False,
"archived": False,
"allowDuplicates": False
}
headers = {
"accept": "application/json",
"content-type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.text)

Create a new link


(simple version)
gethttps://api.short.io/links/tweetbot

Simple version of link create endpoint. You can use it if you can not use POST method​
Rate limit: 50/s
Log in to see full request history
time status user agent

Make a request to see history.


0 Requests This Month

Query Params
domain
string
required
Domain hostname
path
string
Link path
originalURL
string
required
Link original URL
title
string
Link title
urlOnly
boolean
Return only URL
truefalse
apiKey
string
required
API key
import requests

url = "https://api.short.io/links/tweetbot"

response = requests.get(url)

print(response.text)

You might also like