Shorten URL Image Converter About Blog API Docs

How to Use the Shortix API —
A Developer Guide

If you're building an app, running automated workflows, or just tired of shortening links manually — the Shortix REST API lets you do it all programmatically. In this guide we'll walk through every available endpoint, authentication methods, and working code examples you can drop straight into your project.

What the API Can Do

The Shortix API currently exposes four endpoints that cover the full link lifecycle:

All requests and responses use JSON. The base URL for every endpoint is https://shortix.xyz/api.

Authentication

Most endpoints require authentication. The API supports two methods — use whichever fits your use case.

Method 1 — Firebase ID Token (for logged-in users)

If you're building a client-side app where users sign in with their Shortix account, obtain a Firebase ID token from the authenticated user and pass it as a Bearer token:

Authorization: Bearer <firebase-id-token>

Method 2 — API Key (for server-to-server integrations)

For backend scripts and automation where no user is involved, use a static API key in the X-API-Key header:

X-API-Key: your-secret-api-key
💡 Note: The GET /api/stats endpoint is fully public — no authentication header is required.

Endpoint Reference

1. Create a Short Link

POST /api/shorten

Creates a new short link and returns its full metadata including the generated short URL, click count (starts at 0), and creation timestamp.

Request body (JSON):

{ "url": "https://your-long-destination-url.com/path?query=value", "alias": "my-brand" // optional — 3–32 chars, letters/numbers/hyphens/underscores }

Example with curl:

curl -X POST https://shortix.xyz/api/shorten \ -H "Content-Type: application/json" \ -H "X-API-Key: your-secret-key" \ -d '{"url":"https://example.com/very/long/path","alias":"my-link"}'

Example with JavaScript (fetch):

const response = await fetch('https://shortix.xyz/api/shorten', { method: 'POST', headers: { 'Content-Type': 'application/json', 'X-API-Key': 'your-secret-key' }, body: JSON.stringify({ url: 'https://example.com/very/long/path', alias: 'my-link' // omit for auto-generated code }) }); const data = await response.json(); console.log(data.shortUrl); // https://shortix.xyz/my-link

2. Get Link Metadata

GET /api/info/:code

Fetches metadata for any existing short link by its short code. No authentication is required — this is a public endpoint. Returns the original URL, click count, and creation date.

curl https://shortix.xyz/api/info/my-link

This is useful for checking how many clicks a link has received or verifying where a short code currently points before using it in automation.

3. Platform Statistics

GET /api/stats

Returns real-time platform-wide counters: total links shortened, total image conversions, and total QR codes generated. No authentication required.

curl https://shortix.xyz/api/stats

4. Delete a Short Link

DELETE /api/delete/:code

Permanently removes a short link. This action is irreversible. Token-authenticated users can only delete links they own. API key users can delete any link.

curl -X DELETE https://shortix.xyz/api/delete/my-link \ -H "X-API-Key: your-secret-key"
⚠️ Heads up: Deleted links cannot be restored. Any traffic sent to a deleted short code will receive a 404 response.

Practical Use Cases

Automate link creation from a spreadsheet

If you manage a large list of URLs — affiliate links, campaign URLs, or redirects — you can write a short script that reads from a CSV and hits POST /api/shorten for each row, writing the resulting short URLs back out. No manual copying required.

Embed link shortening in your own product

If you're building a SaaS tool, CMS, or internal dashboard that deals with URLs, the API lets you add a "Shorten" button that calls Shortix in the background. Your users get clean links without ever leaving your interface.

Monitor click performance in real time

By polling GET /api/info/:code at regular intervals, you can track click growth on any link — useful for campaign monitoring, A/B comparisons, or simply knowing when a link has gone viral.

Error Codes

The API returns standard HTTP status codes. A 200 or 201 means success. Common errors include 400 (invalid request body or missing fields), 401 (missing or invalid credentials), 409 (alias already taken), and 404 (short code not found). All error responses include a JSON body with a message field explaining what went wrong.

Full API Reference

The interactive API documentation — with full request/response schemas, live examples, and a try-it interface — is available at shortix.xyz/api-docs. It's the best place to explore the endpoints before writing code.

Explore the Full API Docs

Interactive reference with full schemas, code examples, and live endpoint explorer.

Open API Docs →