Skip to main content

API overview

TorrentPier provides a REST API for programmatic access to tracker functionality.

Work in progress

The API is under active development. Endpoints and response formats may change.

Base URL

All API endpoints are prefixed with /api/:

https://your-domain.com/api/

Authentication

The API supports multiple authentication methods:

Session-based authentication (web)

For web applications using the same domain, authentication is handled via built-in session management.

Token-based authentication (API)

For external applications or scripts, use API tokens:

curl -X POST https://your-domain.com/api/login \
-H "Content-Type: application/json" \
-d '{"username": "user", "password": "password"}'

Include the token in subsequent requests:

Authorization: Bearer your-token-here

Response format

All API responses follow a consistent JSON format:

Success response

{
"success": true,
"data": {
"id": 1,
"title": "Example"
}
}

Collection response

{
"success": true,
"data": [
{"id": 1, "title": "Example 1"},
{"id": 2, "title": "Example 2"}
],
"meta": {
"current_page": 1,
"per_page": 50,
"total": 500,
"total_pages": 10
}
}

Error response

{
"success": false,
"error": {
"code": "VALIDATION_ERROR",
"message": "Validation failed",
"details": {
"title": ["The title field is required."]
}
}
}

HTTP status codes

CodeDescription
200OK — request successful
201Created — resource created successfully
204No Content — resource deleted successfully
400Bad Request — invalid request data
401Unauthorized — authentication required
403Forbidden — insufficient permissions
404Not Found — resource not found
422Unprocessable Entity — validation failed
429Too Many Requests — rate limit exceeded
500Internal Server Error — server error

Rate limiting

API requests are rate-limited to prevent abuse:

  • Authenticated users: 60 requests per minute
  • Unauthenticated users: 20 requests per minute

Rate limit headers are included in responses:

X-RateLimit-Limit: 60
X-RateLimit-Remaining: 59
X-RateLimit-Reset: 1640995200

Pagination

List endpoints support pagination using query parameters:

ParameterDefaultMaxDescription
page1Page number
per_page50100Items per page

Example:

GET /api/torrents?page=2&per_page=25

Filtering and sorting

Many endpoints support filtering and sorting:

Query parameters

  • search — text search across relevant fields
  • sort — field to sort by
  • order — sort direction (asc or desc)

Example:

GET /api/torrents?search=linux&sort=created_at&order=desc

Versioning

The current API version is v1. Future versions will be available at:

/api/v2/endpoint

Breaking changes will always result in a new API version.