Integrate URL shortening, QR code generation, and link management into your own applications via our REST API.
All API requests require a valid API key. You can generate keys from your Profile → API Keys page.
Pass your key in one of two ways:
Creates or updates a shortened URL and returns the result.
https://x2y.me/api.php
| Parameter | Required | Description |
|---|---|---|
api_key | Required | Your API key |
url | Required | The long URL to shorten (must include http:// or https://) |
name | Optional | Custom short name (alphanumeric, hyphens, underscores; min 4 chars). Auto-generated if omitted. |
date | Optional | Expiration date in YYYY-MM-DD format. Defaults to 1 year. |
return | Optional | json (default), url, name, qr, barcode |
X2Y automatically forwards any query parameters appended to the short URL to the destination. For example:
| HTTP Code | Error Message | Cause |
|---|---|---|
400 | Missing parameter: url | No URL provided |
400 | Invalid URL format | URL doesn't start with http(s) |
401 | Missing api_key | No key provided |
401 | Invalid or revoked API key | Key doesn't exist or was revoked |
403 | Account not active | Account still Pending admin approval |
400 | Name already taken | Custom name belongs to another user |
https://x2y.me/api.php