v1
https://chl.li/api/v1
Shorten a URL with a POST request
/shorten
To shorten a URL, send a POST request to the following endpoint:
Headers
name | type | required | description |
---|---|---|---|
Content-Type | String | Yes | Must be application/json |
x-api-key | String | Yes | More information on API keys and where to get one. |
Body
name | type | required | description |
---|---|---|---|
url | String | Yes | Must be a valid URL |
alias | String | No | Is case sensitive and must be alphanumeric only |
expires | Number | No | Sets how many minutes the shortened link should work for |
Response
200 (OK)
If you successfully entered a valid body, this endpoint will return an HTTP response with a status code of 200 and a body as below.
The expiry property (timestamp) is only returned if the link has been set to expire.
400 (Bad Request)
If you send a URL that is invalid, you don't send an URL at all or the alias you send is invalid / already in use, this endpoint will return an HTTP response with a status code of 400 and a body as below.
Shorten a URL with a GET request using URL params
/shorten
To shorten a URL using URL parameters, send a GET request to the following endpoint or simply visit it in your browser. The API key is passed using the apikey
URL parameter:
Parameters
Same as using the POST method.
If you successfully entered a valid query, this endpoint will return an HTTP response with a status code of 200 and a body as below.
Note
Shortening a URL with a GET request will only return the shortened URL, if you need all the data returned, send a request using the POST method mentioned above.
Use the Accept
HTTP header to define how the result should be returned (plain text, html or json).
Currently, errors are returned in JSON regardless of the accept header. This will probably change very soon.
Get your shortened URLs
/links
To retrieve your shortened URLs, send a GET request to the following endpoint:
Headers
name | type | required | description |
---|---|---|---|
x-api-key | String | Yes | Your API key |
Query Parameters
name | type | required | description |
---|---|---|---|
page | Number | No | Page number (defaults to 1) |
limit | Number | No | Number of links per page (defaults to 25) |
sort | String | No | Field to sort by (created or clicks, defaults to created) |
order | String | No | Sort order (asc or desc, defaults to desc) |
Response
200 (OK)
If the request is successful, this endpoint will return an HTTP response with a status code of 200 and a body as below.
400 (Bad Request)
If the API key is invalid or missing, this endpoint will return an HTTP response with a status code of 400.
Expire a shortened link
/links
To make a link expire immediately, send a DELETE request with the alias in the body.
Headers
name | type | required | description |
---|---|---|---|
x-api-key | String | Yes | Your API key |
Body
name | type | required | description |
---|---|---|---|
alias | String | Yes | The alias of the link you want to expire |
Response
204 (No Content)
If the request is successful, this endpoint will return an HTTP response with a status code of 204 and no body. Note that you cannot reuse the alias of an expired link.
400 (Bad Request)
If the API key is invalid or missing, or the alias is missing or has not been created using the same API key, this endpoint will return an HTTP response with a status code of 400.