Developers

API documentation and code examples for integrating reLinkIt.io into your applications.

Basic URL Shortening

Shorten a URL with default settings (12 months expiration, unlimited clicks, no challenge).

cURL Example:

curl -X POST https://relinkit.io/api.php \
  -H "Content-Type: application/json" \
  -H "X-API-Key: YOUR_API_KEY_HERE" \
  -d '{"url": "https://example.com/very/long/url"}'

JavaScript Example:

fetch('https://relinkit.io/api.php', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
    'X-API-Key': 'YOUR_API_KEY_HERE'
  },
  body: JSON.stringify({
    url: 'https://example.com/very/long/url'
  })
})
.then(response => response.json())
.then(data => console.log(data));

PHP Example:

$ch = curl_init('https://relinkit.io/api.php');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
    'Content-Type: application/json',
    'X-API-Key: YOUR_API_KEY_HERE'
]);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode([
    'url' => 'https://example.com/very/long/url'
]));

$response = curl_exec($ch);
$data = json_decode($response, true);
curl_close($ch);

echo $data['short_url'];

C# Example:

using System;
using System.Net.Http;
using System.Text;
using System.Text.Json;

var client = new HttpClient();
client.DefaultRequestHeaders.Add("X-API-Key", "YOUR_API_KEY_HERE");

var payload = new {
    url = "https://example.com/very/long/url"
};

var json = JsonSerializer.Serialize(payload);
var content = new StringContent(json, Encoding.UTF8, "application/json");

var response = await client.PostAsync(
    "https://relinkit.io/api.php", 
    content
);

var result = await response.Content.ReadAsStringAsync();
var data = JsonSerializer.Deserialize<JsonElement>(result);
Console.WriteLine(data.GetProperty("short_url").GetString());

Python Example:

import requests
import json

url = "https://relinkit.io/api.php"
headers = {
    "Content-Type": "application/json",
    "X-API-Key": "YOUR_API_KEY_HERE"
}
payload = {
    "url": "https://example.com/very/long/url"
}

response = requests.post(url, headers=headers, json=payload)
data = response.json()
print(data["short_url"])

Using Policies

Policies allow you to apply consistent rules (expiration, click limits, challenge requirements) to multiple URLs. Create policies in the "Policies" section, then reference them by name in your API calls.

cURL Example with Policy:

curl -X POST https://relinkit.io/api.php \
  -H "Content-Type: application/json" \
  -H "X-API-Key: YOUR_API_KEY_HERE" \
  -d '{"url": "https://example.com/very/long/url", "policy": "invoice_policy"}'

JavaScript Example with Policy:

fetch('https://relinkit.io/api.php', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
    'X-API-Key': 'YOUR_API_KEY_HERE'
  },
  body: JSON.stringify({
    url: 'https://example.com/very/long/url',
    policy: 'invoice_policy'
  })
})
.then(response => response.json())
.then(data => console.log(data));

PHP Example with Policy:

$ch = curl_init('https://relinkit.io/api.php');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
    'Content-Type: application/json',
    'X-API-Key: YOUR_API_KEY_HERE'
]);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode([
    'url' => 'https://example.com/very/long/url',
    'policy' => 'invoice_policy'
]));

$response = curl_exec($ch);
$data = json_decode($response, true);
curl_close($ch);

echo $data['short_url'];

C# Example with Policy:

using System;
using System.Net.Http;
using System.Text;
using System.Text.Json;

var client = new HttpClient();
client.DefaultRequestHeaders.Add("X-API-Key", "YOUR_API_KEY_HERE");

var payload = new {
    url = "https://example.com/very/long/url",
    policy = "invoice_policy"
};

var json = JsonSerializer.Serialize(payload);
var content = new StringContent(json, Encoding.UTF8, "application/json");

var response = await client.PostAsync(
    "https://relinkit.io/api.php", 
    content
);

var result = await response.Content.ReadAsStringAsync();
var data = JsonSerializer.Deserialize<JsonElement>(result);
Console.WriteLine(data.GetProperty("short_url").GetString());

Python Example with Policy:

import requests
import json

url = "https://relinkit.io/api.php"
headers = {
    "Content-Type": "application/json",
    "X-API-Key": "YOUR_API_KEY_HERE"
}
payload = {
    "url": "https://example.com/very/long/url",
    "policy": "invoice_policy"
}

response = requests.post(url, headers=headers, json=payload)
data = response.json()
print(data["short_url"])

Policy Rules

When creating a policy, you can define the following rules in JSON format:

  • allowedClicks: Maximum number of clicks allowed (-1 for unlimited)
  • expire_after_days: Number of days until expiration (e.g., 30)
  • expirationDateTime: Specific expiration date/time (format: "YYYY-MM-DD HH:MM:SS")
  • challengeRequired: Require reCAPTCHA before redirect (true/false)

Note: Use either expire_after_days OR expirationDateTime, not both.

Example Policy JSON:

{
  "allowedClicks": 100,
  "expire_after_days": 30,
  "challengeRequired": true
}

API Response

Successful API calls return a JSON object with the following fields:

{
  "success": true,
  "short_url": "https://relinkit.io/abc123",
  "long_url": "https://example.com/very/long/url",
  "expiration_date": "2025-12-31 23:59:59",
  "allowed_clicks": 100,
  "status": "ACTIVE",
  "challenge_required": true,
  "policy_name": "invoice_policy"
}