Complete guide to using the EmpireSphere API
All API requests require an API key passed in the header:
curl -H "x-api-key: YOUR_API_KEY" https://api.empiresphere.com/api/files
https://api.empiresphere.com/api
Upload one or multiple files to your storage.
/api/upload
curl -X POST \
-H "x-api-key: YOUR_API_KEY" \
-H "x-folder: my-folder" \
-F "files=@file1.pdf" \
-F "files=@file2.jpg" \
https://api.empiresphere.com/api/upload
{
"message": "Files uploaded and processed successfully",
"files": [
{
"id": "123e4567-e89b-12d3-a456-426614174000",
"name": "file1.pdf",
"path": "user123/my-folder/file1.pdf",
"type": "application/pdf",
"createdAt": "2024-03-21T12:00:00Z"
}
]
}
Retrieve a list of your files with pagination and filtering options.
/api/files
page - Page number (default: 1)limit - Items per page (default: 20)folder - Filter by folder namesearch - Search in file namestype - Filter by file type{
"files": [
{
"id": "123e4567-e89b-12d3-a456-426614174000",
"name": "document.pdf",
"path": "user123/default/document.pdf",
"type": "application/pdf",
"createdAt": "2024-03-21T12:00:00Z"
}
],
"pagination": {
"total": 50,
"pages": 3,
"currentPage": 1,
"perPage": 20
}
}
Delete a specific file by its ID.
/api/files/:fileId
curl -X DELETE \
-H "x-api-key: YOUR_API_KEY" \
https://api.empiresphere.com/api/files/123e4567-e89b-12d3-a456-426614174000
{
"message": "File deleted successfully"
}
Generate a sharing link for a file.
/api/files/:fileId/share
curl -X POST \
-H "x-api-key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"expiresIn": 24}' \
https://api.empiresphere.com/api/files/123e4567-e89b-12d3-a456-426614174000/share
{
"shareUrl": "https://api.empiresphere.com/api/share/abcdef123456",
"expiresAt": "2024-03-22T12:00:00Z"
}
The API uses conventional HTTP response codes to indicate success or failure of requests.
200 - Success201 - Created400 - Bad Request401 - Unauthorized404 - Not Found429 - Too Many Requests500 - Server ErrorThe API implements rate limiting to ensure fair usage:
npm install empiresphere-sdk
import { EmpireSphere } from 'empiresphere-sdk';
const client = new EmpireSphere('YOUR_API_KEY');
const files = await client.listFiles();
pip install empiresphere
from empiresphere import EmpireSphere
client = EmpireSphere('YOUR_API_KEY')
files = client.list_files()
API keys should be kept secure and never exposed in client-side code. Each key has specific permissions and can be revoked at any time from the dashboard.
All API requests must be made over HTTPS. Calls made over plain HTTP will fail.
All uploaded files are automatically scanned for viruses and malware. Infected files will be rejected.
Get notified about events in your account by configuring webhooks.
file.uploaded - When a new file is uploadedfile.deleted - When a file is deletedfile.shared - When a file is sharedshare.accessed - When a shared file is accessed{
"event": "file.uploaded",
"data": {
"fileId": "123e4567-e89b-12d3-a456-426614174000",
"name": "document.pdf",
"size": 1048576,
"type": "application/pdf",
"timestamp": "2024-03-21T12:00:00Z"
}
}
Always implement proper error handling in your applications. The API returns detailed error messages to help you debug issues.
Implement exponential backoff when dealing with rate limits. Monitor the rate limit headers to stay within limits.