Sk Shortener

API Documentation

Use your API key to access the URL shortener programmatically. Get your API key

Authentication

All API requests require authentication using your API key in the Authorization header:

Authorization: Bearer YOUR_API_KEY
Endpoints
POST /api/v1/shorten

Create a new short URL

curl -X POST https://dnsxn.com/api/v1/shorten \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "destination": "https://example.com/very/long/url",
    "customSlug": "my-link",
    "title": "My Campaign",
    "qrWidth": 300
  }'

Response:

{
  "success": true,
  "url": {
    "slug": "my-link",
    "shortURL": "https://dnsxn.com/my-link",
    "destination": "https://example.com/very/long/url",
    "qrCode": "data:image/png;base64,...",
    "createdAt": "2024-01-01T00:00:00.000Z"
  }
}
GET /api/v1/urls

List all your URLs

curl -X GET https://dnsxn.com/api/v1/urls \
  -H "Authorization: Bearer YOUR_API_KEY"

Response:

{
  "success": true,
  "urls": [
    {
      "slug": "my-link",
      "shortURL": "https://dnsxn.com/my-link",
      "destination": "https://example.com",
      "clicks_count": 42,
      "created_at": "2024-01-01T00:00:00.000Z"
    }
  ]
}
GET /api/v1/analytics/:slug

Get analytics for a specific URL

curl -X GET https://dnsxn.com/api/v1/analytics/my-link \
  -H "Authorization: Bearer YOUR_API_KEY"

Response:

{
  "success": true,
  "analytics": {
    "url": { ... },
    "summary": {
      "total_clicks": 42,
      "unique_visitors": 30
    },
    "clicksByDate": [ ... ],
    "clicksByCountry": [ ... ],
    "clicksByDevice": [ ... ]
  }
}
DELETE /api/v1/urls/:slug

Delete a URL

curl -X DELETE https://dnsxn.com/api/v1/urls/my-link \
  -H "Authorization: Bearer YOUR_API_KEY"

Response:

{
  "success": true,
  "message": "URL deleted successfully"
}
Error Responses

All error responses follow this format:

{
  "success": false,
  "error": "Error message description"
}

Common HTTP status codes: