SHORTIO_ LINK GUIDE (1)
SHORTIO_ LINK GUIDE (1)
To use our API you need to get your API key here:
https://app.short.io/settings/integrations/api-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
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
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
}
]
$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;
import requests
url = "https://api.short.io/links/opengraph/domainId/linkId"
response = requests.get(url)
print(response.text)
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
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"
}
print(response.text)
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
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)