API Documentation
Integrate URL shortening into your apps using the DrTrim.io REST API. Generate an API key from your dashboard.
https://api.drtrim.io/v1Authentication
All API requests must include your API key as a Bearer token in the Authorization header. API keys begin with sk_.
curl https://api.drtrim.io/v1/links/ \ -H "Authorization: Bearer YOUR_API_KEY"
Rate limiting
All API endpoints are rate limited to 5 requests per second per authenticated user. Every response includes the following headers so you can track your current usage.
| Header | Type | Description |
|---|---|---|
| X-RateLimit-Limit | integer | Maximum requests allowed per second |
| X-RateLimit-Remaining | integer | Requests remaining in the current window |
| X-RateLimit-Reset | Unix timestamp | Time at which the current window resets |
When the limit is exceeded the API returns 429 Too Many Requests. Back off and retry after the time indicated in X-RateLimit-Reset.
429 response
{
"status": false,
"message": "Request was throttled. Expected available in 1 second.",
"data": null,
"meta": null,
"links": null
}Create a link
/links/createCreates a short link for the given URL. By default, if you have already shortened this URL, the most recent existing link is returned rather than creating a duplicate. Pass new: true to always create a fresh link. Optionally supply a code to use a custom short code.
Request body
| Parameter | Type | Required | Description |
|---|---|---|---|
| url | string | Yes | The destination URL to shorten |
| code | string | No | Custom short code. Auto-generated if omitted. |
| new | boolean | No | When true, always creates a new link even if one already exists for this URL. Default: false. |
| Status | Meaning |
|---|---|
| 201 Created | A new short link was created. |
| 200 OK | An existing link for this URL was returned (new was omitted or false). |
Example — auto-generated code
curl -X POST https://api.drtrim.io/v1/links/create \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"url": "https://example.com/very/long/url"}'Example — custom code
curl -X POST https://api.drtrim.io/v1/links/create \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"url": "https://example.com/long-url", "code": "summer-sale"}'Example — force new link
curl -X POST https://api.drtrim.io/v1/links/create \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"url": "https://example.com/very/long/url", "new": true}'Response
{
"status": true,
"message": "Link created successfully.",
"data": {
"id": 42,
"url": "https://example.com/very/long/url",
"code": "abc123",
"short_url": "https://drtrim.io/abc123",
"qr_code": "https://api.drtrim.io/qr/abc123.png",
"created_at": "2026-05-05T10:00:00Z"
}
}List links
/links/Returns a paginated list of all short links belonging to the authenticated user.
Query parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
| page | integer | 1 | Page number |
| limit | integer | 15 | Results per page (max 100) |
curl "https://api.drtrim.io/v1/links/?page=1&limit=15" \ -H "Authorization: Bearer YOUR_API_KEY"
Response
{
"status": true,
"message": "Successful Response",
"data": [
{
"id": 42,
"url": "https://example.com/very/long/url",
"code": "abc123",
"short_url": "https://drtrim.io/abc123",
"created_at": "2026-05-05T10:00:00Z"
}
],
"meta": {
"current_page": 1,
"from": 1,
"last_page": 1,
"path": "https://api.drtrim.io/v1/links/",
"per_page": 15,
"to": 4,
"total": 4
}
}Delete a link
/links/{'{id}'}/deletePermanently deletes a short link and all its associated visit data. This action cannot be undone.
curl -X DELETE https://api.drtrim.io/v1/links/{id}/delete \
-H "Authorization: Bearer YOUR_API_KEY"Response
{
"status": true,
"message": "Link deleted successfully.",
"data": null
}Link analytics
/links/{'{id}'}/visitsReturns paginated visit records for a specific link, including IP address, country, and city for each click.
Query parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
| page | integer | 1 | Page number |
| limit | integer | 50 | Results per page (max 100) |
curl "https://api.drtrim.io/v1/links/{id}/visits?page=1&limit=50" \
-H "Authorization: Bearer YOUR_API_KEY"Response
{
"status": true,
"message": "Successful Response",
"data": [
{
"id": 1,
"ip": "192.168.1.1",
"country": "United States",
"city": "New York",
"created_at": "2026-05-05T10:00:00Z"
}
],
"meta": {
"current_page": 1,
"from": 1,
"last_page": 29,
"path": "https://api.drtrim.io/v1/links/42/visits",
"per_page": 50,
"to": 50,
"total": 1420
}
}