An API key is required for requests to be processed by the system. Once a user registers, an API key is automatically generated for this user. The API key must be sent with each request (see full example below). If the API key is not sent or is expired, there will be an error. Please make sure to keep your API key secret to prevent abuse.
To authenticate with the API system, you need to send your API key as an authorization token with each request. You can see sample code below.
curl --location --request POST 'https://linktw.in/api/account' \
--header 'Authorization: Bearer YOURAPIKEY' \
--header 'Content-Type: application/json' \
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://linktw.in/api/account",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_MAXREDIRS => 2,
CURLOPT_TIMEOUT => 10,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer YOURAPIKEY",
"Content-Type: application/json",
],
));
$response = curl_exec($curl);
var request = require('request');
var options = {
'method': 'POST',
'url': 'https://linktw.in/api/account',
'headers': {
'Authorization': 'Bearer YOURAPIKEY',
'Content-Type': 'application/json'
},
body: ''
};
request(options, function (error, response) {
if (error) throw new Error(error);
console.log(response.body);
});
Our API has a rate limiter to safeguard against spike in requests to maximize its stability. Our rate limiter is currently caped at 120 requests per 1 minute.
Several headers will be sent alongside the response and these can be examined to determine various information about the request.
X-RateLimit-Limit: 120
X-RateLimit-Remaining: 119
X-RateLimit-Reset: TIMESTAMP
All API response are returned in JSON format by default. To convert this into usable data, the appropriate function will need to be used according to the language. In PHP, the function json_decode() can be used to convert the data to either an object (default) or an array (set the second parameter to true). It is very important to check the error key as that provides information on whether there was an error or not. You can also check the header code.
{
"error": 1,
"message": "An error occurred"
}
https://linktw.in/api/urls?limit=2&page=1&order=date&collections=%5B1%2C2%5D
To get your links via the API, you can use this endpoint. You can also filter data (See table for more info).
| Parameter | Description |
|---|---|
| limit | (optional) Per page data result |
| page | (optional) Current page request |
| order | (optional) Sort data: date, date_desc, date_asc, clicks_desc, clicks_asc, name_asc, name_desc |
| search | (optional) Search links by alias, custom alias, URL, meta title, custom title, or description. Supports domain alias expansion (e.g., "youtube" matches youtube.com and youtu.be) |
| date_from | (optional) Filter by start date (Y-m-d or ISO 8601 format, e.g., 2025-01-01 or 2025-01-01T00:00:00.000Z) |
| date_to | (optional) Filter by end date (Y-m-d or ISO 8601 format, e.g., 2025-01-31 or 2025-01-31T23:59:59.999Z) |
| collections | (optional) Array of collection IDs or names to filter links by. Use either all IDs or all names, not mixed. Example: [1,2,3] or ["Marketing","Social Media"] |
curl --location --request GET 'https://linktw.in/api/urls?limit=2&page=1&order=date&collections=%5B1%2C2%5D' \
--header 'Authorization: Bearer YOURAPIKEY' \
--header 'Content-Type: application/json' \
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://linktw.in/api/urls?limit=2&page=1&order=date&collections=%5B1%2C2%5D",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_MAXREDIRS => 2,
CURLOPT_TIMEOUT => 10,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer YOURAPIKEY",
"Content-Type: application/json",
],
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
var request = require('request');
var options = {
'method': 'GET',
'url': 'https://linktw.in/api/urls?limit=2&page=1&order=date&collections=%5B1%2C2%5D',
'headers': {
'Authorization': 'Bearer YOURAPIKEY',
'Content-Type': 'application/json'
},
};
request(options, function (error, response) {
if (error) throw new Error(error);
console.log(response.body);
});
{
"error": "0",
"data": {
"result": 2,
"perpage": 2,
"currentpage": 1,
"nextpage": 1,
"maxpage": 1,
"urls": [
{
"id": 2,
"alias": "google",
"shorturl": "https:\/\/linktw.in\/google",
"longurl": "https:\/\/google.com",
"clicks": 0,
"uniqueclicks": 0,
"title": "Google",
"description": "",
"display_title": "My Dashboard Title",
"custom_title": "My Custom Google Title",
"custom_description": "This is my custom description for Google",
"collections": [
{
"id": 1,
"name": "Marketing"
},
{
"id": 3,
"name": "Social Media"
}
],
"pixels": [
{
"id": 1,
"type": "gtmpixel",
"name": "GTM Pixel"
},
{
"id": 2,
"type": "fbpixel",
"name": "Facebook Pixel"
}
],
"date": "2023-11-10 18:01:43"
},
{
"id": 1,
"alias": "googlecanada",
"shorturl": "https:\/\/linktw.in\/googlecanada",
"longurl": "https:\/\/google.ca",
"clicks": 0,
"uniqueclicks": 0,
"title": "Google Canada",
"description": "",
"display_title": null,
"custom_title": null,
"custom_description": null,
"collections": [],
"pixels": [],
"date": "2023-11-10 18:00:25"
}
]
}
}
https://linktw.in/api/url/:id
To get details for a single link via the API, you can use this endpoint. You can pass either the link ID or the full short URL.
| Parameter | Description |
|---|---|
| 0 | {"name":":id","description":"(required) The link ID (e.g., 123) or the full short URL (e.g., https:\/\/linktw.in\/abc123)"} |
curl --location --request GET 'https://linktw.in/api/url/:id' \
--header 'Authorization: Bearer YOURAPIKEY' \
--header 'Content-Type: application/json' \
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://linktw.in/api/url/:id",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_MAXREDIRS => 2,
CURLOPT_TIMEOUT => 10,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer YOURAPIKEY",
"Content-Type: application/json",
],
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
var request = require('request');
var options = {
'method': 'GET',
'url': 'https://linktw.in/api/url/:id',
'headers': {
'Authorization': 'Bearer YOURAPIKEY',
'Content-Type': 'application/json'
},
};
request(options, function (error, response) {
if (error) throw new Error(error);
console.log(response.body);
});
{
"error": 0,
"id": 1,
"details": {
"id": 1,
"alias": "googlecanada",
"shorturl": "https:\/\/linktw.in\/googlecanada",
"longurl": "https:\/\/google.com",
"domain": "https:\/\/linktw.in",
"title": "Google",
"description": "",
"display_title": "My Dashboard Title",
"custom_title": "My Custom Title",
"custom_description": "My Custom Description",
"note": "Internal note for this link",
"pass": false,
"location": {
"canada": {
"all": "https:\/\/google.ca"
},
"united states": {
"CA": "https:\/\/google.us\/california",
"NY": "https:\/\/google.us\/newyork",
"all": "https:\/\/google.us"
}
},
"device": {
"iphone": "https:\/\/google.com",
"android": "https:\/\/google.com"
},
"languagetarget": {
"en": "https:\/\/google.com",
"fr": "https:\/\/google.ca"
},
"parameters": {
"utm_source": "api",
"utm_medium": "link"
},
"expiry": "2025-12-31 23:59:59",
"clicklimit": 1000,
"expirationredirect": "https:\/\/example.com\/expired",
"abtesting": [
{
"percent": 50,
"link": "https:\/\/variant-a.com",
"count": 125
},
{
"percent": 50,
"link": "https:\/\/variant-b.com",
"count": 130
}
],
"date": "2023-11-10 18:01:43",
"collections": [
{
"id": 1,
"name": "Marketing",
"color": "#FF6B6B"
},
{
"id": 3,
"name": "Social Media",
"color": "#4ECDC4"
}
],
"pixels": [
{
"id": 1,
"type": "gtmpixel",
"name": "GTM Pixel",
"tag": "GTM-ABCDE"
},
{
"id": 2,
"type": "fbpixel",
"name": "Facebook Pixel",
"tag": "123456789012345"
}
]
},
"data": {
"clicks": 0,
"uniqueClicks": 0,
"topCountries": 0,
"topReferrers": 0,
"topBrowsers": 0,
"topOs": 0,
"socialCount": {
"facebook": 0,
"twitter": 0,
"google": 0
}
}
}
https://linktw.in/api/url/add
To create a link, you need to send a valid data in JSON via a POST request. The data must be sent as the raw body of your request as shown below. The example below shows all the parameters you can send but you are not required to send all (See table for more info).
| Parameter | Description |
|---|---|
| url | (required) Long URL to shorten. |
| custom | (optional) Custom alias instead of random alias. |
| password | (optional) Password protection |
| domain | (optional) Custom Domain (must match an already added branded domain) |
| expiry | (optional) Expiration for the link example 2024-09-28 23:11:16 |
| clicklimit | (optional) Maximum number of clicks before link expires (integer) |
| expirationredirect | (optional) URL to redirect to after link expires (by date or click limit) |
| note | (optional) Internal note/description for this link (not visible to visitors) |
| display_title | (optional) Custom title for organizing this link in your dashboard. This is for your reference only and does not affect og:title or the link preview. |
| geotarget | (optional) Geo targeting data. Array of objects with location, link, and optional state fields. |
| devicetarget | (optional) Device targeting data. Array of objects with device and link fields. |
| languagetarget | (optional) Language targeting data. Array of objects with language and link fields. |
| abtesting | (optional) A/B testing variants. Array of objects with link and optional percent fields. |
| parameters | (optional) URL parameters to append. Array of objects with name and value fields. |
| metatitle | (optional) Meta title |
| metadescription | (optional) Meta description |
| metaimage | (optional) Link to a jpg or png image |
| pixels | (optional) Array of pixel IDs to attach to the link. Get pixel IDs from the Pixels API. |
| collections | (optional) Array of collection IDs or names to add the link to. Use either all IDs or all names, not mixed. |
curl --location --request POST 'https://linktw.in/api/url/add' \
--header 'Authorization: Bearer YOURAPIKEY' \
--header 'Content-Type: application/json' \
--data-raw '{
"url": "https:\/\/google.com",
"custom": "takeme-to-google",
"password": "mypass",
"expiry": "2023-11-11 12:00:00",
"clicklimit": 1000,
"expirationredirect": "https:\/\/example.com\/expired",
"note": "Internal campaign tracking note",
"display_title": "My Google Link",
"pixels": [
1,
2
],
"collections": [
"Marketing",
"Social Media"
],
"metatitle": "Not Google",
"metadescription": "Not Google description",
"metaimage": "https:\/\/www.mozilla.org\/media\/protocol\/img\/logos\/firefox\/browser\/og.4ad05d4125a5.png",
"geotarget": [
{
"location": "Canada",
"link": "https:\/\/google.ca"
},
{
"location": "United States",
"link": "https:\/\/google.us",
"state": "California"
}
],
"devicetarget": [
{
"device": "iPhone",
"link": "https:\/\/google.com\/iphone"
},
{
"device": "Android",
"link": "https:\/\/google.com\/android"
}
],
"languagetarget": [
{
"language": "en",
"link": "https:\/\/google.com"
},
{
"language": "fr",
"link": "https:\/\/google.ca"
}
],
"abtesting": [
{
"link": "https:\/\/variant-a.example.com",
"percent": 50
},
{
"link": "https:\/\/variant-b.example.com",
"percent": 50
}
],
"parameters": [
{
"name": "aff",
"value": "3"
},
{
"name": "gtm_source",
"value": "api"
}
]
}'
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://linktw.in/api/url/add",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_MAXREDIRS => 2,
CURLOPT_TIMEOUT => 10,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer YOURAPIKEY",
"Content-Type: application/json",
],
CURLOPT_POSTFIELDS => json_encode(array(
'url' => 'https://google.com',
'custom' => 'takeme-to-google',
'password' => 'mypass',
'expiry' => '2023-11-11 12:00:00',
'clicklimit' => 1000,
'expirationredirect' => 'https://example.com/expired',
'note' => 'Internal campaign tracking note',
'display_title' => 'My Google Link',
'pixels' =>
array(
0 => 1,
1 => 2,
),
'collections' =>
array(
0 => 'Marketing',
1 => 'Social Media',
),
'metatitle' => 'Not Google',
'metadescription' => 'Not Google description',
'metaimage' => 'https://www.mozilla.org/media/protocol/img/logos/firefox/browser/og.4ad05d4125a5.png',
'geotarget' =>
array(
0 =>
array(
'location' => 'Canada',
'link' => 'https://google.ca',
),
1 =>
array(
'location' => 'United States',
'link' => 'https://google.us',
'state' => 'California',
),
),
'devicetarget' =>
array(
0 =>
array(
'device' => 'iPhone',
'link' => 'https://google.com/iphone',
),
1 =>
array(
'device' => 'Android',
'link' => 'https://google.com/android',
),
),
'languagetarget' =>
array(
0 =>
array(
'language' => 'en',
'link' => 'https://google.com',
),
1 =>
array(
'language' => 'fr',
'link' => 'https://google.ca',
),
),
'abtesting' =>
array(
0 =>
array(
'link' => 'https://variant-a.example.com',
'percent' => 50,
),
1 =>
array(
'link' => 'https://variant-b.example.com',
'percent' => 50,
),
),
'parameters' =>
array(
0 =>
array(
'name' => 'aff',
'value' => '3',
),
1 =>
array(
'name' => 'gtm_source',
'value' => 'api',
),
),
)),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
var request = require('request');
var options = {
'method': 'POST',
'url': 'https://linktw.in/api/url/add',
'headers': {
'Authorization': 'Bearer YOURAPIKEY',
'Content-Type': 'application/json'
},
body: JSON.stringify({
"url": "https:\/\/google.com",
"custom": "takeme-to-google",
"password": "mypass",
"expiry": "2023-11-11 12:00:00",
"clicklimit": 1000,
"expirationredirect": "https:\/\/example.com\/expired",
"note": "Internal campaign tracking note",
"display_title": "My Google Link",
"pixels": [
1,
2
],
"collections": [
"Marketing",
"Social Media"
],
"metatitle": "Not Google",
"metadescription": "Not Google description",
"metaimage": "https:\/\/www.mozilla.org\/media\/protocol\/img\/logos\/firefox\/browser\/og.4ad05d4125a5.png",
"geotarget": [
{
"location": "Canada",
"link": "https:\/\/google.ca"
},
{
"location": "United States",
"link": "https:\/\/google.us",
"state": "California"
}
],
"devicetarget": [
{
"device": "iPhone",
"link": "https:\/\/google.com\/iphone"
},
{
"device": "Android",
"link": "https:\/\/google.com\/android"
}
],
"languagetarget": [
{
"language": "en",
"link": "https:\/\/google.com"
},
{
"language": "fr",
"link": "https:\/\/google.ca"
}
],
"abtesting": [
{
"link": "https:\/\/variant-a.example.com",
"percent": 50
},
{
"link": "https:\/\/variant-b.example.com",
"percent": 50
}
],
"parameters": [
{
"name": "aff",
"value": "3"
},
{
"name": "gtm_source",
"value": "api"
}
]
}),
};
request(options, function (error, response) {
if (error) throw new Error(error);
console.log(response.body);
});
{
"error": 0,
"id": 3,
"shorturl": "https:\/\/linktw.in\/google",
"title": "Google",
"description": "Search the world's information..."
}
https://linktw.in/api/url/:id/update
To update a link, you need to send a valid data in JSON via a PUT request. You can use either PUT /api/url/:id/update (for numeric IDs) or PUT /api/url/update/:id (for both numeric IDs and full short URLs like https://linktw.in/abc123). Only send fields you want to change - omitted fields remain unchanged. For array fields (geotarget, devicetarget, etc.), sending the field replaces all existing values. Send null to clear a field. Send an empty array [] to remove all items from array fields.
| Parameter | Description |
|---|---|
| url | (optional) Long URL to update to |
| custom | (optional) Custom alias |
| password | (optional) Password protection. Send null to remove. |
| domain | (optional) Custom Domain (must match an already added branded domain) |
| expiry | (optional) Expiration for the link (e.g., 2024-09-28 23:11:16). Send null to remove. |
| clicklimit | (optional) Maximum number of clicks before link expires. Send null to remove. |
| expirationredirect | (optional) URL to redirect to after link expires. Send null to remove. |
| note | (optional) Internal note/description. Send null to remove. |
| display_title | (optional) Custom title for dashboard organization. Send null to remove. |
| geotarget | (optional) Geo targeting data (full replacement). Array of objects with location, link, and optional state fields. Send [] to clear all. |
| devicetarget | (optional) Device targeting data (full replacement). Array of objects with device and link fields. Send [] to clear all. |
| languagetarget | (optional) Language targeting data (full replacement). Array of objects with language and link fields. Send [] to clear all. |
| abtesting | (optional) A/B testing variants (full replacement). Array of objects with link and optional percent fields. Send [] to clear all. |
| parameters | (optional) URL parameters (full replacement). Array of objects with name and value fields. Send [] to clear all. |
| metatitle | (optional) Meta title. Send null to remove. |
| metadescription | (optional) Meta description. Send null to remove. |
| metaimage | (optional) Link to a jpg or png image. Send null to remove. |
| pixels | (optional) Array of pixel IDs (full replacement). Send [] to remove all pixels. |
| collections | (optional) Array of collection IDs or names (full replacement). Send [] to remove from all collections. |
curl --location --request PUT 'https://linktw.in/api/url/:id/update' \
--header 'Authorization: Bearer YOURAPIKEY' \
--header 'Content-Type: application/json' \
--data-raw '{
"url": "https:\/\/google.com",
"custom": "google",
"password": "mypass",
"expiry": "2024-12-31 23:59:59",
"clicklimit": 500,
"expirationredirect": "https:\/\/example.com\/link-expired",
"note": "Updated campaign note",
"display_title": "Updated Dashboard Title",
"pixels": [
1,
2
],
"collections": [
"Marketing",
"Q4 Campaign"
],
"metatitle": "Updated Title",
"metadescription": "Updated description",
"geotarget": [
{
"location": "Canada",
"link": "https:\/\/google.ca"
},
{
"location": "United States",
"link": "https:\/\/google.us",
"state": "New York"
}
],
"devicetarget": [
{
"device": "iPhone",
"link": "https:\/\/google.com\/iphone"
},
{
"device": "Android",
"link": "https:\/\/google.com\/android"
}
],
"languagetarget": [
{
"language": "en",
"link": "https:\/\/google.com"
},
{
"language": "es",
"link": "https:\/\/google.es"
}
],
"abtesting": [
{
"link": "https:\/\/variant-a.example.com",
"percent": 70
},
{
"link": "https:\/\/variant-b.example.com",
"percent": 30
}
],
"parameters": [
{
"name": "utm_source",
"value": "api"
},
{
"name": "utm_campaign",
"value": "winter2024"
}
]
}'
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://linktw.in/api/url/:id/update",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_MAXREDIRS => 2,
CURLOPT_TIMEOUT => 10,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_CUSTOMREQUEST => "PUT",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer YOURAPIKEY",
"Content-Type: application/json",
],
CURLOPT_POSTFIELDS => json_encode(array(
'url' => 'https://google.com',
'custom' => 'google',
'password' => 'mypass',
'expiry' => '2024-12-31 23:59:59',
'clicklimit' => 500,
'expirationredirect' => 'https://example.com/link-expired',
'note' => 'Updated campaign note',
'display_title' => 'Updated Dashboard Title',
'pixels' =>
array(
0 => 1,
1 => 2,
),
'collections' =>
array(
0 => 'Marketing',
1 => 'Q4 Campaign',
),
'metatitle' => 'Updated Title',
'metadescription' => 'Updated description',
'geotarget' =>
array(
0 =>
array(
'location' => 'Canada',
'link' => 'https://google.ca',
),
1 =>
array(
'location' => 'United States',
'link' => 'https://google.us',
'state' => 'New York',
),
),
'devicetarget' =>
array(
0 =>
array(
'device' => 'iPhone',
'link' => 'https://google.com/iphone',
),
1 =>
array(
'device' => 'Android',
'link' => 'https://google.com/android',
),
),
'languagetarget' =>
array(
0 =>
array(
'language' => 'en',
'link' => 'https://google.com',
),
1 =>
array(
'language' => 'es',
'link' => 'https://google.es',
),
),
'abtesting' =>
array(
0 =>
array(
'link' => 'https://variant-a.example.com',
'percent' => 70,
),
1 =>
array(
'link' => 'https://variant-b.example.com',
'percent' => 30,
),
),
'parameters' =>
array(
0 =>
array(
'name' => 'utm_source',
'value' => 'api',
),
1 =>
array(
'name' => 'utm_campaign',
'value' => 'winter2024',
),
),
)),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
var request = require('request');
var options = {
'method': 'PUT',
'url': 'https://linktw.in/api/url/:id/update',
'headers': {
'Authorization': 'Bearer YOURAPIKEY',
'Content-Type': 'application/json'
},
body: JSON.stringify({
"url": "https:\/\/google.com",
"custom": "google",
"password": "mypass",
"expiry": "2024-12-31 23:59:59",
"clicklimit": 500,
"expirationredirect": "https:\/\/example.com\/link-expired",
"note": "Updated campaign note",
"display_title": "Updated Dashboard Title",
"pixels": [
1,
2
],
"collections": [
"Marketing",
"Q4 Campaign"
],
"metatitle": "Updated Title",
"metadescription": "Updated description",
"geotarget": [
{
"location": "Canada",
"link": "https:\/\/google.ca"
},
{
"location": "United States",
"link": "https:\/\/google.us",
"state": "New York"
}
],
"devicetarget": [
{
"device": "iPhone",
"link": "https:\/\/google.com\/iphone"
},
{
"device": "Android",
"link": "https:\/\/google.com\/android"
}
],
"languagetarget": [
{
"language": "en",
"link": "https:\/\/google.com"
},
{
"language": "es",
"link": "https:\/\/google.es"
}
],
"abtesting": [
{
"link": "https:\/\/variant-a.example.com",
"percent": 70
},
{
"link": "https:\/\/variant-b.example.com",
"percent": 30
}
],
"parameters": [
{
"name": "utm_source",
"value": "api"
},
{
"name": "utm_campaign",
"value": "winter2024"
}
]
}),
};
request(options, function (error, response) {
if (error) throw new Error(error);
console.log(response.body);
});
{
"error": 0,
"id": 3,
"shorturl": "https:\/\/linktw.in\/google",
"title": "Google",
"description": "Search the world's information..."
}
https://linktw.in/api/url/:id/delete
To delete a link, you need to send a DELETE request. You can use either DELETE /api/url/:id/delete (for numeric IDs) or DELETE /api/url/delete/:id (for both numeric IDs and full short URLs like https://linktw.in/abc123).
curl --location --request DELETE 'https://linktw.in/api/url/:id/delete' \
--header 'Authorization: Bearer YOURAPIKEY' \
--header 'Content-Type: application/json' \
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://linktw.in/api/url/:id/delete",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_MAXREDIRS => 2,
CURLOPT_TIMEOUT => 10,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_CUSTOMREQUEST => "DELETE",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer YOURAPIKEY",
"Content-Type: application/json",
],
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
var request = require('request');
var options = {
'method': 'DELETE',
'url': 'https://linktw.in/api/url/:id/delete',
'headers': {
'Authorization': 'Bearer YOURAPIKEY',
'Content-Type': 'application/json'
},
};
request(options, function (error, response) {
if (error) throw new Error(error);
console.log(response.body);
});
{
"error": 0,
"message": "Link has been successfully deleted."
}
https://linktw.in/api/urls/delete
Delete multiple links in a single request. Send an array of link IDs to delete.
| Parameter | Description |
|---|---|
| ids | (required) Array of link IDs to delete |
curl --location --request POST 'https://linktw.in/api/urls/delete' \
--header 'Authorization: Bearer YOURAPIKEY' \
--header 'Content-Type: application/json' \
--data-raw '{
"ids": [
101,
102,
103
]
}'
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://linktw.in/api/urls/delete",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_MAXREDIRS => 2,
CURLOPT_TIMEOUT => 10,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer YOURAPIKEY",
"Content-Type: application/json",
],
CURLOPT_POSTFIELDS => json_encode(array(
'ids' =>
array(
0 => 101,
1 => 102,
2 => 103,
),
)),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
var request = require('request');
var options = {
'method': 'POST',
'url': 'https://linktw.in/api/urls/delete',
'headers': {
'Authorization': 'Bearer YOURAPIKEY',
'Content-Type': 'application/json'
},
body: JSON.stringify({
"ids": [
101,
102,
103
]
}),
};
request(options, function (error, response) {
if (error) throw new Error(error);
console.log(response.body);
});
{
"error": 0,
"deleted": [
101,
102,
103
],
"errors": []
}
https://linktw.in/api/domains?limit=2&page=1
Get all available domains for shortening links. This includes standard (platform-provided) domains and your branded (custom) domains. Use the isStandard field to distinguish between them.
| Parameter | Description |
|---|---|
| limit | (optional) Per page data result for branded domains |
| page | (optional) Current page request for branded domains |
curl --location --request GET 'https://linktw.in/api/domains?limit=2&page=1' \
--header 'Authorization: Bearer YOURAPIKEY' \
--header 'Content-Type: application/json' \
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://linktw.in/api/domains?limit=2&page=1",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_MAXREDIRS => 2,
CURLOPT_TIMEOUT => 10,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer YOURAPIKEY",
"Content-Type: application/json",
],
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
var request = require('request');
var options = {
'method': 'GET',
'url': 'https://linktw.in/api/domains?limit=2&page=1',
'headers': {
'Authorization': 'Bearer YOURAPIKEY',
'Content-Type': 'application/json'
},
};
request(options, function (error, response) {
if (error) throw new Error(error);
console.log(response.body);
});
{
"error": "0",
"data": {
"result": 4,
"perpage": 15,
"currentpage": 1,
"nextpage": null,
"maxpage": 1,
"domains": [
{
"id": "default",
"domain": "https:\/\/linktw.in",
"redirectroot": null,
"redirect404": null,
"isStandard": true
},
{
"id": "standard_abc123",
"domain": "https:\/\/short.link",
"redirectroot": null,
"redirect404": null,
"isStandard": true
},
{
"id": 1,
"domain": "https:\/\/mybrand.com",
"redirectroot": "https:\/\/mybrand.com\/home",
"redirect404": "https:\/\/mybrand.com\/404",
"isStandard": false
},
{
"id": 2,
"domain": "https:\/\/mycompany.io",
"redirectroot": "https:\/\/mycompany.io",
"redirect404": "https:\/\/mycompany.io\/not-found",
"isStandard": false
}
]
}
}
https://linktw.in/api/domain/add
A domain can be added using this endpoint. Please make sure the domain is correctly pointed to our server.
| Parameter | Description |
|---|---|
| domain | (required) Branded domain including http or https |
| redirectroot | (optional) Root redirect when someone visits your domain |
| redirect404 | (optional) Custom 404 redirect |
curl --location --request POST 'https://linktw.in/api/domain/add' \
--header 'Authorization: Bearer YOURAPIKEY' \
--header 'Content-Type: application/json' \
--data-raw '{
"domain": "https:\/\/domain1.com",
"redirectroot": "https:\/\/rootdomain.com",
"redirect404": "https:\/\/rootdomain.com\/404"
}'
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://linktw.in/api/domain/add",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_MAXREDIRS => 2,
CURLOPT_TIMEOUT => 10,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer YOURAPIKEY",
"Content-Type: application/json",
],
CURLOPT_POSTFIELDS => json_encode(array(
'domain' => 'https://domain1.com',
'redirectroot' => 'https://rootdomain.com',
'redirect404' => 'https://rootdomain.com/404',
)),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
var request = require('request');
var options = {
'method': 'POST',
'url': 'https://linktw.in/api/domain/add',
'headers': {
'Authorization': 'Bearer YOURAPIKEY',
'Content-Type': 'application/json'
},
body: JSON.stringify({
"domain": "https:\/\/domain1.com",
"redirectroot": "https:\/\/rootdomain.com",
"redirect404": "https:\/\/rootdomain.com\/404"
}),
};
request(options, function (error, response) {
if (error) throw new Error(error);
console.log(response.body);
});
{
"error": 0,
"id": 1
}
https://linktw.in/api/domain/:id/update
To update a branded domain, you need to send a valid data in JSON via a PUT request. The data must be sent as the raw body of your request as shown below. The example below shows all the parameters you can send but you are not required to send all (See table for more info).
| Parameter | Description |
|---|---|
| redirectroot | (optional) Root redirect when someone visits your domain |
| redirect404 | (optional) Custom 404 redirect |
curl --location --request PUT 'https://linktw.in/api/domain/:id/update' \
--header 'Authorization: Bearer YOURAPIKEY' \
--header 'Content-Type: application/json' \
--data-raw '{
"redirectroot": "https:\/\/rootdomain-new.com",
"redirect404": "https:\/\/rootdomain-new.com\/404"
}'
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://linktw.in/api/domain/:id/update",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_MAXREDIRS => 2,
CURLOPT_TIMEOUT => 10,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_CUSTOMREQUEST => "PUT",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer YOURAPIKEY",
"Content-Type: application/json",
],
CURLOPT_POSTFIELDS => json_encode(array(
'redirectroot' => 'https://rootdomain-new.com',
'redirect404' => 'https://rootdomain-new.com/404',
)),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
var request = require('request');
var options = {
'method': 'PUT',
'url': 'https://linktw.in/api/domain/:id/update',
'headers': {
'Authorization': 'Bearer YOURAPIKEY',
'Content-Type': 'application/json'
},
body: JSON.stringify({
"redirectroot": "https:\/\/rootdomain-new.com",
"redirect404": "https:\/\/rootdomain-new.com\/404"
}),
};
request(options, function (error, response) {
if (error) throw new Error(error);
console.log(response.body);
});
{
"error": 0,
"message": "Domain has been updated successfully."
}
https://linktw.in/api/domain/:id/delete
To delete a domain, you need to send a DELETE request.
curl --location --request DELETE 'https://linktw.in/api/domain/:id/delete' \
--header 'Authorization: Bearer YOURAPIKEY' \
--header 'Content-Type: application/json' \
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://linktw.in/api/domain/:id/delete",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_MAXREDIRS => 2,
CURLOPT_TIMEOUT => 10,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_CUSTOMREQUEST => "DELETE",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer YOURAPIKEY",
"Content-Type: application/json",
],
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
var request = require('request');
var options = {
'method': 'DELETE',
'url': 'https://linktw.in/api/domain/:id/delete',
'headers': {
'Authorization': 'Bearer YOURAPIKEY',
'Content-Type': 'application/json'
},
};
request(options, function (error, response) {
if (error) throw new Error(error);
console.log(response.body);
});
{
"error": 0,
"message": "Domain has been deleted successfully."
}
https://linktw.in/api/pixels?limit=2&page=1
To get your pixels codes via the API, you can use this endpoint. You can also filter data (See table for more info).
| Parameter | Description |
|---|---|
| limit | (optional) Per page data result |
| page | (optional) Current page request |
curl --location --request GET 'https://linktw.in/api/pixels?limit=2&page=1' \
--header 'Authorization: Bearer YOURAPIKEY' \
--header 'Content-Type: application/json' \
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://linktw.in/api/pixels?limit=2&page=1",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_MAXREDIRS => 2,
CURLOPT_TIMEOUT => 10,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer YOURAPIKEY",
"Content-Type: application/json",
],
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
var request = require('request');
var options = {
'method': 'GET',
'url': 'https://linktw.in/api/pixels?limit=2&page=1',
'headers': {
'Authorization': 'Bearer YOURAPIKEY',
'Content-Type': 'application/json'
},
};
request(options, function (error, response) {
if (error) throw new Error(error);
console.log(response.body);
});
{
"error": "0",
"data": {
"result": 2,
"perpage": 2,
"currentpage": 1,
"nextpage": 1,
"maxpage": 1,
"pixels": [
{
"id": 1,
"type": "gtmpixel",
"name": "GTM Pixel",
"tag": "GA-123456789",
"date": "2023-11-10 18:00:00"
},
{
"id": 2,
"type": "twitterpixel",
"name": "Twitter Pixel",
"tag": "1234567",
"date": "2023-11-10 18:10:00"
}
]
}
}
https://linktw.in/api/pixel/add
A pixel can be created using this endpoint. You need to send the pixel type and the tag.
| Parameter | Description |
|---|---|
| type | (required) gtmpixel | gapixel | fbpixel | adwordspixel | linkedinpixel | twitterpixel | adrollpixel | quorapixel | pinterest | bing | snapchat | reddit | tiktok |
| name | (required) Custom name for your pixel |
| tag | (required) The tag for the pixel |
curl --location --request POST 'https://linktw.in/api/pixel/add' \
--header 'Authorization: Bearer YOURAPIKEY' \
--header 'Content-Type: application/json' \
--data-raw '{
"type": "gtmpixel",
"name": "My GTM",
"tag": "GTM-ABCDE"
}'
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://linktw.in/api/pixel/add",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_MAXREDIRS => 2,
CURLOPT_TIMEOUT => 10,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer YOURAPIKEY",
"Content-Type: application/json",
],
CURLOPT_POSTFIELDS => json_encode(array(
'type' => 'gtmpixel',
'name' => 'My GTM',
'tag' => 'GTM-ABCDE',
)),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
var request = require('request');
var options = {
'method': 'POST',
'url': 'https://linktw.in/api/pixel/add',
'headers': {
'Authorization': 'Bearer YOURAPIKEY',
'Content-Type': 'application/json'
},
body: JSON.stringify({
"type": "gtmpixel",
"name": "My GTM",
"tag": "GTM-ABCDE"
}),
};
request(options, function (error, response) {
if (error) throw new Error(error);
console.log(response.body);
});
{
"error": 0,
"id": 1
}
https://linktw.in/api/pixel/:id/update
To update a pixel, you need to send a valid data in JSON via a PUT request. The data must be sent as the raw body of your request as shown below. The example below shows all the parameters you can send but you are not required to send all (See table for more info).
| Parameter | Description |
|---|---|
| name | (optional) Custom name for your pixel |
| tag | (required) The tag for the pixel |
curl --location --request PUT 'https://linktw.in/api/pixel/:id/update' \
--header 'Authorization: Bearer YOURAPIKEY' \
--header 'Content-Type: application/json' \
--data-raw '{
"name": "My GTM",
"tag": "GTM-ABCDE"
}'
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://linktw.in/api/pixel/:id/update",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_MAXREDIRS => 2,
CURLOPT_TIMEOUT => 10,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_CUSTOMREQUEST => "PUT",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer YOURAPIKEY",
"Content-Type: application/json",
],
CURLOPT_POSTFIELDS => json_encode(array(
'name' => 'My GTM',
'tag' => 'GTM-ABCDE',
)),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
var request = require('request');
var options = {
'method': 'PUT',
'url': 'https://linktw.in/api/pixel/:id/update',
'headers': {
'Authorization': 'Bearer YOURAPIKEY',
'Content-Type': 'application/json'
},
body: JSON.stringify({
"name": "My GTM",
"tag": "GTM-ABCDE"
}),
};
request(options, function (error, response) {
if (error) throw new Error(error);
console.log(response.body);
});
{
"error": 0,
"message": "Pixel has been updated successfully."
}
https://linktw.in/api/pixel/:id/delete
To delete a pixel, you need to send a DELETE request.
curl --location --request DELETE 'https://linktw.in/api/pixel/:id/delete' \
--header 'Authorization: Bearer YOURAPIKEY' \
--header 'Content-Type: application/json' \
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://linktw.in/api/pixel/:id/delete",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_MAXREDIRS => 2,
CURLOPT_TIMEOUT => 10,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_CUSTOMREQUEST => "DELETE",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer YOURAPIKEY",
"Content-Type: application/json",
],
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
var request = require('request');
var options = {
'method': 'DELETE',
'url': 'https://linktw.in/api/pixel/:id/delete',
'headers': {
'Authorization': 'Bearer YOURAPIKEY',
'Content-Type': 'application/json'
},
};
request(options, function (error, response) {
if (error) throw new Error(error);
console.log(response.body);
});
{
"error": 0,
"message": "Pixel has been deleted successfully."
}
https://linktw.in/api/pixel/:id?limit=15&page=1
To get a single pixel with its assigned links via the API, you can use this endpoint. Returns the pixel details and a paginated list of links that have this pixel assigned.
| Parameter | Description |
|---|---|
| :id | (required) Pixel ID |
| limit | (optional) Per page data result |
| page | (optional) Current page request |
curl --location --request GET 'https://linktw.in/api/pixel/:id?limit=15&page=1' \
--header 'Authorization: Bearer YOURAPIKEY' \
--header 'Content-Type: application/json' \
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://linktw.in/api/pixel/:id?limit=15&page=1",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_MAXREDIRS => 2,
CURLOPT_TIMEOUT => 10,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer YOURAPIKEY",
"Content-Type: application/json",
],
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
var request = require('request');
var options = {
'method': 'GET',
'url': 'https://linktw.in/api/pixel/:id?limit=15&page=1',
'headers': {
'Authorization': 'Bearer YOURAPIKEY',
'Content-Type': 'application/json'
},
};
request(options, function (error, response) {
if (error) throw new Error(error);
console.log(response.body);
});
{
"error": 0,
"data": {
"result": 15,
"perpage": 15,
"currentpage": 1,
"nextpage": 2,
"maxpage": 3,
"pixel": {
"id": 1,
"type": "gtmpixel",
"name": "GTM Pixel",
"tag": "GTM-XXXXX",
"date": "2024-01-15 12:00:00"
},
"links": [
{
"id": 101,
"title": "Example Link",
"shorturl": "https:\/\/linktw.in\/abc123",
"longurl": "https:\/\/example.com",
"clicks": 150,
"date": "2024-01-10"
}
]
}
}
https://linktw.in/api/pixel/:id/links
Add or remove multiple links to/from a pixel in a single request. Send an array of link IDs to add and/or remove.
| Parameter | Description |
|---|---|
| :id | (required) Pixel ID |
| add | (optional) Array of link IDs to add this pixel to |
| remove | (optional) Array of link IDs to remove this pixel from |
curl --location --request POST 'https://linktw.in/api/pixel/:id/links' \
--header 'Authorization: Bearer YOURAPIKEY' \
--header 'Content-Type: application/json' \
--data-raw '{
"add": [
101,
102,
103
],
"remove": [
50,
51
]
}'
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://linktw.in/api/pixel/:id/links",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_MAXREDIRS => 2,
CURLOPT_TIMEOUT => 10,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer YOURAPIKEY",
"Content-Type: application/json",
],
CURLOPT_POSTFIELDS => json_encode(array(
'add' =>
array(
0 => 101,
1 => 102,
2 => 103,
),
'remove' =>
array(
0 => 50,
1 => 51,
),
)),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
var request = require('request');
var options = {
'method': 'POST',
'url': 'https://linktw.in/api/pixel/:id/links',
'headers': {
'Authorization': 'Bearer YOURAPIKEY',
'Content-Type': 'application/json'
},
body: JSON.stringify({
"add": [
101,
102,
103
],
"remove": [
50,
51
]
}),
};
request(options, function (error, response) {
if (error) throw new Error(error);
console.log(response.body);
});
{
"error": 0,
"pixel_id": 1,
"added": [
101,
102,
103
],
"removed": [
50,
51
],
"errors": []
}
https://linktw.in/api/qr?limit=2&page=1
To get your QR codes via the API, you can use this endpoint. You can also filter data (See table for more info).
| Parameter | Description |
|---|---|
| limit | (optional) Per page data result |
| page | (optional) Current page request |
curl --location --request GET 'https://linktw.in/api/qr?limit=2&page=1' \
--header 'Authorization: Bearer YOURAPIKEY' \
--header 'Content-Type: application/json' \
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://linktw.in/api/qr?limit=2&page=1",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_MAXREDIRS => 2,
CURLOPT_TIMEOUT => 10,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer YOURAPIKEY",
"Content-Type: application/json",
],
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
var request = require('request');
var options = {
'method': 'GET',
'url': 'https://linktw.in/api/qr?limit=2&page=1',
'headers': {
'Authorization': 'Bearer YOURAPIKEY',
'Content-Type': 'application/json'
},
};
request(options, function (error, response) {
if (error) throw new Error(error);
console.log(response.body);
});
{
"error": "0",
"data": {
"result": 2,
"perpage": 2,
"currentpage": 1,
"nextpage": 1,
"maxpage": 1,
"qrs": [
{
"id": 2,
"link": "https:\/\/linktw.in\/qr\/a2d5e",
"scans": 0,
"name": "Google",
"date": "2023-11-10 18:01:43"
},
{
"id": 1,
"link": "https:\/\/linktw.in\/qr\/b9edfe",
"scans": 5,
"name": "Google Canada",
"date": "2023-11-10 18:00:25"
}
]
}
}
https://linktw.in/api/qr/:id
To get details for a single QR code via the API, you can use this endpoint.
curl --location --request GET 'https://linktw.in/api/qr/:id' \
--header 'Authorization: Bearer YOURAPIKEY' \
--header 'Content-Type: application/json' \
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://linktw.in/api/qr/:id",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_MAXREDIRS => 2,
CURLOPT_TIMEOUT => 10,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer YOURAPIKEY",
"Content-Type: application/json",
],
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
var request = require('request');
var options = {
'method': 'GET',
'url': 'https://linktw.in/api/qr/:id',
'headers': {
'Authorization': 'Bearer YOURAPIKEY',
'Content-Type': 'application/json'
},
};
request(options, function (error, response) {
if (error) throw new Error(error);
console.log(response.body);
});
{
"error": 0,
"details": {
"id": 1,
"link": "https:\/\/linktw.in\/qr\/b9edfe",
"scans": 5,
"name": "Google Canada",
"date": "2023-11-10 18:00:25"
},
"data": {
"clicks": 1,
"uniqueClicks": 1,
"topCountries": {
"Unknown": "1"
},
"topReferrers": {
"Direct, email and other": "1"
},
"topBrowsers": {
"Chrome": "1"
},
"topOs": {
"Windows 10": "1"
},
"socialCount": {
"facebook": 0,
"twitter": 0,
"instagram": 0
}
}
}
https://linktw.in/api/qr/add
To create a QR Code, you need to send a valid data in JSON via a POST request. The data must be sent as the raw body of your request as shown below. The example below shows all the parameters you can send but you are not required to send all (See table for more info).
| Parameter | Description |
|---|---|
| type | (required) text | vcard | link | email | phone | sms | wifi |
| data | (required) Data to be embedded inside the QR code. The data can be string or array depending on the type |
| background | (optional) RGB color e.g. rgb(255,255,255) |
| foreground | (optional) RGB color e.g. rgb(0,0,0) |
| logo | (optional) Path to the logo either png or jpg |
curl --location --request POST 'https://linktw.in/api/qr/add' \
--header 'Authorization: Bearer YOURAPIKEY' \
--header 'Content-Type: application/json' \
--data-raw '{
"type": "link",
"data": "https:\/\/google.com",
"background": "rgb(255,255,255)",
"foreground": "rgb(0,0,0)",
"logo": "https:\/\/site.com\/logo.png"
}'
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://linktw.in/api/qr/add",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_MAXREDIRS => 2,
CURLOPT_TIMEOUT => 10,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer YOURAPIKEY",
"Content-Type: application/json",
],
CURLOPT_POSTFIELDS => json_encode(array(
'type' => 'link',
'data' => 'https://google.com',
'background' => 'rgb(255,255,255)',
'foreground' => 'rgb(0,0,0)',
'logo' => 'https://site.com/logo.png',
)),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
var request = require('request');
var options = {
'method': 'POST',
'url': 'https://linktw.in/api/qr/add',
'headers': {
'Authorization': 'Bearer YOURAPIKEY',
'Content-Type': 'application/json'
},
body: JSON.stringify({
"type": "link",
"data": "https:\/\/google.com",
"background": "rgb(255,255,255)",
"foreground": "rgb(0,0,0)",
"logo": "https:\/\/site.com\/logo.png"
}),
};
request(options, function (error, response) {
if (error) throw new Error(error);
console.log(response.body);
});
{
"error": 0,
"id": 3,
"link": "https:\/\/linktw.in\/qr\/a58f79"
}
https://linktw.in/api/qr/:id/update
To update a QR Code, you need to send a valid data in JSON via a PUT request. The data must be sent as the raw body of your request as shown below. The example below shows all the parameters you can send but you are not required to send all (See table for more info).
| Parameter | Description |
|---|---|
| data | (required) Data to be embedded inside the QR code. The data can be string or array depending on the type |
| background | (optional) RGB color e.g. rgb(255,255,255) |
| foreground | (optional) RGB color e.g. rgb(0,0,0) |
| logo | (optional) Path to the logo either png or jpg |
curl --location --request PUT 'https://linktw.in/api/qr/:id/update' \
--header 'Authorization: Bearer YOURAPIKEY' \
--header 'Content-Type: application/json' \
--data-raw '{
"type": "link",
"data": "https:\/\/google.com",
"background": "rgb(255,255,255)",
"foreground": "rgb(0,0,0)",
"logo": "https:\/\/site.com\/logo.png"
}'
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://linktw.in/api/qr/:id/update",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_MAXREDIRS => 2,
CURLOPT_TIMEOUT => 10,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_CUSTOMREQUEST => "PUT",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer YOURAPIKEY",
"Content-Type: application/json",
],
CURLOPT_POSTFIELDS => json_encode(array(
'type' => 'link',
'data' => 'https://google.com',
'background' => 'rgb(255,255,255)',
'foreground' => 'rgb(0,0,0)',
'logo' => 'https://site.com/logo.png',
)),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
var request = require('request');
var options = {
'method': 'PUT',
'url': 'https://linktw.in/api/qr/:id/update',
'headers': {
'Authorization': 'Bearer YOURAPIKEY',
'Content-Type': 'application/json'
},
body: JSON.stringify({
"type": "link",
"data": "https:\/\/google.com",
"background": "rgb(255,255,255)",
"foreground": "rgb(0,0,0)",
"logo": "https:\/\/site.com\/logo.png"
}),
};
request(options, function (error, response) {
if (error) throw new Error(error);
console.log(response.body);
});
{
"error": 0,
"message": "QR has been updated successfully."
}
https://linktw.in/api/qr/:id/delete
To delete a QR code, you need to send a DELETE request.
curl --location --request DELETE 'https://linktw.in/api/qr/:id/delete' \
--header 'Authorization: Bearer YOURAPIKEY' \
--header 'Content-Type: application/json' \
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://linktw.in/api/qr/:id/delete",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_MAXREDIRS => 2,
CURLOPT_TIMEOUT => 10,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_CUSTOMREQUEST => "DELETE",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer YOURAPIKEY",
"Content-Type: application/json",
],
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
var request = require('request');
var options = {
'method': 'DELETE',
'url': 'https://linktw.in/api/qr/:id/delete',
'headers': {
'Authorization': 'Bearer YOURAPIKEY',
'Content-Type': 'application/json'
},
};
request(options, function (error, response) {
if (error) throw new Error(error);
console.log(response.body);
});
{
"error": 0,
"message": "QR Code has been deleted successfully."
}
https://linktw.in/api/collections?limit=2&page=1
To get your collections via the API, you can use this endpoint. You can also filter data (See table for more info).
| Parameter | Description |
|---|---|
| limit | (optional) Per page data result |
| page | (optional) Current page request |
curl --location --request GET 'https://linktw.in/api/collections?limit=2&page=1' \
--header 'Authorization: Bearer YOURAPIKEY' \
--header 'Content-Type: application/json' \
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://linktw.in/api/collections?limit=2&page=1",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_MAXREDIRS => 2,
CURLOPT_TIMEOUT => 10,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer YOURAPIKEY",
"Content-Type: application/json",
],
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
var request = require('request');
var options = {
'method': 'GET',
'url': 'https://linktw.in/api/collections?limit=2&page=1',
'headers': {
'Authorization': 'Bearer YOURAPIKEY',
'Content-Type': 'application/json'
},
};
request(options, function (error, response) {
if (error) throw new Error(error);
console.log(response.body);
});
{
"error": "0",
"data": {
"result": 2,
"perpage": 2,
"currentpage": 1,
"nextpage": 1,
"maxpage": 1,
"collections": [
{
"id": 1,
"name": "Social Media",
"description": "All social media links",
"color": "#1E88E5",
"public": false,
"rotator": false,
"list": "https:\/\/domain.com\/u\/admin\/social-media-1",
"starred": true,
"views": 150,
"clicks": 5420
},
{
"id": 2,
"name": "Marketing Campaign",
"description": "Q4 Marketing Campaign",
"color": "#00897B",
"public": true,
"rotator": "https:\/\/domain.com\/r\/marketing-campaign",
"list": "https:\/\/domain.com\/u\/admin\/marketing-campaign-2",
"starred": false,
"views": 300,
"clicks": 12580
}
]
}
}
https://linktw.in/api/collection/:id?limit=1&page=1
To get items in a selected collection via the API, you can use this endpoint. You can also filter data (See table for more info).
| Parameter | Description |
|---|---|
| limit | (optional) Per page data result |
| page | (optional) Current page request |
curl --location --request GET 'https://linktw.in/api/collection/:id?limit=1&page=1' \
--header 'Authorization: Bearer YOURAPIKEY' \
--header 'Content-Type: application/json' \
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://linktw.in/api/collection/:id?limit=1&page=1",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_MAXREDIRS => 2,
CURLOPT_TIMEOUT => 10,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer YOURAPIKEY",
"Content-Type: application/json",
],
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
var request = require('request');
var options = {
'method': 'GET',
'url': 'https://linktw.in/api/collection/:id?limit=1&page=1',
'headers': {
'Authorization': 'Bearer YOURAPIKEY',
'Content-Type': 'application/json'
},
};
request(options, function (error, response) {
if (error) throw new Error(error);
console.log(response.body);
});
{
"error": "0",
"data": {
"result": 2,
"perpage": 2,
"currentpage": 1,
"nextpage": 1,
"maxpage": 1,
"items": [
{
"type": "links",
"id": 1,
"title": "My Sample Link",
"preview": "https:\/\/google.com",
"link": "https:\/\/linktw.in\/google",
"date": "2024-05-12"
},
{
"type": "bio",
"id": 1,
"title": "My Sample Bio",
"preview": "https:\/\/linktw.in\/mybio",
"link": "https:\/\/linktw.in\/mybio",
"date": "2024-06-01"
},
{
"type": "qr",
"id": 1,
"title": "My QR Code",
"preview": "https:\/\/example.com",
"link": "https:\/\/linktw.in\/qr\/1",
"date": "2024-06-15"
}
]
}
}
https://linktw.in/api/collection/add
A collection can be added using this endpoint.
| Parameter | Description |
|---|---|
| name | (required) Collection name |
| slug | (optional) Rotator Slug |
| description | (optional) Collection description |
| color | (optional) Collection badge color (HEX) |
| public | (optional) Access (true or false) |
| starred | (optional) Star the collection or not (true or false) |
curl --location --request POST 'https://linktw.in/api/collection/add' \
--header 'Authorization: Bearer YOURAPIKEY' \
--header 'Content-Type: application/json' \
--data-raw '{
"name": "NewCollection",
"slug": "new-collection",
"description": "My new collection",
"color": "#1E88E5",
"public": true,
"starred": true
}'
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://linktw.in/api/collection/add",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_MAXREDIRS => 2,
CURLOPT_TIMEOUT => 10,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer YOURAPIKEY",
"Content-Type: application/json",
],
CURLOPT_POSTFIELDS => json_encode(array(
'name' => 'NewCollection',
'slug' => 'new-collection',
'description' => 'My new collection',
'color' => '#1E88E5',
'public' => true,
'starred' => true,
)),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
var request = require('request');
var options = {
'method': 'POST',
'url': 'https://linktw.in/api/collection/add',
'headers': {
'Authorization': 'Bearer YOURAPIKEY',
'Content-Type': 'application/json'
},
body: JSON.stringify({
"name": "NewCollection",
"slug": "new-collection",
"description": "My new collection",
"color": "#1E88E5",
"public": true,
"starred": true
}),
};
request(options, function (error, response) {
if (error) throw new Error(error);
console.log(response.body);
});
{
"error": 0,
"id": 3,
"name": "New Collection",
"public": true,
"rotator": "https:\/\/domain.com\/r\/new-collection",
"list": "https:\/\/domain.com\/u\/admin\/new-collection-3"
}
https://linktw.in/api/collection/:collectionid/assign/:itemid
A link can be assigned to any collection by sending a request with the collection id and link id.
| Parameter | Description |
|---|---|
| :collectionid | (required) Collection ID |
| :itemid | (required) Link ID |
curl --location --request POST 'https://linktw.in/api/collection/:collectionid/assign/:itemid' \
--header 'Authorization: Bearer YOURAPIKEY' \
--header 'Content-Type: application/json' \
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://linktw.in/api/collection/:collectionid/assign/:itemid",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_MAXREDIRS => 2,
CURLOPT_TIMEOUT => 10,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer YOURAPIKEY",
"Content-Type: application/json",
],
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
var request = require('request');
var options = {
'method': 'POST',
'url': 'https://linktw.in/api/collection/:collectionid/assign/:itemid',
'headers': {
'Authorization': 'Bearer YOURAPIKEY',
'Content-Type': 'application/json'
},
};
request(options, function (error, response) {
if (error) throw new Error(error);
console.log(response.body);
});
{
"error": 0,
"message": "Link successfully added to the collection."
}
https://linktw.in/api/collection/:id/links
Add or remove multiple links to/from a collection in a single request. Send an array of link IDs to add and/or remove.
| Parameter | Description |
|---|---|
| :id | (required) Collection ID |
| add | (optional) Array of link IDs to add to the collection |
| remove | (optional) Array of link IDs to remove from the collection |
curl --location --request POST 'https://linktw.in/api/collection/:id/links' \
--header 'Authorization: Bearer YOURAPIKEY' \
--header 'Content-Type: application/json' \
--data-raw '{
"add": [
101,
102,
103
],
"remove": [
50,
51
]
}'
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://linktw.in/api/collection/:id/links",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_MAXREDIRS => 2,
CURLOPT_TIMEOUT => 10,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer YOURAPIKEY",
"Content-Type: application/json",
],
CURLOPT_POSTFIELDS => json_encode(array(
'add' =>
array(
0 => 101,
1 => 102,
2 => 103,
),
'remove' =>
array(
0 => 50,
1 => 51,
),
)),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
var request = require('request');
var options = {
'method': 'POST',
'url': 'https://linktw.in/api/collection/:id/links',
'headers': {
'Authorization': 'Bearer YOURAPIKEY',
'Content-Type': 'application/json'
},
body: JSON.stringify({
"add": [
101,
102,
103
],
"remove": [
50,
51
]
}),
};
request(options, function (error, response) {
if (error) throw new Error(error);
console.log(response.body);
});
{
"error": 0,
"collection_id": 5,
"added": [
101,
102,
103
],
"removed": [
50,
51
],
"errors": []
}
https://linktw.in/api/collection/:id/update
To update a collection, you need to send a valid data in JSON via a PUT request. The data must be sent as the raw body of your request as shown below. The example below shows all the parameters you can send but you are not required to send all (See table for more info).
| Parameter | Description |
|---|---|
| name | (optional) Collection name |
| slug | (optional) Rotator Slug |
| description | (optional) Collection description |
| color | (optional) Collection badge color (HEX) |
| public | (optional) Access (true or false) |
| starred | (optional) Star the collection or not (true or false) |
curl --location --request PUT 'https://linktw.in/api/collection/:id/update' \
--header 'Authorization: Bearer YOURAPIKEY' \
--header 'Content-Type: application/json' \
--data-raw '{
"name": "Updated Collection",
"description": "Updated collection description",
"color": "#FF5722",
"public": false,
"starred": true
}'
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://linktw.in/api/collection/:id/update",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_MAXREDIRS => 2,
CURLOPT_TIMEOUT => 10,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_CUSTOMREQUEST => "PUT",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer YOURAPIKEY",
"Content-Type: application/json",
],
CURLOPT_POSTFIELDS => json_encode(array(
'name' => 'Updated Collection',
'description' => 'Updated collection description',
'color' => '#FF5722',
'public' => false,
'starred' => true,
)),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
var request = require('request');
var options = {
'method': 'PUT',
'url': 'https://linktw.in/api/collection/:id/update',
'headers': {
'Authorization': 'Bearer YOURAPIKEY',
'Content-Type': 'application/json'
},
body: JSON.stringify({
"name": "Updated Collection",
"description": "Updated collection description",
"color": "#FF5722",
"public": false,
"starred": true
}),
};
request(options, function (error, response) {
if (error) throw new Error(error);
console.log(response.body);
});
{
"error": 0,
"message": "Collection has been updated successfully."
}
https://linktw.in/api/collection/:id/delete
To delete a collection, you need to send a DELETE request. All items will be unassigned as well.
curl --location --request DELETE 'https://linktw.in/api/collection/:id/delete' \
--header 'Authorization: Bearer YOURAPIKEY' \
--header 'Content-Type: application/json' \
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://linktw.in/api/collection/:id/delete",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_MAXREDIRS => 2,
CURLOPT_TIMEOUT => 10,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_CUSTOMREQUEST => "DELETE",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer YOURAPIKEY",
"Content-Type: application/json",
],
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
var request = require('request');
var options = {
'method': 'DELETE',
'url': 'https://linktw.in/api/collection/:id/delete',
'headers': {
'Authorization': 'Bearer YOURAPIKEY',
'Content-Type': 'application/json'
},
};
request(options, function (error, response) {
if (error) throw new Error(error);
console.log(response.body);
});
{
"error": 0,
"message": "Collection has been deleted successfully."
}