API Documentation

Connect your website to Short Link and create short links automatically. The integration is designed to be copy-paste simple — one small function in your PHP code is all you need. No plugins, no libraries, no extra configuration, nothing else to build.

💡 How it works in one line: your website sends us a long URL → we reply with a ready short link. That's the entire integration.

What You Need Before Connecting

RequirementDetails
1. An account on our website Register here (free, takes one minute)
2. An API key Generated from your Dashboard after you log in
3. A PHP website with cURLcURL is enabled by default on virtually all PHP hostings

The Only Endpoint

There is exactly one API address, and it only accepts POST requests:

https://uplink.cyou.soshop.cyou/api.php

Request Parameters

FieldRequiredTypeDescription
api_key✅ YesstringYour private 32-character API key
url✅ YesstringThe long URL to shorten (http/https, max 2048 chars)
title❌ NostringOptional label to identify the link

Step 1: Copy This Function Into Your Website

This is all the code you will ever need. Paste it once (for example in your functions.php or a config file) and use it anywhere:

<?php
// =====================================================
// Short Link API connector
// Paste this ONCE in your website. Nothing else needed.
// =====================================================
function makeShortLink($longUrl, $title = null) {
    $apiEndpoint = "https://uplink.cyou.soshop.cyou/api.php";
    $apiKey      = "PASTE_YOUR_API_KEY_HERE";   // from your Dashboard

    $ch = curl_init($apiEndpoint);
    curl_setopt_array($ch, [
        CURLOPT_POST           => true,
        CURLOPT_POSTFIELDS     => http_build_query([
            'api_key' => $apiKey,
            'url'     => $longUrl,
            'title'   => $title,
        ]),
        CURLOPT_RETURNTRANSFER => true,
        CURLOPT_TIMEOUT        => 10,
    ]);
    $response = curl_exec($ch);
    curl_close($ch);

    $data = json_decode($response, true);

    if (($data['status'] ?? '') === 'success') {
        return $data['short_url'];   // ready short link
    }
    return false;
}

Step 2: Call It Wherever You Need a Short Link

// ✅ CORRECT — one line, done. No other code is needed.
$short = makeShortLink("https://example.com/some/very/long/page");

if ($short !== false) {
    echo "<a href='" . $short . "'>Visit</a>";
}

✅ How to Connect — The RIGHT Way

DoWhy
Send requests with POST to the single endpoint aboveThe API ignores everything else
Send api_key and url as form fieldsThese are the only two required fields
Keep your API key only in server-side PHP codeKeys in HTML/JavaScript can be stolen by visitors
Treat the reply as JSON and read short_urlstatus = success means the link is ready
Handle false / error replies quietlyYour site keeps working even if our API is briefly unreachable
Use one API key per websiteEasier to track usage and revoke if needed

❌ How to Connect — The WRONG Way

Don'tWhat happens instead
Send a GET request or open the endpoint in a browser405 METHOD_NOT_ALLOWED — nothing gets shortened
Forget the api_key field401 MISSING_API_KEY
Use a wrong or revoked key401/403 error — the key must come from your own Dashboard
Send text, FTP, or JavaScript links instead of real URLs422 INVALID_URL — only http/https links are accepted
Put your API key inside visible page HTML or client-side JSAnyone can copy it and use your quota
Try to create links for other people's accounts or manage keys through the APIThat is not possible — key management only happens in your Dashboard
Build your own extra plumbing around the APINot needed — the connector function above already does everything

Response Format

On success — new link (HTTP 201):

{
    "status":      "success",
    "short_code":  "aB3x9K",
    "short_url":   "https://uplink.cyou.soshop.cyou/aB3x9K",
    "long_url":    "https://example.com/very/long/url",
    "duplicate":   false
}

On success — same URL sent again (HTTP 200): identical reply, but with "duplicate": true and the same short link as before. Your code does not need to treat these two cases differently — status = "success" always means the short link is ready to use.

On failure (HTTP 401 / 403 / 405 / 422 / 500):

{
    "status":  "error",
    "code":    "INVALID_API_KEY",
    "message": "This API key does not exist."
}

Error Reference

HTTPCodeMeaning
405METHOD_NOT_ALLOWEDOnly POST requests are supported
401MISSING_API_KEYThe api_key field was not sent
401INVALID_API_KEYThe key is wrong or does not exist
403API_KEY_REVOKEDThe key was revoked from the Dashboard
403ACCOUNT_BLOCKEDThe account behind the key is blocked
422MISSING_URLThe url field was not sent
422INVALID_URLNot a valid http/https URL, or longer than 2048 chars
429RATE_LIMITEDToo many requests — slow down and retry shortly
500SERVER_ERRORCould not generate a short code — retry later

Important Rules

🚀 Ready to connect? Create your free account, generate an API key from the Dashboard, and you're done.