API ServicePaid licence
Bring 9H link shortening into your own website and systems
🚀About the service
9H API is self-serve: log in, claim your own API key in the Dashboard, and deploy short-link generation into any website, app or internal system — no redirect to the 9H web UI. API-created links go through the same five-layer safety validation and Google Safe Browsing checks as on-site links, support custom codes, and expose click stats and remaining quota.
Ideal for content systems on your own site, bulk landing-page generation, internal tools, e-commerce and community operations. Free web-based generation stays as-is; the API serves users who need programmatic, bulk or white-label integration — start free self-serve, upgrade to a paid plan for volume.
🧩Endpoints
Base URL https://9h.hk, authenticated with the header Authorization: Bearer <API Key>
| Method | Path | Description |
|---|---|---|
| POST | /api/v1/shorten.php | Create a short link (custom code supported; optional advanced params: password / max_clicks / expires_at / mobile_url / geo / utm) |
| GET | /api/v1/info.php?code={code} | Look up your link info and clicks |
| GET | /api/v1/usage.php | Check monthly quota and licence status |
| GET | /api/v1/health.php | Service health check (public) |
⚡Quick start
cURL example:
curl -X POST https://9h.hk/api/v1/shorten.php \
-H "Authorization: Bearer 9hk_YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"url":"https://example.com/a/very/long/page"}'
# Successful response
# {"code":0,"msg":"ok","data":{"short_url":"https://9h.hk/Ab3dEf",
# "code":"Ab3dEf","original":"https://example.com/a/very/long/page",
# "quota":{"used":1,"limit":1000,"remaining":999}}}
Browser JavaScript example (your domain must be whitelisted first):
const r = await fetch('https://9h.hk/api/v1/shorten.php', {
method: 'POST',
headers: {
'Authorization': 'Bearer 9hk_YOUR_API_KEY',
'Content-Type': 'application/json'
},
body: JSON.stringify({ url: 'https://example.com/page' })
});
const d = await r.json();
console.log(d.data.short_url);
Server-side PHP example:
$ch = curl_init('https://9h.hk/api/v1/shorten.php');
curl_setopt_array($ch, [
CURLOPT_POST => true,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => [
'Authorization: Bearer 9hk_YOUR_API_KEY',
'Content-Type: application/json'
],
CURLOPT_POSTFIELDS => json_encode(['url' => 'https://example.com/page'])
]);
$d = json_decode(curl_exec($ch), true);
echo $d['data']['short_url'];💳Pricing & activation
The API offers a free self-serve tier and paid plans: the free tier includes 100 links per month, activated in your Dashboard after login; paid plans are priced by monthly quota, licence term and number of registered domains. To activate:
Log in and open your Dashboard , then click "Activate free" in the API Key section — your key is issued instantly
Copy the key and call the API as documented on this page to create short links
For a higher quota, email cp@9h.hk with your expected volume; an admin upgrades your plan and can register an IP whitelist
View usage and rotate or disable your key anytime in the Dashboard; quota and usage are also queryable via the API
🛡️Authentication & limits
Each customer's key is independent and can be suspended or rotated anytime in the Dashboard — rotate it immediately or email us if one leaks. A licence can bind a domain whitelist (checked for browser calls) and an IP whitelist (checked for server calls), and is subject to a monthly quota and per-minute rate limit with explicit error codes. API-created links are governed by our Terms of Service; phishing, malware or other unlawful use leads to suspension.
More questions? See theContact us page or email cp@9h.hk。