Referência da API para Desenvolvedores

Primeiros Passos

Uma chave de API é necessária para que as requisições sejam processadas pelo sistema. Quando um usuário se registra, uma chave de API é gerada automaticamente. A chave de API deve ser enviada com cada requisição (veja o exemplo completo abaixo). Se a chave de API não for enviada ou estiver expirada, haverá um erro. Certifique-se de manter sua chave de API em segredo para evitar abusos.

Autenticação

Para se autenticar no sistema de API, você precisa enviar sua chave de API como token de autorização em cada requisição. Veja o código de exemplo abaixo.

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);
});
Limite de Requisições

Nossa API tem um limitador de taxa para proteger contra picos de requisições e maximizar sua estabilidade. Nosso limitador de taxa está atualmente limitado a 120 requisições por 1 minuto.

Vários headers serão enviados junto com a resposta e podem ser examinados para determinar diversas informações sobre a requisição.

X-RateLimit-Limit: 120
X-RateLimit-Remaining: 119
X-RateLimit-Reset: TIMESTAMP
Tratamento de Resposta

Todas as respostas da API são retornadas em formato JSON por padrão. Para converter em dados utilizáveis, a função apropriada precisa ser usada de acordo com a linguagem. No PHP, a função json_decode() pode ser usada para converter os dados em um objeto (padrão) ou um array (defina o segundo parâmetro como true). É muito importante verificar a chave de erro, pois ela informa se houve um erro ou não. Você também pode verificar o código do cabeçalho.

{
    "error": 1,
    "message": "An error occurred"
}
Data e Hora

Todos os campos de data e hora nas respostas da API são retornados no fuso horário configurado na sua conta. Você pode definir seu fuso horário nas configurações da conta. Se nenhum fuso horário estiver configurado, as datas usam UTC como padrão.

Você também pode substituir o fuso horário da sua conta por solicitação adicionando um ?timezone= parâmetro de consulta para a maioria dos endpoints (ex., ?timezone=America/New_York).

Os campos de data são formatados como YYYY-MM-DD HH:MM:SS (ex. 2024-01-15 14:30:00).

O endpoint Account retorna timezone_offset que é o deslocamento UTC atual em minutos para o seu fuso horário configurado. Isso leva em conta o horário de verão e pode ser usado para converter datas para outros fusos horários. Por exemplo, -300 significa UTC-5 (Horário Padrão do Leste), 60 significa UTC+1 (Horário da Europa Central).

{
    "settings": {
        "timezone": "America/New_York",
        "timezone_offset": -300
    },
    "date": "2024-01-15 14:30:00"
}

Tabelas de Referência

Lista de Países para Geo Segmentação

O location campo no geotarget o array deve usar o nome completo exato do país conforme mostrado abaixo. Os nomes dos países diferenciam maiúsculas de minúsculas. Clique em qualquer país para ver os estados/regiões disponíveis para o campo opcional state campo.

