Media Library - v1.1.0
API Overview
The Media Library provides a comprehensive REST API for managing media, folders, and tags programmatically. All endpoints require authentication via Laravel Sanctum.
Base URL
/api/media
Authentication
All API endpoints require authentication using Laravel Sanctum:
GET /api/media HTTP/1.1
Host: your-domain.com
Authorization: Bearer YOUR_TOKEN_HERE
Accept: application/json
See Authentication for details on obtaining and using tokens.
Endpoints Overview
Media Endpoints
GET /api/media- List all media (paginated)POST /api/media- Upload new mediaGET /api/media/{id}- Get specific mediaPUT /api/media/{id}- Update media metadataDELETE /api/media/{id}- Delete media
Folder Endpoints
GET /api/media/folders- List all foldersPOST /api/media/folders- Create folderGET /api/media/folders/{id}- Get specific folderPUT /api/media/folders/{id}- Update folderDELETE /api/media/folders/{id}- Delete folderPOST /api/media/folders/{id}/move- Move folder
Tag Endpoints
GET /api/media/tags- List all tagsPOST /api/media/tags- Create tagGET /api/media/tags/{id}- Get specific tagPUT /api/media/tags/{id}- Update tagDELETE /api/media/tags/{id}- Delete tagPOST /api/media/tags/{id}/attach- Attach tag to mediaPOST /api/media/tags/{id}/detach- Detach tag from media
Response Format
All API responses follow a consistent JSON structure:
Success Response
{
"data": {
"id": 1,
"title": "Example Media",
"file_name": "example.jpg",
...
}
}
Collection Response
{
"data": [
{ "id": 1, ... },
{ "id": 2, ... }
],
"links": {
"first": "...",
"last": "...",
"prev": null,
"next": "..."
},
"meta": {
"current_page": 1,
"from": 1,
"last_page": 5,
"per_page": 15,
"to": 15,
"total": 73
}
}
Error Response
{
"message": "The given data was invalid.",
"errors": {
"field": [
"The field is required."
]
}
}
Rate Limiting
API endpoints are rate-limited to prevent abuse:
- 60 requests per minute for authenticated users
- 30 requests per minute for guest users (where applicable)
Rate limit headers are included in responses:
X-RateLimit-Limit: 60
X-RateLimit-Remaining: 59
X-RateLimit-Reset: 1640000000
Pagination
List endpoints support pagination with these parameters:
per_page- Items per page (default: 15, max: 100)page- Page number (default: 1)
Example:
GET /api/media?per_page=20&page=2
Filtering & Sorting
Many endpoints support filtering and sorting. See Endpoints Reference for details.
Next Steps
- Review Endpoints Reference for detailed API documentation
- Learn about Authentication
- See example implementations in Integration Guide