The admin API is available at /admin prefix and provides endpoints for managing:
- Projects
- Origins (domains)
- Storage configurations
- Video profiles
All admin API endpoints require authentication. Include the authorization header:
Authorization: Bearer <your-token>
GET /admin/projects
Response:
{
"data": [
{
"id": 1,
"name": "My Project",
"description": "Project description",
"created_at": "2023-01-01T00:00:00Z",
"updated_at": "2023-01-01T00:00:00Z"
}
]
}POST /admin/projects
Content-Type: application/json
{
"name": "New Project",
"description": "Project description"
}
PUT /admin/projects/{id}
Content-Type: application/json
{
"name": "Updated Project",
"description": "Updated description"
}
DELETE /admin/projects/{id}
GET /admin/origins
Response:
{
"data": [
{
"id": 1,
"project_id": 1,
"domain": "example.com",
"prefix_path": "/media",
"project": {
"id": 1,
"name": "My Project"
}
}
]
}POST /admin/origins
Content-Type: application/json
{
"project_id": 1,
"domain": "example.com",
"prefix_path": "/media"
}
PUT /admin/origins/{id}
Content-Type: application/json
{
"domain": "updated-example.com",
"prefix_path": "/assets"
}
DELETE /admin/origins/{id}
GET /admin/storages
Response:
{
"data": [
{
"id": 1,
"project_id": 1,
"type": "local",
"priority": 1,
"path": "/var/media/storage"
},
{
"id": 2,
"project_id": 1,
"type": "s3",
"priority": 2,
"bucket": "my-media-bucket",
"region": "us-west-2"
}
]
}POST /admin/storages
Content-Type: application/json
{
"project_id": 1,
"type": "local",
"priority": 1,
"path": "/var/media/storage"
}
POST /admin/storages
Content-Type: application/json
{
"project_id": 1,
"type": "s3",
"priority": 2,
"bucket": "my-media-bucket",
"region": "us-west-2",
"access_key": "your-access-key",
"secret_key": "your-secret-key"
}
PUT /admin/storages/{id}
Content-Type: application/json
{
"priority": 3,
"path": "/new/media/path"
}
DELETE /admin/storages/{id}
GET /admin/video-profiles
Response:
{
"data": [
{
"id": 1,
"profile": "hd",
"width": 1280,
"height": 720,
"bitrate": "2000k",
"codec": "h264"
}
]
}POST /admin/video-profiles
Content-Type: application/json
{
"profile": "4k",
"width": 3840,
"height": 2160,
"bitrate": "8000k",
"codec": "h264"
}
PUT /admin/video-profiles/{id}
Content-Type: application/json
{
"bitrate": "10000k",
"codec": "h265"
}
DELETE /admin/video-profiles/{id}
All media requests are handled through the main domain routing:
GET /{path-to-media}?{processing-parameters}
w- Width in pixelsh- Height in pixelsf- Output formatq- Quality (1-100)
MediaX sets appropriate headers for caching and content delivery:
Content-Type: Correct MIME type for processed mediaCache-Control: Caching directivesX-Trace-ID: Request tracing ID (in debug mode)X-Debug-*: Debug information (when debug mode is enabled)
{
"error": "Invalid parameters",
"message": "Width must be a positive integer"
}{
"error": "Forbidden domain",
"message": "Domain not configured"
}{
"error": "File not found",
"message": "The requested file does not exist"
}{
"error": "Unsupported media type",
"message": "File format not supported"
}{
"error": "Processing failed",
"message": "Unable to process media file"
}Enable debug mode by adding the X-Debug: 1 header to requests:
curl -H "X-Debug: 1" http://localhost:8080/images/photo.jpg?w=800Debug response headers:
X-Debug-Host: Request hostX-Debug-Extension: Detected file extensionX-Debug-MediaType: Media type configurationX-Debug-Options: Processing optionsX-Debug-Error: Error details (if any)
The API implements rate limiting to prevent abuse:
- Default: 100 requests per minute per IP
- Burst: Up to 200 requests in a short period
- Headers: Rate limit information in response headers
Rate limit headers:
X-RateLimit-Limit: Requests allowed per windowX-RateLimit-Remaining: Requests remaining in current windowX-RateLimit-Reset: Time when the rate limit resets
MediaX implements intelligent caching:
- Processed files: Cached on disk for fast subsequent access
- Cache headers: Appropriate cache-control headers set
- ETags: Entity tags for efficient cache validation
- CDN friendly: Optimized for CDN integration
Cache-related headers:
Cache-Control: Caching directivesETag: Entity tag for cache validationLast-Modified: Last modification timeExpires: Expiration time
- Streaming: Large files are streamed for efficient delivery
- Compression: Automatic compression for supported formats
- Range requests: Support for partial content requests
- CORS: Cross-origin resource sharing support
const MediaX = require('mediax-client');
const client = new MediaX({
baseURL: 'https://your-domain.com',
apiKey: 'your-api-key'
});
// Process image
const imageUrl = client.image('/path/to/image.jpg')
.width(800)
.height(600)
.format('webp')
.quality(90)
.url();
// Process video
const videoUrl = client.video('/path/to/video.mp4')
.width(1280)
.height(720)
.format('webm')
.url();from mediax import MediaXClient
client = MediaXClient(
base_url='https://your-domain.com',
api_key='your-api-key'
)
# Process image
image_url = (client.image('/path/to/image.jpg')
.width(800)
.height(600)
.format('webp')
.quality(90)
.url())
# Process video
video_url = (client.video('/path/to/video.mp4')
.width(1280)
.height(720)
.format('webm')
.url())<?php
use MediaX\Client;
$client = new Client([
'base_url' => 'https://your-domain.com',
'api_key' => 'your-api-key'
]);
// Process image
$imageUrl = $client->image('/path/to/image.jpg')
->width(800)
->height(600)
->format('webp')
->quality(90)
->url();
// Process video
$videoUrl = $client->video('/path/to/video.mp4')
->width(1280)
->height(720)
->format('webm')
->url();
?>