API Documentation

Integrate ShortURL into your applications with our RESTful API.

Introduction

The ShortURL API allows you to programmatically create short links, manage your links, and retrieve analytics data. Our API is organized around REST and returns JSON responses.

Base URL:

https://t.wpsanjeet.com/api

Authentication

All API requests require an API key. Include your API key in the Authorization header or as a query parameter.

Authorization: Bearer YOUR_API_KEY

API keys are available for Pro and Agency plans. Get your API key from your dashboard.

Shorten URL

Create a new short link from a long URL.

POST /api/?endpoint=shorten

Request Body

Parameter Type Required Description
url string Yes The long URL to shorten
alias string No Custom short code (3-50 chars)
title string No Title for the link

Example Request

curl -X POST https://t.wpsanjeet.com/api/?endpoint=shorten \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"url": "https://example.com/my-long-url", "alias": "mylink"}'

Example Response

{
  "success": true,
  "data": {
    "short_url": "https://t.wpsanjeet.com/mylink",
    "short_code": "mylink",
    "long_url": "https://example.com/my-long-url",
    "qr_code_url": "https://api.qrserver.com/v1/create-qr-code/?size=200x200&data=https%3A%2F%2Ft.wpsanjeet.com/mylink",
    "created_at": "2024-01-15 10:30:00"
  }
}

Analytics

Retrieve click analytics for your links.

GET /api/?endpoint=analytics&link_id={id}&days={days}

Query Parameters

Parameter Type Required Description
link_id integer No Specific link ID. Omit for account summary.
days integer No Number of days to analyze (1-90, default 30)

Bio Pages

List all your bio link pages.

GET /api/?endpoint=bio-pages

Rate Limits

To ensure fair usage, API requests are rate limited:

  • Free plan: Not available
  • Pro plan: 1,000 requests per hour
  • Agency plan: 10,000 requests per hour

If you exceed your rate limit, the API will return a 429 Too Many Requests response.

Error Codes

Code Description
400Bad Request - Invalid parameters
401Unauthorized - Invalid API key
403Forbidden - Plan limit reached
404Not Found - Resource doesn't exist
405Method Not Allowed
409Conflict - Custom alias already taken
429Too Many Requests - Rate limit exceeded