API Documentation

Our API allows you to programmatically shorten URLs. Below you'll find the details of how to use our single endpoint.

Endpoint: /shorten

Parameters

Parameter Type Description Required
url String The original URL you want to shorten. Yes
custom_alias String A custom short code for the URL. If not provided, a random one will be generated. No

Success Response

On success, the API will return a JSON object with the short code.

{
    "short_code": "your_short_code"
}

Error Response

If something goes wrong, the API will return a JSON object with an error message.

{
    "error": "Error message describing the issue"
}

Example Usage

Here's an example of how to shorten a URL using curl:

curl -X POST \
  https://too-short.vercel.app/shorten \
  -d 'url=https://example.com/my-very-long-url-to-shorten'

To use a custom alias:

curl -X POST \
  https://too-short.vercel.app/shorten \
  -d 'url=https://example.com/another-long-url&custom_alias=my-link'