Media Library - v1.0-beta1
API
The Media Library provides a comprehensive REST API for managing media, folders, and tags programmatically. All endpoints require authentication via Laravel Sanctum.
API Documentation
API Overview
Introduction to the REST API:
- Base URL and endpoints
- Authentication requirements
- Response format (success, collections, errors)
- Rate limiting
- Pagination
- Filtering and sorting
Endpoints Reference
Complete reference for all API endpoints:
Media Endpoints:
GET /api/media- List media with filteringPOST /api/media- Upload new mediaGET /api/media/{id}- Get specific mediaPUT /api/media/{id}- Update metadataDELETE /api/media/{id}- Delete media
Folder Endpoints:
GET /api/media/folders- List foldersPOST /api/media/folders- Create folderGET /api/media/folders/{id}- Get 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 tagsPOST /api/media/tags- Create tagPUT /api/media/tags/{id}- Update tagDELETE /api/media/tags/{id}- Delete tagPOST /api/media/tags/{id}/attach- Attach to mediaPOST /api/media/tags/{id}/detach- Detach from media
Authentication
API authentication with Laravel Sanctum:
- Generating tokens
- Using tokens in requests
- Token abilities and permissions
- Revoking tokens
- Configuration
Quick Example
Upload via API
curl -X POST "https://example.com/api/media" \
-H "Authorization: Bearer YOUR_TOKEN" \
-F "file=@/path/to/image.jpg" \
-F "title=Product Photo" \
-F "folder_id=1"
List Media
curl -X GET "https://example.com/api/media?type=image&per_page=20" \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Accept: application/json"
Response Format
{
"data": [
{
"id": 1,
"title": "Product Photo",
"file_name": "product.jpg",
"url": "https://example.com/storage/media/product.jpg",
"thumbnail_url": "https://example.com/storage/media/product-thumbnail.jpg"
}
],
"meta": {
"current_page": 1,
"total": 73
}
}
Rate Limits
- 60 requests per minute for authenticated users
- 30 requests per minute for guests
Next Steps
- Review Authentication setup
- See complete Endpoints Reference
- Learn about Helper Functions for PHP usage