CódigoNome do País (use isto em location)
AD Andorra
AF Afghanistan
AG Antigua and Barbuda
AI Anguilla
AL Albania
AM Armenia
AN Netherlands Antilles
AO Angola
AQ Antarctica
AR Argentina
AS American Samoa
AT Austria
AU Australia
AW Aruba
AX Åland
AZ Azerbaijan
BA Bosnia and Herzegovina
BB Barbados
BD Bangladesh
BE Belgium
BF Burkina Faso
BG Bulgaria
BH Bahrain
BI Burundi
BJ Benin
BL Saint Barthélemy
BM Bermuda
BN Brunei
BO Bolivia
BQ Bonaire, Sint Eustatius and Saba
BR Brazil
BS Bahamas
BT Bhutan
BV Bouvet Island
BW Botswana
BY Belarus
BZ Belize
CA Canada
CC Cocos [Keeling] Islands
CD DR Congo
CF Central African Republic
CG Congo Republic
CH Switzerland
CI Ivory Coast
CK Cook Islands
CL Chile
CM Cameroon
CN China
CO Colombia
CR Costa Rica
CS Serbia and Montenegro
CU Cuba
CV Cabo Verde
CW Curaçao
CX Christmas Island
CY Cyprus
CZ Czechia
DE Germany
DJ Djibouti
DK Denmark
DM Dominica
DO Dominican Republic
DZ Algeria
EC Ecuador
EE Estonia
EG Egypt
EH Western Sahara
ER Eritrea
ES Spain
ET Ethiopia
FI Finland
FJ Fiji
FK Falkland Islands
FM Micronesia
FO Faroe Islands
FR France
GA Gabon
GB United Kingdom
GD Grenada
GE Georgia
GF French Guiana
GG Guernsey
GH Ghana
GI Gibraltar
GL Greenland
GM Gambia
GN Guinea
GP Guadeloupe
GQ Equatorial Guinea
GR Greece
GS South Georgia and South Sandwich Islands
GT Guatemala
GU Guam
GW Guinea-Bissau
GY Guyana
HK Hong Kong
HM Heard Island and McDonald Islands
HN Honduras
HR Croatia
HT Haiti
HU Hungary
ID Indonesia
IE Ireland
IL Israel
IM Isle of Man
IN India
IO British Indian Ocean Territory
IQ Iraq
IR Iran
IS Iceland
IT Italy
JE Jersey
JM Jamaica
JO Jordan
JP Japan
KE Kenya
KG Kyrgyzstan
KH Cambodia
KI Kiribati
KM Comoros
KN St Kitts and Nevis
KP North Korea
KR South Korea
KW Kuwait
KY Cayman Islands
KZ Kazakhstan
LA Laos
LB Lebanon
LC Saint Lucia
LI Liechtenstein
LK Sri Lanka
LR Liberia
LS Lesotho
LT Lithuania
LU Luxembourg
LV Latvia
LY Libya
MA Morocco
MC Monaco
MD Moldova
ME Montenegro
MF Saint Martin
MG Madagascar
MH Marshall Islands
MK North Macedonia
ML Mali
MM Myanmar
MN Mongolia
MO Macao
MP Northern Mariana Islands
MQ Martinique
MR Mauritania
MS Montserrat
MT Malta
MU Mauritius
MV Maldives
MW Malawi
MX Mexico
MY Malaysia
MZ Mozambique
NA Namibia
NC New Caledonia
NE Niger
NF Norfolk Island
NG Nigeria
NI Nicaragua
NL Netherlands
NO Norway
NP Nepal
NR Nauru
NU Niue
NZ New Zealand
OM Oman
PA Panama
PE Peru
PF French Polynesia
PG Papua New Guinea
PH Philippines
PK Pakistan
PL Poland
PM Saint Pierre and Miquelon
PN Pitcairn Islands
PR Puerto Rico
PS Palestine
PT Portugal
PW Palau
PY Paraguay
QA Qatar
RE Réunion
RO Romania
RS Serbia
RU Russia
RW Rwanda
SA Saudi Arabia
SB Solomon Islands
SC Seychelles
SD Sudan
SE Sweden
SG Singapore
SH Saint Helena
SI Slovenia
SJ Svalbard and Jan Mayen
SK Slovakia
SL Sierra Leone
SM San Marino
SN Senegal
SO Somalia
SR Suriname
SS South Sudan
ST São Tomé and Príncipe
SV El Salvador
SX Sint Maarten
SY Syria
SZ Eswatini
TC Turks and Caicos Islands
TD Chad
TF French Southern Territories
TG Togo
TH Thailand
TJ Tajikistan
TK Tokelau
TL Timor-Leste
TM Turkmenistan
TN Tunisia
TO Tonga
TR Turkey
TT Trinidad and Tobago
TV Tuvalu
TW Taiwan
TZ Tanzania
AE United Arab Emirates
UA Ukraine
UG Uganda
UM U.S. Minor Outlying Islands
US United States
UY Uruguay
UZ Uzbekistan
VA Vatican City
VC St Vincent and Grenadines
VE Venezuela
VG British Virgin Islands
VI U.S. Virgin Islands
VN Vietnam
VU Vanuatu
WF Wallis and Futuna
WS Samoa
XK Kosovo
YE Yemen
YT Mayotte
ZA South Africa
ZM Zambia
ZW Zimbabwe
Exemplo de uso:
"geotarget": [
  {"location": "Canada", "link": "https://example.ca"},
  {"location": "United States", "link": "https://example.us", "state": "California"},
  {"location": "United Kingdom", "link": "https://example.co.uk"}
]

