API Documentation

Complete reference for Shortner Pro REST API endpoints

Base URL
https://shortner-pro.vercel.app
🔐 Authentication

Using API Tokens

To use the API, you need to create an API token from your dashboard. Include it in your requests using the Authorization header:

Authorization: Bearer sp_your_api_token_here

Getting Your API Token

  1. Navigate to your Dashboard
  2. Click on "API Tokens" button
  3. Create a new token with a descriptive name
  4. Copy the generated token (it starts with "sp_")
  5. Use it in your API requests

Example Request with cURL

curl -X POST https://shortner-pro.vercel.app/api/shorten \
  -H "Authorization: Bearer sp_your_api_token_here" \
  -H "Content-Type: application/json" \
  -d '{
    "originalUrl": "https://example.com",
    "title": "My Link",
    "expiry": "never"
  }'

Example Request with JavaScript

const response = await fetch('https://shortner-pro.vercel.app/api/shorten', {
  method: 'POST',
  headers: {
    'Authorization': 'Bearer sp_your_api_token_here',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    originalUrl: 'https://example.com',
    title: 'My Link',
    expiry: 'never'
  })
});

const data = await response.json();
console.log(data.shortUrl);

⚠️ Important: Keep your API tokens secure. Never share them publicly or commit them to version control. Each token has rate limits based on your account configuration.

Filter by Category

POST/api/auth/register
Register a new user account
POST/api/auth/login
Authenticate user and get session
POST/api/auth/google
Authenticate with Google OAuth
POST/api/shorten
Create a new short URL
GET/api/redirect/{shortCode}
Redirect to original URL by short code
GET/api/user/links
Get all links for authenticated user
DELETE/api/user/links/{linkId}
Delete a specific link
GET/api/analytics/{shortCode}
Get analytics for a specific short URL
GET/api/analytics/detailed/{shortCode}
Get detailed analytics including device, location, and hourly data
POST/api/impression/{shortCode}
Track an ad impression for a short URL
POST/api/admin/cleanup
Delete expired links from database (admin only)
GET/api/migrate
Run database migrations