Back to API List
URL Shortener API
Create and manage shortened URLs with click tracking, expiration, and custom aliases.
Utilities
Internal API - Hosted by this App
API Endpoints & Usage
Explore and interact with the available endpoints for the URL Shortener API. These API routes are live! The paths shown below are relative to your application's base URL. For example, if this application is hosted at
https://gen-endpoint.com
, an endpoint path for this API, such as /api/shorten
, would be accessible at https://gen-endpoint.com/api/shorten
. You can use the "Try it out" section for each endpoint or use tools like curl
, Postman, or your browser's address bar (for GET requests) to interact with them.POST
/api/shorten
Create shortened URL with optional custom alias and expiration.
Show Static Examples
Example Request Body:
{
"originalUrl": "https://www.example.com/very/long/path/to/content",
"customAlias": "my-link",
"expiresAt": "2024-12-31T23:59:59Z",
"description": "Link to important content"
}
Example Response:
{
"id": "link_123",
"shortUrl": "https://short.ly/my-link",
"originalUrl": "https://www.example.com/very/long/path/to/content",
"shortCode": "my-link",
"createdAt": "2024-08-16T12:00:00Z",
"expiresAt": "2024-12-31T23:59:59Z"
}
Try it out
GET
/api/stats/{shortCode}
Get click statistics and analytics for shortened URL. Replace {shortCode} with an actual code.
Show Static Examples
Example Response:
{
"shortCode": "my-link",
"originalUrl": "https://www.example.com/very/long/path/to/content",
"totalClicks": 1250,
"uniqueClicks": 892,
"clicksByDate": [
{
"date": "2024-08-15",
"clicks": 45
},
{
"date": "2024-08-16",
"clicks": 67
}
],
"topReferrers": [
"google.com",
"twitter.com",
"facebook.com"
],
"countries": [
{
"code": "US",
"name": "United States",
"clicks": 678
}
]
}
Try it out
Replace placeholders (e.g., {userId}) with actual values in the path above. You can also add/edit query parameters (e.g., ?key=value).
GET
/api/links
List user's shortened URLs with filtering.
Show Static Examples
Example Request Parameters:
?status=active&sort=created_desc&page=1&limit=10
Example Response:
{
"links": [
{
"id": "link_123",
"shortCode": "my-link",
"originalUrl": "https://www.example.com/very/long/path/to/content",
"totalClicks": 1250,
"status": "active",
"createdAt": "2024-08-16T12:00:00Z"
}
],
"pagination": {
"page": 1,
"limit": 10,
"total": 45
}
}
Try it out
You can add or change query parameters in the path above (e.g., ?name=User).
DELETE
/api/links/{linkId}
Delete shortened URL and disable access. Replace {linkId} with an actual ID.
Show Static Examples
Example Response:
{
"message": "Link link_123 deleted successfully",
"deletedAt": "2024-08-16T12:30:00Z"
}
Try it out
Replace placeholders (e.g., {userId}) with actual values in the path above.