1. Links


2. Domínios

Listar Todos os Domínios
GET https://linktw.in/api/domains?limit=2&page=1

Obtenha todos os domínios disponíveis para encurtamento de links. Isso inclui domínios padrão (fornecidos pela plataforma) e seus domínios de marca (personalizados). Use o campo isStandard para distingui-los.

ParâmetroDescrição
limit (opcional) Quantidade de resultados por página para domínios de marca
page (opcional) Página atual solicitada para domínios de marca
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);
});
Resposta do servidor
{
    "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
            }
        ]
    }
}
Criar um Domínio de Marca
POST https://linktw.in/api/domain/add

Um domínio pode ser adicionado usando este endpoint. Certifique-se de que o domínio está corretamente apontado para o nosso servidor.

ParâmetroDescrição
domain (obrigatório) Domínio de marca incluindo http ou https
redirectroot (opcional) Redirecionamento raiz quando alguém visita seu domínio
redirect404 (opcional) Redirecionamento 404 personalizado
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);
});
Resposta do servidor
{
    "error": 0,
    "id": 1
}
Atualizar Domínio
PUT https://linktw.in/api/domain/:id/update

Para atualizar um domínio de marca, você precisa enviar dados válidos em JSON via uma requisição PUT. Os dados devem ser enviados como corpo bruto da sua requisição conforme mostrado abaixo. O exemplo abaixo mostra todos os parâmetros que você pode enviar, mas não é obrigatório enviar todos (veja a tabela para mais informações).

ParâmetroDescrição
redirectroot (opcional) Redirecionamento raiz quando alguém visita seu domínio
redirect404 (opcional) Redirecionamento 404 personalizado
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);
});
Resposta do servidor
{
    "error": 0,
    "message": "Domain has been updated successfully."
}
Excluir Domínio
DELETE https://linktw.in/api/domain/:id/delete

Para excluir um domínio, você precisa enviar uma requisição DELETE.

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);
});
Resposta do servidor
{
    "error": 0,
    "message": "Domain has been deleted successfully."
}

3. Pixels

Listar Pixels
GET https://linktw.in/api/pixels?limit=2&page=1

Para obter seus códigos de pixel via API, você pode usar este endpoint. Você também pode filtrar os dados (veja a tabela para mais informações).

ParâmetroDescrição
limit (opcional) Quantidade de resultados por página
page (opcional) Página atual solicitada
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);
});
Resposta do servidor
{
    "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"
            }
        ]
    }
}
Criar um Pixel
POST https://linktw.in/api/pixel/add

Um pixel pode ser criado usando este endpoint. Você precisa enviar o tipo de pixel e a tag.

ParâmetroDescrição
type (required) gtmpixel | gapixel | fbpixel | adwordspixel | linkedinpixel | twitterpixel | adrollpixel | quorapixel | pinterest | bing | snapchat | reddit | tiktok
name (obrigatório) Nome personalizado para seu pixel
tag (obrigatório) A tag do 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);
});
Resposta do servidor
{
    "error": 0,
    "id": 1
}
Atualizar Pixel
PUT https://linktw.in/api/pixel/:id/update

Para atualizar um pixel, você precisa enviar dados válidos em JSON via uma requisição PUT. Os dados devem ser enviados como corpo bruto da sua requisição conforme mostrado abaixo. O exemplo abaixo mostra todos os parâmetros que você pode enviar, mas não é obrigatório enviar todos (veja a tabela para mais informações).

