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.
/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"
}
}
List Links
Get a list of all your shortened links.
/api/?endpoint=links
Example Request
curl https://t.wpsanjeet.com/api/?endpoint=links \ -H "Authorization: Bearer YOUR_API_KEY"
Delete Link
Delete a short link permanently.
/api/?endpoint=links&id={link_id}
Example Request
curl -X DELETE "https://t.wpsanjeet.com/api/?endpoint=links&id=123" \ -H "Authorization: Bearer YOUR_API_KEY"
Analytics
Retrieve click analytics for your links.
/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.
/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 |
|---|---|
| 400 | Bad Request - Invalid parameters |
| 401 | Unauthorized - Invalid API key |
| 403 | Forbidden - Plan limit reached |
| 404 | Not Found - Resource doesn't exist |
| 405 | Method Not Allowed |
| 409 | Conflict - Custom alias already taken |
| 429 | Too Many Requests - Rate limit exceeded |