Introduction

Welcome to the OrionLinks API! This RESTful API allows you to programmatically create and manage short links.

Base URL: https://www.orionlinks.orionscripts.com/api

Authentication

All API requests require authentication using Bearer tokens.

POST /api/login

Obtain an API token

Request Body:
{
  "email": "user@example.com",
  "password": "your-password"
}
Response:
{
  "success": true,
  "message": "Login successful",
  "data": {
    "user": {
      "id": 1,
      "name": "John Doe",
      "email": "user@example.com"
    },
    "token": "1|abc123..."
  }
}
Usage: Include the token in all requests:
Authorization: Bearer YOUR_TOKEN_HERE

Endpoints

GET /api/links

Get all your links

Query Parameters:
  • page - Page number (default: 1)
  • per_page - Items per page (default: 15, max: 100)
Response:
{
  "success": true,
  "data": {
    "current_page": 1,
    "data": [
      {
        "id": 1,
        "short_code": "abc123",
        "original_url": "https://example.com",
        "clicks_count": 42,
        "created_at": "2025-12-14T10:00:00.000000Z"
      }
    ],
    "total": 10
  }
}
POST /api/links

Create a new short link

Request Body:
{
  "url": "https://example.com/very-long-url",
  "custom_alias": "mylink",  // optional
  "password": "secret123",   // optional
  "expires_at": "2025-12-31", // optional
  "click_limit": 1000        // optional
}
Response:
{
  "success": true,
  "message": "Link created successfully",
  "data": {
    "id": 1,
    "short_url": "https://www.orionlinks.orionscripts.com/abc123",
    "short_code": "abc123",
    "original_url": "https://example.com/very-long-url",
    "qr_code_url": "https://www.orionlinks.orionscripts.com/links/1/qrcode"
  }
}
GET /api/links/{id}/stats

Get detailed statistics for a link

Response:
{
  "success": true,
  "data": {
    "total_clicks": 150,
    "by_country": [...],
    "by_device": [...],
    "by_browser": [...],
    "recent_clicks": [...]
  }
}
POST /api/links/bulk

Create multiple links at once (max 100)

Request Body:
{
  "links": [
    { "url": "https://example.com/page1" },
    { "url": "https://example.com/page2", "custom_alias": "page2" }
  ]
}
DELETE /api/links/{id}

Delete a link

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

Error Handling

The API uses standard HTTP status codes:

  • 200 - Success
  • 201 - Created
  • 400 - Bad Request
  • 401 - Unauthorized
  • 404 - Not Found
  • 422 - Validation Error
  • 500 - Server Error
Error Response Format:
{
  "success": false,
  "message": "Error description",
  "errors": {
    "field": ["Validation error message"]
  }
}

Code Examples

JavaScript (Fetch)
const response = await fetch('https://www.orionlinks.orionscripts.com/api/links', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
    'Authorization': 'Bearer YOUR_TOKEN'
  },
  body: JSON.stringify({
    url: 'https://example.com'
  })
});

const data = await response.json();
console.log(data.data.short_url);
PHP (cURL)
$ch = curl_init('https://www.orionlinks.orionscripts.com/api/links');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
    'Content-Type: application/json',
    'Authorization: Bearer YOUR_TOKEN'
]);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode([
    'url' => 'https://example.com'
]));

$response = curl_exec($ch);
$data = json_decode($response, true);
echo $data['data']['short_url'];
Python (Requests)
import requests

response = requests.post('https://www.orionlinks.orionscripts.com/api/links', 
    headers={'Authorization': 'Bearer YOUR_TOKEN'},
    json={'url': 'https://example.com'}
)

data = response.json()
print(data['data']['short_url'])