API Documentation

Authentication

All API requests require authentication using an API key. Include your API key in the request headers:

x-api-key: your_api_key_here

Endpoints

post/api/urls

Create a shortened URL

Request Body

{
  "type": "object",
  "properties": {
    "url": {
      "type": "string",
      "format": "uri",
      "description": "The URL to shorten"
    }
  },
  "required": [
    "url"
  ]
}

Responses

Status 200

URL shortened successfully

{
  "type": "object",
  "properties": {
    "shortCode": {
      "type": "string",
      "description": "The generated short code"
    },
    "originalUrl": {
      "type": "string",
      "description": "The original URL that was shortened"
    }
  }
}
Status 401

Authentication required - Please provide valid API key or session

post/api/urls/create

Create a shortened URL with optional custom code

Request Body

{
  "type": "object",
  "properties": {
    "url": {
      "type": "string",
      "format": "uri",
      "description": "The URL to shorten"
    },
    "shortCode": {
      "type": "string",
      "description": "Optional custom short code (requires paid plan)",
      "minLength": 1,
      "maxLength": 50
    }
  },
  "required": [
    "url"
  ]
}

Responses

Status 200

URL shortened successfully

{
  "type": "object",
  "properties": {
    "fullUrl": {
      "type": "string",
      "description": "The complete shortened URL"
    },
    "shortCode": {
      "type": "string",
      "description": "The generated or custom short code"
    },
    "originalUrl": {
      "type": "string",
      "description": "The original URL that was shortened"
    }
  }
}
Status 401

Authentication required - Please provide valid API key or session

Status 403

Custom short codes require a paid subscription

Status 409

This short code is already taken. Please choose another one.

get/api/urls/{code}

Get URL information

Responses

Status 200

URL details retrieved successfully

{
  "type": "object",
  "properties": {
    "originalUrl": {
      "type": "string",
      "description": "The original URL"
    },
    "shortCode": {
      "type": "string",
      "description": "The short code"
    },
    "clicks": {
      "type": "number",
      "description": "Number of times the URL has been accessed"
    }
  }
}
Status 404

URL not found

delete/api/urls/{code}

Delete a shortened URL

Responses

Status 200

URL deleted successfully

{
  "type": "object",
  "properties": {
    "success": {
      "type": "boolean",
      "description": "Indicates successful deletion"
    }
  }
}
Status 401

Authentication required - Please provide valid API key or session

Status 404

URL not found

get/api/keys

List all API keys for the authenticated user

Responses

Status 200

List of API keys

{
  "type": "array",
  "items": {
    "type": "object",
    "properties": {
      "key": {
        "type": "string",
        "description": "The API key"
      },
      "expiresAt": {
        "type": "string",
        "format": "date-time",
        "description": "Expiration date of the API key"
      },
      "requestsCount": {
        "type": "number",
        "description": "Number of requests made with this key"
      }
    }
  }
}
Status 401

Unauthorized - User session required

post/api/keys

Generate a new API key

Responses

Status 200

API key generated successfully

{
  "type": "object",
  "properties": {
    "key": {
      "type": "string",
      "description": "The generated API key"
    },
    "expiresAt": {
      "type": "string",
      "format": "date-time",
      "description": "Expiration date of the API key"
    }
  }
}
Status 401

Unauthorized - User session required

Status 403

API access requires a paid subscription

delete/api/keys/{key}

Delete an API key

Responses

Status 200

API key deleted successfully

{
  "type": "object",
  "properties": {
    "success": {
      "type": "boolean",
      "description": "Indicates successful deletion"
    }
  }
}
Status 401

Unauthorized - User session required

Status 404

API key not found

Rate Limits

API rate limits vary by plan:

  • Free: 100 requests/hour
  • Pro: 1,000 requests/hour
  • Enterprise: Custom limits

Example Usage

cURL

curl -X POST \
                -H "Content-Type: application/json" \
                -H "x-api-key: your_api_key" \
                -d '{"url":"https://example.com"}' \
                https://your-domain.com/api/urls

JavaScript

const response = await
                fetch('https://your-domain.com/api/urls', {
                method: 'POST',
                headers: {
                'Content-Type': 'application/json',
                'x-api-key': 'your_api_key'
                },
                body: JSON.stringify({
                url: 'https://example.com'
                })
                })

                const data = await response.json()