FOR DEVELOPERS

API Documentation

Integrate ShortLink Pro into your applications with our comprehensive REST API.
Fast, reliable, and developer-friendly.

Quick Start

Get started with the API in minutes

Base URL
https://shorturl.ultrahosts.co.uk/api/
Authentication

All API requests require authentication using your API key:

bash
# Header Authentication (Recommended)
curl -H "Authorization: Bearer YOUR_API_KEY" \
     https://shorturl.ultrahosts.co.uk/api/urls

# Query Parameter Authentication  
curl "https://shorturl.ultrahosts.co.uk/api/urls?api_key=YOUR_API_KEY"
Get Your API Key
Response Format

All responses are in JSON format:

json
{
  "success": true,
  "data": { ... },
  "message": "Success message"
}

API Endpoints

Shorten URL
POST

POST /api/shorten.php

Create a new shortened URL.

Request Body:
{
  "url": "https://example.com/very-long-url",
  "custom_alias": "my-link",           // Optional
  "password": "secret123",             // Optional
  "expires_at": "2024-12-31 23:59:59" // Optional
}
Response:
{
  "success": true,
  "message": "URL shortened successfully",
  "data": {
    "id": 123,
    "original_url": "https://example.com/very-long-url",
    "short_code": "abc123",
    "short_url": "https://shorturl.ultrahosts.co.uk/abc123",
    "qr_code": "https://api.qrserver.com/v1/create-qr-code/?data=...",
    "title": "Page Title",
    "created_at": "2024-01-01 12:00:00"
  }
}
cURL Example:
curl -X POST "https://shorturl.ultrahosts.co.uk/api/shorten.php" \
     -H "Authorization: Bearer YOUR_API_KEY" \
     -H "Content-Type: application/json" \
     -d '{
       "url": "https://example.com/very-long-url",
       "custom_alias": "my-link"
     }'
Get URLs
GET

GET /api/urls.php

Retrieve your shortened URLs with pagination and search.

Query Parameters:
  • limit - Number of URLs to return (max 100, default 50)
  • offset - Number of URLs to skip (default 0)
  • search - Search term to filter URLs
cURL Example:
curl -H "Authorization: Bearer YOUR_API_KEY" \
     "https://shorturl.ultrahosts.co.uk/api/urls.php?limit=10&offset=0&search=example"
Update URL
PUT

PUT /api/urls.php?id={url_id}

Update an existing shortened URL.

Request Body:
{
  "title": "New Title",
  "description": "New Description",
  "password": "new_password",
  "expires_at": "2024-12-31 23:59:59",
  "is_active": true
}
cURL Example:
curl -X PUT "https://shorturl.ultrahosts.co.uk/api/urls.php?id=123" \
     -H "Authorization: Bearer YOUR_API_KEY" \
     -H "Content-Type: application/json" \
     -d '{"title": "Updated Title"}'
Delete URL
DELETE

DELETE /api/urls.php?id={url_id}

Delete (deactivate) a shortened URL.

cURL Example:
curl -X DELETE "https://shorturl.ultrahosts.co.uk/api/urls.php?id=123" \
     -H "Authorization: Bearer YOUR_API_KEY"
Get Analytics
GET

GET /api/analytics.php

Get detailed analytics for a specific URL.

Query Parameters:
  • url_id - Required. The ID of the URL
  • days - Number of days to include (max 365, default 30)
cURL Example:
curl -H "Authorization: Bearer YOUR_API_KEY" \
     "https://shorturl.ultrahosts.co.uk/api/analytics.php?url_id=123&days=30"

Error Codes

Code Description Common Causes
400 Bad Request Invalid URL, missing required fields
401 Unauthorized Invalid or missing API key
403 Forbidden Plan limits exceeded, insufficient permissions
404 Not Found URL not found or doesn't belong to user
429 Too Many Requests Rate limit exceeded
500 Internal Server Error Server error, contact support

SDKs & Libraries

JavaScript
// Using fetch API
const response = await fetch('https://shorturl.ultrahosts.co.uk/api/shorten.php', {
  method: 'POST',
  headers: {
    'Authorization': 'Bearer YOUR_API_KEY',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    url: 'https://example.com'
  })
});

const data = await response.json();
Python
import requests

headers = {
    'Authorization': 'Bearer YOUR_API_KEY',
    'Content-Type': 'application/json'
}

data = {
    'url': 'https://example.com'
}

response = requests.post(
    'https://shorturl.ultrahosts.co.uk/api/shorten.php',
    headers=headers,
    json=data
)
PHP
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://shorturl.ultrahosts.co.uk/api/shorten.php');
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode([
    'url' => 'https://example.com'
]));
curl_setopt($ch, CURLOPT_HTTPHEADER, [
    'Authorization: Bearer YOUR_API_KEY',
    'Content-Type: application/json'
]);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

$response = curl_exec($ch);
curl_close($ch);