Developers API

Detailed docs & examples

Authentication
Use your API key in query or header
Query:  /api/shorten?api=<API_KEY>&url=<LONG_URL>
Header: x-api-key: <API_KEY>
Quick Link
Shorten a single URL
GET https://sahi.to/api/shorten?api=<API_KEY>&url=<LONG_URL>
-> {"status":"success","shortenedUrl":"https://sahi.to/abc123"}
Batch (coming soon)
Shorten multiple URLs
POST https://sahi.to/api/shorten
Headers: x-api-key: <API_KEY>
Body: { "urls": ["https://a.com","https://b.com"] }
Full Page Script
Auto-convert links on your site
<script src="https://sahi.to/sdk.js"></script>
<script>
  SahiURL.init({ key: "<API_KEY>", selector: "a" });
</script>
Responses
JSON and TEXT formats
JSON: {"status":"success","shortenedUrl":"https://sahi.to/abc123"}
TEXT: https://sahi.to/abc123
Errors
Standard error payload
{"status":"error","message":"Alias already taken"}