URL Shortener
Create and resolve shortened URLs with optional custom codes. Powered by Valkey for high-speed storage with automatic expiration (30 days for Free tier, 365 days for paid plans). Includes click tracking and FNV hash-based auto-code generation.
/api/v1/url/shortenTry it out
/api/v1/url/shortenParameters
Code
curl -X POST "https://khaleejiapi.dev/api/v1/url/shorten?url=https%3A%2F%2Fkhaleejiapi.dev%2Fdocs" \ -H "Authorization: Bearer your_api_key"Methods
GET — Resolve Short URL
Resolve a shortened URL by its code. Pass code as a query parameter. Returns the original URL, creation date, expiry, and click count. Increments the click counter.
POST — Create Short URL
Create a new shortened URL. Send url (required) and optional code in the request body. If no custom code is provided, a 6-character FNV hash code is auto-generated.
POST Request Body
| Field | Type | Required | Description |
|---|---|---|---|
| url | string | Required | The URL to shorten (must be a valid HTTP/HTTPS URL) |
| code | string | Optional | Custom short code (3–20 alphanumeric chars) |
GET Query Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| code | string | Required | The short URL code to resolve |
Response Fields
shortUrl
Full shortened URL with domain
code
The short code (auto-generated or custom)
originalUrl
The original long URL
createdAt
ISO 8601 creation timestamp
expiresAt
ISO 8601 expiration timestamp
clicks
Total click/resolve count
Expiration
| Plan | Link Lifetime | Custom Codes |
|---|---|---|
| Free | 30 days | No |
| Starter | 180 days | Yes |
| Professional | 365 days | Yes |
| Business | 365 days | Yes |
Rate Limits
| Plan | Requests/Month | Rate Limit |
|---|---|---|
| Free | 500 | 10 req/min |
| Starter | 5,000 | 30 req/min |
| Professional | 50,000 | 120 req/min |
| Business | 250,000 | 500 req/min |
Debugging & Support
Include X-Request-ID when contacting support
Every response from KhaleejiAPI includes an X-Request-ID header — a unique identifier that lets our support team pull the exact log entry for your request within seconds. Always share it when reporting an unexpected error or unexpected result.
How to capture it
JavaScript / fetch
const res = await fetch("https://khaleejiapi.dev/api/v1/...", {
headers: { Authorization: "******" },
});
const requestId = res.headers.get("x-request-id");
console.log("Request ID:", requestId);
// → e.g. "req_01j9xkz4vp8..."cURL
curl -si "https://khaleejiapi.dev/api/v1/..." \ -H "Authorization: ******" | grep -i x-request-id # → x-request-id: req_01j9xkz4vp8...
Browser DevTools
Open DevTools (F12) → Network tab → click the failing request → scroll to the Response Headers section → copy the value next to x-request-id.
For a full list of error codes and guidance on common issues, see the Troubleshooting guide.