API Documentation

Integrate Shorty's powerful URL shortening and analytics into your applications

1

Get API Key

Sign up and generate your API key from your dashboard

2

Make Request

Send authenticated requests to our REST API endpoints

3

Get Response

Receive JSON responses with shortened URLs and analytics

API Base URL

https://api.shorty.com/v1

All endpoints are relative to this base URL. Authentication required for all requests.

Authentication

Include your API key in the request header:

Authorization: Bearer YOUR_API_KEY

Important: Keep your API key secure. Never expose it in client-side code or public repositories.

POST

/shorten

Create a new shortened URL

Request Body

{
  "url": "https://example.com/very/long/url",
  "custom_alias": "my-link",  // optional
  "domain": "short.fy"         // optional
}

Response (200 OK)

{
  "success": true,
  "data": {
    "id": "abc123",
    "short_url": "https://short.fy/abc123",
    "original_url": "https://example.com/very/long/url",
    "created_at": "2025-01-15T10:30:00Z"
  }
}

Example

curl -X POST https://api.shorty.com/v1/shorten \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"url": "https://example.com/page"}'
GET

/links/{id}

Get information about a shortened link

Response (200 OK)

{
  "success": true,
  "data": {
    "id": "abc123",
    "short_url": "https://short.fy/abc123",
    "original_url": "https://example.com/page",
    "clicks": 1234,
    "created_at": "2025-01-15T10:30:00Z",
    "updated_at": "2025-01-15T10:30:00Z"
  }
}

Example

curl https://api.shorty.com/v1/links/abc123 \
  -H "Authorization: Bearer YOUR_API_KEY"
GET

/links/{id}/analytics

Get detailed analytics for a link

Query Parameters

  • period - Time period (7d, 30d, 90d, all)
  • groupBy - Group by (day, week, month)

Response (200 OK)

{
  "success": true,
  "data": {
    "total_clicks": 1234,
    "unique_clicks": 856,
    "referrers": [
      {"source": "twitter.com", "clicks": 450},
      {"source": "facebook.com", "clicks": 320}
    ],
    "countries": [
      {"country": "US", "clicks": 600},
      {"country": "UK", "clicks": 200}
    ],
    "devices": [
      {"type": "mobile", "clicks": 700},
      {"type": "desktop", "clicks": 534}
    ]
  }
}
DELETE

/links/{id}

Delete a shortened link

Response (200 OK)

{
  "success": true,
  "message": "Link deleted successfully"
}

Error Handling

The API uses standard HTTP status codes and returns errors in this format:

{
  "success": false,
  "error": {
    "code": "invalid_url",
    "message": "The provided URL is invalid"
  }
}

Common Status Codes

200 Success
400 Bad Request - Invalid parameters
401 Unauthorized - Invalid API key
404 Not Found - Resource doesn't exist
429 Too Many Requests - Rate limit exceeded
500 Server Error - Something went wrong on our end

Rate Limits

Free Plan

100

requests per hour

Pro Plan

1,000

requests per hour

Enterprise

Custom

unlimited requests

Ready to Start Building?

Sign up now and get your API key to start integrating Shorty