link-to@console:~$
POST https://link-to.site/create

// INTRODUCTION

The Link-To API allows you to programmatically create shortened URLs. Our API is RESTful, returns JSON responses, and uses standard HTTP response codes. This documentation provides all the information you need to integrate our URL shortening service into your applications.

Base URL: https://link-to.site

// API SPECIFICATIONS

Download our machine-readable API specifications for integration with tools like Postman, Swagger UI, or automated SDK generators.

// INTERACTIVE API TESTER

Test API without Authentication

Use the public demo API key below to test the API without registration. This endpoint simulates the real API behavior but doesn't save data to the database. All test requests are logged and displayed below.

$ test_api()

Public demo key - no registration required
Group ID or API group identifier for organization

$ live_test_log()

Loading test logs...

// AUTHENTICATION

All API requests require authentication using your API key. You can obtain your API key from your account dashboard after purchasing an API-enabled plan.

$ get_api_key()

  1. Log in to your account dashboard
  2. Navigate to Account Settings
  3. Your API key will be displayed in the API Access section
  4. Copy your API key and keep it secure
Keep your API key secure! Never share it publicly or commit it to version control.

$ authentication_methods()

We support two authentication methods for backward compatibility:

Method 1: Header Authentication (Recommended)

HTTP Headers
X-API-Key: your_api_key_here
Content-Type: application/json

Method 2: POST Parameter (Legacy)

Form Data
apikey=your_api_key_here&url=https://example.com

// REQUEST PARAMETERS

Parameter Type Required Description
url string Required The long URL to shorten. Must be a valid HTTP/HTTPS URL.
group string Optional Group ID or API group identifier to organize your links.

// CODE EXAMPLES

$ curl_modern()

bash
curl -X POST https://link-to.site/create \
  -H 'Content-Type: application/json' \
  -H 'X-API-Key: your_api_key_here' \
  -d '{
    "url": "https://example.com"
  }'

$ curl_legacy()

bash
curl -X POST https://link-to.site/create \
  -d 'apikey=your_api_key_here' \
  -d 'url=https://example.com'

$ php_example()

php
<?php
$apiUrl = 'https://link-to.site/create';
$apiKey = 'your_api_key_here';

$data = json_encode([
    'url' => 'https://example.com'
]);

$options = [
    'http' => [
        'method' => 'POST',
        'header' => [
            'Content-Type: application/json',
            'X-API-Key: ' . $apiKey
        ],
        'content' => $data
    ]
];

$context = stream_context_create($options);
$response = file_get_contents($apiUrl, false, $context);
$result = json_decode($response, true);

if ($result['success'] === 'true') {
    echo "Short URL: " . $result['short_url'];
} else {
    echo "Error: " . $result['message'];
}
?>

$ javascript_example()

javascript
const apiUrl = 'https://link-to.site/create';
const apiKey = 'your_api_key_here';

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

fetch(apiUrl, {
    method: 'POST',
    headers: {
        'Content-Type': 'application/json',
        'X-API-Key': apiKey
    },
    body: JSON.stringify(data)
})
.then(response => response.json())
.then(result => {
    if (result.success === 'true') {
        console.log('Short URL:', result.short_url);
    } else {
        console.error('Error:', result.message);
    }
})
.catch(error => console.error('Request failed:', error));

$ python_example()

python
import requests
import json

api_url = 'https://link-to.site/create'
api_key = 'your_api_key_here'

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

headers = {
    'Content-Type': 'application/json',
    'X-API-Key': api_key
}

response = requests.post(api_url, json=data, headers=headers)
result = response.json()

if result['success'] == 'true':
    print(f"Short URL: {result['short_url']}")
else:
    print(f"Error: {result['message']}")

// RESPONSE FORMAT

Success Response

json
{
    "success": "true",
    "timestamps": "2025/11/13 16:53:37",
    "message": "Certification completed",
    "error": "",
    "short_code": "abc123",
    "short_url": "https://link-to.site/abc123",
    "long_url": "https://example.com",
    "qr_code": "https://link-to.site/qrcode/abc123.png",
    "title": "Example Domain",
    "clicks": 0
}

Error Response

json
{
    "success": "false",
    "timestamps": "2025/11/13 16:53:37",
    "message": "API key not detected",
    "error": "301"
}

// ERROR CODES

The API uses the following error codes to indicate specific issues:

Code Description
300API not queried correctly - Invalid request format
301API key not detected - Missing authentication
302URL not found - Missing required 'url' parameter
303User not found or wrong API key - Invalid credentials
304The shortenable URLs are finished - No available URL slots
305The indicated URL has already been shortened
306The URL could not be processed - Connection or fetch error
307404 Error - The page does not exist
308The page is hosted on a server with Mod_Security enabled
309The page is hosted on a secure server with Cloudflare protection
310The URL directs to a social network - Not allowed
311HTTP headers returned 0 as file size - Empty response
312The indicated group does not exist
429Rate limit exceeded - Please try again later

// RATE LIMITING

To ensure fair usage and system stability, API requests are rate-limited:

Rate Limit: 1,000 requests per hour per API key

If you exceed the rate limit, you'll receive a 429 error response. The rate limit resets every hour. If you need higher limits, please contact support.

// BEST PRACTICES

  • Secure your API key: Never expose it in client-side code or public repositories
  • Handle errors gracefully: Always check the success field and handle errors appropriately
  • Cache responses: Store shortened URLs to avoid duplicate API calls
  • Use custom codes wisely: Choose memorable, branded short codes when appropriate
  • Respect rate limits: Implement exponential backoff if you hit rate limits
  • Validate URLs: Ensure URLs are valid before sending them to the API

// SUPPORT

Need help? We're here to assist you: