Short URL
Short URL
Create a short URL from a long URL. Your shortened links will be tracked and managed in your dashboard.
API Keys
Generate API keys to use the URL shortener API in your applications.
Save this API key now. You won't be able to see it again!
Loading API keys...
API Usage
Basic URL Shortening
Shorten a URL with default settings (12 months expiration, unlimited clicks, no challenge).
cURL Example:
curl -X POST https://lnkshrt.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://lnkshrt.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://lnkshrt.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://lnkshrt.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://lnkshrt.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://lnkshrt.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://lnkshrt.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://lnkshrt.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://lnkshrt.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://lnkshrt.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://lnkshrt.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"
}
Analytics
View detailed analytics and insights about your URLs