Back to Homepage

Developer Documentation

Welcome to the KompaktURL API. Our API is designed to be simple, predictable, and powerful. Build your own tools, automate shortening, or integrate real-time analytics into your workflow.

Authentication

All private API requests must include your API key in the X-API-Key header. You can generate an API key from your dashboard.

X-API-Key: ku_live_your_secret_key_here

If the key is missing or invalid, the API will return a 401 Unauthorized error.

Endpoints

Shorten a URL

POST /api/v1/urls/shorten

Create a shortened link for any long URL.

{
  "original_url": "https://example.com/very-long-path",
  "custom_code": "my-alias",
  "is_one_time": false
}

List My Links

GET /api/v1/urls/me

Retrieve a list of all URLs you've created.

Get Analytics

GET /api/v1/analytics/{short_code}

Get detailed click stats for a specific short code.

Webhooks

Webhooks allow you to receive real-time notifications when your links are clicked. We send a POST request to your endpoint as soon as an event occurs.

Security (HMAC Verification)

Each webhook request includes an X-KompaktURL-Signature header. Use your webhook secret to verify the payload signature using HMAC-SHA256.

# Python Verification Example
import hmac, hashlib
signature = hmac.new(secret.encode(), payload.encode(), hashlib.sha256).hexdigest()

Python SDK

Integrating is even easier with our official Python SDK. Download it from the sdk/python directory in the repository.

from kompakturl import KompaktURL

sdk = KompaktURL(api_key="your_key")
link = sdk.shorten("https://google.com")
print(link['short_code'])