Utilities

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.

Endpoint:/api/v1/url/shorten
Methods:GETPOST
Latency:~5ms

Try it out

POST/api/v1/url/shorten

Parameters

Code

curl
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

FieldTypeRequiredDescription
urlstringRequiredThe URL to shorten (must be a valid HTTP/HTTPS URL)
codestringOptionalCustom short code (3–20 alphanumeric chars)

GET Query Parameters

NameTypeRequiredDescription
codestringRequiredThe 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

PlanLink LifetimeCustom Codes
Free30 daysNo
Starter180 daysYes
Professional365 daysYes
Business365 daysYes

Rate Limits

PlanRequests/MonthRate Limit
Free50010 req/min
Starter5,00030 req/min
Professional50,000120 req/min
Business250,000500 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.