Integrate SahiURL into your applications, Telegram bots, and websites.
Your API token can be found in Dashboard → Tools.
Send a GET request with your API token and URL like this:
https://sahiurl.in/api?api=YOUR_API_KEY&url=https://example.comYou will get a JSON response like:
{"status":"success","shortenedUrl":"https://sahi.to/abc123"}For TEXT response (just the short URL), add &format=text:
https://sahiurl.in/api?api=YOUR_API_KEY&url=https://example.com&format=textThis returns just: https://sahi.to/abc123
https://sahiurl.in/api| Parameter | Required | Description |
|---|---|---|
| api | Required | Your API token |
| url | Required | The destination URL to shorten |
| alias | Optional | Custom short code (2-30 chars, alphanumeric) |
| format | Optional | json (default) or text |
https://sahiurl.in/apiHeaders:
x-api-key: YOUR_API_KEY
Content-Type: application/jsonBody:
{
"url": "https://example.com",
"alias": "custom-name"
}Using JSON Response:
<?php
$long_url = urlencode('https://example.com');
$api_token = 'YOUR_API_KEY';
$api_url = "https://sahiurl.in/api?api={$api_token}&url={$long_url}";
$result = @json_decode(file_get_contents($api_url), TRUE);
if ($result["status"] === 'error') {
echo $result["message"];
} else {
echo $result["shortenedUrl"];
}
?>Using Plain Text Response:
<?php
$long_url = urlencode('https://example.com');
$api_token = 'YOUR_API_KEY';
$api_url = "https://sahiurl.in/api?api={$api_token}&url={$long_url}&format=text";
$result = @file_get_contents($api_url);
if ($result) {
echo $result;
}
?>Using Fetch:
const response = await fetch(
'https://sahiurl.in/api?api=YOUR_API_KEY&url=' + encodeURIComponent('https://example.com')
);
const data = await response.json();
console.log(data.shortenedUrl); // https://sahi.to/abc123Using POST with Headers:
const response = await fetch('https://sahiurl.in/api', {
method: 'POST',
headers: {
'x-api-key': 'YOUR_API_KEY',
'Content-Type': 'application/json'
},
body: JSON.stringify({
url: 'https://example.com',
alias: 'my-custom-link'
})
});
const data = await response.json();
console.log(data.shortenedUrl);import requests
from urllib.parse import quote
api_key = "YOUR_API_KEY"
long_url = quote("https://example.com")
response = requests.get(f"https://sahiurl.in/api?api={api_key}&url={long_url}")
data = response.json()
if data["status"] == "success":
print(data["shortenedUrl"])
else:
print(data["message"])Use this format in your Telegram bot:
/shortlink sahiurl.in YOUR_API_KEYReplace YOUR_API_KEY with your actual API key from Dashboard → Tools.
Note: Compatible with AdLinkFly-style bots. The API format matches popular URL shortener APIs.
| Status | Message | Description |
|---|---|---|
400 | Missing API key | API key not provided |
400 | Missing URL | URL parameter missing |
400 | Alias already taken | Custom alias is in use |
401 | Invalid API key | API key not found |
500 | Internal error | Server error |
{"status":"error","message":"Invalid API key"}