ParâmetroDescrição
name (opcional) Nome personalizado para seu pixel
tag (obrigatório) A tag do 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);
});
Resposta do servidor
{
    "error": 0,
    "message": "Pixel has been updated successfully."
}
Excluir Pixel
DELETE https://linktw.in/api/pixel/:id/delete

Para excluir um pixel, você precisa enviar uma requisição DELETE.

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);
});
Resposta do servidor
{
    "error": 0,
    "message": "Pixel has been deleted successfully."
}
Obter Pixel Específico
GET https://linktw.in/api/pixel/:id?limit=15&page=1

Para obter um pixel específico com seus links associados via API, você pode usar este endpoint. Retorna os detalhes do pixel e uma lista paginada de links que têm este pixel associado.

ParâmetroDescrição
:id (obrigatório) ID do pixel
limit (opcional) Quantidade de resultados por página
page (opcional) Página atual solicitada
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);
});
Resposta do servidor
{
    "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"
            }
        ]
    }
}
POST https://linktw.in/api/pixel/:id/links

Adicione ou remova múltiplos links de um pixel em uma única requisição. Envie um array de IDs de links para adicionar e/ou remover.

ParâmetroDescrição
:id (obrigatório) ID do pixel
add (opcional) Array de IDs de links para adicionar este pixel
remove (opcional) Array de IDs de links para remover este pixel
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);
});
Resposta do servidor
{
    "error": 0,
    "pixel_id": 1,
    "added": [
        101,
        102,
        103
    ],
    "removed": [
        50,
        51
    ],
    "errors": []
}

4. Códigos QR

Listar Códigos QR
GET https://linktw.in/api/qr?limit=2&page=1

Para obter seus códigos QR via API, você pode usar este endpoint. Você também pode filtrar os dados (veja a tabela para mais informações).

ParâmetroDescrição
limit (opcional) Quantidade de resultados por página
page (opcional) Página atual solicitada
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);
});
Resposta do servidor
{
    "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"
            }
        ]
    }
}
Obter um Código QR Específico
GET https://linktw.in/api/qr/:id

Para obter detalhes de um código QR específico via API, você pode usar este 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);
});
Resposta do servidor
{
    "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
        }
    }
}
Criar um Código QR
POST https://linktw.in/api/qr/add

Para criar um código QR, você precisa enviar dados válidos em JSON via uma requisição POST. Os dados devem ser enviados como corpo bruto da sua requisição conforme mostrado abaixo. O exemplo abaixo mostra todos os parâmetros que você pode enviar, mas não é obrigatório enviar todos (veja a tabela para mais informações).

ParâmetroDescrição
type (obrigatório) text | vcard | link | email | phone | sms | wifi
data (obrigatório) Dados a serem incorporados dentro do código QR. Os dados podem ser uma string ou array dependendo do tipo
background (opcional) Cor RGB, ex.: rgb(255,255,255)
foreground (opcional) Cor RGB, ex.: rgb(0,0,0)
logo (opcional) Caminho para o logo em formato png ou 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);
});
Resposta do servidor
{
    "error": 0,
    "id": 3,
    "link": "https:\/\/linktw.in\/qr\/a58f79"
}
Atualizar QR Code
PUT https://linktw.in/api/qr/:id/update

Para atualizar um código QR, você precisa enviar dados válidos em JSON via uma requisição PUT. Os dados devem ser enviados como corpo bruto da sua requisição conforme mostrado abaixo. O exemplo abaixo mostra todos os parâmetros que você pode enviar, mas não é obrigatório enviar todos (veja a tabela para mais informações).

