📡 API Documentation
Programmatically create short URLs with the Gil.bar REST API.
Authentication
All API requests require a valid token. To obtain a token, please submit a request via our contact form and include the reason why you need access to the Gil.bar API. Once approved, your token will be provided. Include it as a query parameter:
?token=YOUR_API_TOKEN
Token Types
| Type | Custom Slug | Description |
|---|---|---|
| Basic | ❌ | Random slug auto-generated |
| Premium | ✅ | Can specify custom subdomain |
Create Short URL
GET
https://api.gil.bar/shorten_api
Parameters
| Parameter | Required | Description |
|---|---|---|
token | Required | Your API token |
url | Required | The long URL to shorten |
slug | Optional | Custom subdomain (Premium tokens only) |
Example Request
GET https://api.gil.bar/shorten_api?token=abc123&url=https://google.com&slug=mylink
Success Response
{
"status": "success",
"message": "Short URL created successfully.",
"data": {
"short_url": "https://mylink.gil.bar",
"slug": "mylink",
"original_url": "https://google.com",
"title": "Google",
"stats_url": "https://mylink.gil.bar/stat",
"qr_code_url": "https://api.gil.bar/qrcode?..."
}
}
Error Responses
| Scenario | Message |
|---|---|
| Invalid token | "Invalid API token." |
| Token deactivated | "This API token has been deactivated." |
| Missing URL | "URL parameter is required." |
| Invalid URL | "Invalid URL format." |
| Slug taken | "Subdomain 'xxx' is already taken." |
| Basic + custom slug | "Custom slug is not allowed for Basic tokens." |
| Rate limit exceeded | "Monthly limit reached (1000/1000)." |
| Reserved subdomain | "This subdomain is reserved." |
Rate Limits
Each token has a default limit of 1,000 requests per 30-day cycle. The cycle starts from the day the token is created and resets every 30 days. Contact us if you need a higher limit.
Check Token Usage
GET
https://api.gil.bar/token_status
Parameters
| Parameter | Required | Description |
|---|---|---|
token | Required | Your API token |
Example Request
GET https://api.gil.bar/token_status?token=YOUR_TOKEN
Response
{
"status": "success",
"data": {
"label": "My App",
"type": "premium",
"is_active": true,
"cycle_usage": 42,
"cycle_limit": 1000,
"remaining": 958,
"cycle_start": "2026-02-10",
"resets_at": "2026-03-12"
}
}
Code Examples
cURL
curl "https://api.gil.bar/shorten_api?token=YOUR_TOKEN&url=https://example.com"
JavaScript (Fetch)
const response = await fetch(
'https://api.gil.bar/shorten_api?token=YOUR_TOKEN&url=https://example.com'
);
const data = await response.json();
console.log(data.data.short_url); // https://xxxxx.gil.bar
Python
import requests
r = requests.get('https://api.gil.bar/shorten_api', params={
'token': 'YOUR_TOKEN',
'url': 'https://example.com'
})
print(r.json()['data']['short_url'])
PHP
$response = file_get_contents(
'https://api.gil.bar/shorten_api?token=YOUR_TOKEN&url=' . urlencode('https://example.com')
);
$data = json_decode($response, true);
echo $data['data']['short_url'];
💡 Tip: The
qr_code_url in the response returns a direct link to a branded QR code image for your short URL.