chl.li API Documentation

v1

Base URL
https://chl.li/api/v1

Shorten a URL with a POST request

POST
/shorten

To shorten a URL, send a POST request to the following endpoint:

Headers

nametyperequireddescription
Content-TypeStringYesMust be application/json
x-api-keyStringYesMore information on API keys and where to get one.

Body

nametyperequireddescription
urlStringYesMust be a valid URL
aliasStringNoIs case sensitive and must be alphanumeric only
expiresNumberNo 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

GET
/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.

Expire a shortened link

DELETE
/links

To make a link expire immediately, send a DELETE request with the alias in the body.

Headers

nametyperequireddescription
x-api-keyStringYesYour API key

Body

nametyperequireddescription
aliasStringYesThe 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.