This API allows you to shorten long URLs and redirect users from a short slug to the original URL. Below you'll find details on how to interact with the available endpoints.
POST /shorten
Description: Creates a new short URL for the provided long URL. You can optionally provide a custom slug.
Request Body (JSON):
{
"long_url": "https://www.example.com/very/long/url/path",
"custom_slug": "my-short-link" // Optional: provide a desired custom slug
}
Response Body (JSON - Success 200 OK):
{
"short_url": "YOUR_BASE_URL/s/generated_slug_or_custom_slug"
}
Error Response (JSON):
{
"error": "Error message details, e.g., Invalid URL provided"
}
GET /s/{short_slug}
Description: Redirects to the original long URL associated with the given short slug.
Response: 302 Found (Redirects to the original URL).
Error Response (JSON - 404 Not Found):
{
"error": "Link not found or expired"
}
GET /health
Description: Checks the operational status of the API server. Useful for monitoring.
Response: Plain text "OK" (200 OK).
OK