ParâmetroDescrição
data (obrigatório) Dados a serem incorporados dentro do código QR. Os dados podem ser uma string ou array dependendo do tipo
background (opcional) Cor RGB, ex.: rgb(255,255,255)
foreground (opcional) Cor RGB, ex.: rgb(0,0,0)
logo (opcional) Caminho para o logo em formato png ou 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);
});
Resposta do servidor
{
    "error": 0,
    "message": "QR has been updated successfully."
}
Excluir um Código QR
DELETE https://linktw.in/api/qr/:id/delete

Para excluir um código QR, você precisa enviar uma requisição DELETE.

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);
});
Resposta do servidor
{
    "error": 0,
    "message": "QR Code has been deleted successfully."
}

5. Coleções

Listar Coleções
GET https://linktw.in/api/collections?limit=2&page=1

Para obter suas coleções via API, você pode usar este endpoint. Você também pode filtrar os dados (veja a tabela para mais informações).

ParâmetroDescrição
limit (opcional) Quantidade de resultados por página
page (opcional) Página atual solicitada
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);
});
Resposta do servidor
{
    "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
            }
        ]
    }
}
Obter Coleção Específica
GET https://linktw.in/api/collection/:id?limit=1&page=1

Para obter os itens de uma coleção selecionada via API, você pode usar este endpoint. Você também pode filtrar os dados (veja a tabela para mais informações).

ParâmetroDescrição
limit (opcional) Quantidade de resultados por página
page (opcional) Página atual solicitada
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);
});
Resposta do servidor
{
    "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"
            }
        ]
    }
}
Criar uma Coleção
POST https://linktw.in/api/collection/add

Uma coleção pode ser adicionada usando este endpoint.

ParâmetroDescrição
name (obrigatório) Nome da coleção
slug (opcional) Slug do rotador
description (opcional) Descrição da coleção
color (opcional) Cor do badge da coleção (HEX)
public (opcional) Acesso (true ou false)
starred (opcional) Marcar a coleção como favorita ou não (true ou 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);
});
Resposta do servidor
{
    "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"
}
POST https://linktw.in/api/collection/:collectionid/assign/:itemid

Um link pode ser atribuído a qualquer coleção enviando uma requisição com o ID da coleção e o ID do link.

ParâmetroDescrição
:collectionid (obrigatório) ID da coleção
:itemid (obrigatório) ID do link
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);
});
Resposta do servidor
{
    "error": 0,
    "message": "Link successfully added to the collection."
}
POST https://linktw.in/api/collection/:id/links

Adicione ou remova múltiplos links de uma coleção em uma única requisição. Envie um array de IDs de links para adicionar e/ou remover.

ParâmetroDescrição
:id (obrigatório) ID da coleção
add (opcional) Array de IDs de links para adicionar à coleção
remove (opcional) Array de IDs de links para remover da coleção
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);
});
Resposta do servidor
{
    "error": 0,
    "collection_id": 5,
    "added": [
        101,
        102,
        103
    ],
    "removed": [
        50,
        51
    ],
    "errors": []
}
Atualizar Coleção
PUT https://linktw.in/api/collection/:id/update

Para atualizar uma coleção, você precisa enviar dados válidos em JSON via uma requisição PUT. Os dados devem ser enviados como corpo bruto da sua requisição conforme mostrado abaixo. O exemplo abaixo mostra todos os parâmetros que você pode enviar, mas não é obrigatório enviar todos (veja a tabela para mais informações).

ParâmetroDescrição
name (opcional) Nome da coleção
slug (opcional) Slug do rotador
description (opcional) Descrição da coleção
color (opcional) Cor do badge da coleção (HEX)
public (opcional) Acesso (true ou false)
starred (opcional) Marcar a coleção como favorita ou não (true ou 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);
});
Resposta do servidor
{
    "error": 0,
    "message": "Collection has been updated successfully."
}
Excluir Coleção
DELETE https://linktw.in/api/collection/:id/delete

Para excluir uma coleção, você precisa enviar uma requisição DELETE. Todos os itens também serão desvinculados.

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);
});
Resposta do servidor
{
    "error": 0,
    "message": "Collection has been deleted successfully."
}