My App

File API

Complete guide to uploading and managing media files via REST API

Authentication

All API requests require authentication via the Authorization header with your API token:

Authorization: YOUR_API_TOKEN

Alternatively, you can pass your API key as a query parameter (useful for browser uploads):

GET /api/v2/image?apiKey=YOUR_API_TOKEN

Upload Endpoints

Images

POST https://fmapi.net/api/v2/image

Audio

POST https://fmapi.net/api/v2/audio

Videos

POST https://fmapi.net/api/v2/video

Upload Media

Submit a form-data request with your media file and optional metadata.

const formData = new FormData();
formData.append('file', yourFile); // File, Blob, or stream
formData.append('metadata', JSON.stringify({
    name: 'My Upload',
    description: 'Custom description',
    // Any other custom fields
}));

const response = await fetch('https://fmapi.net/api/v2/image', {
    method: 'POST',
    headers: {
        'Authorization': 'YOUR_API_TOKEN'
    },
    body: formData
});

const result = await response.json();
console.log(result.url);
curl -X POST https://fmapi.net/api/v2/image \
  -H "Authorization: YOUR_API_TOKEN" \
  -F "file=@path/to/your/file.jpg" \
  -F 'metadata={"name":"My Upload","description":"Custom description"}'
exports['screenshot-basic']:requestScreenshotUpload(
    'https://fmapi.net/api/v2/image',
    'file',
    {
        headers = {
            Authorization = "YOUR_API_TOKEN"
        }
    },
    function(data)
        local resp = json.decode(data)
        if resp then
            print('Upload URL:', resp.url)
        end
    end
)

Request Body

FieldTypeRequiredDescription
fileFile/BlobYesThe media file to upload
metadataJSON StringNoAdditional metadata object

Response

{
  "id": "7F9pGhN8qwErT1vx5aZk",
  "url": "https://i.fmfile.com/6E9pGhN8qwErT1vx5aZk/7F9pGhN8qwErT1vx5aZk.webp"
}

Delete Media

Remove uploaded files by sending a DELETE request with the file ID.

Endpoints

  • Images: DELETE https://fmapi.net/api/image/delete/{id}
  • Audio: DELETE https://fmapi.net/api/audio/delete/{id}
  • Videos: DELETE https://fmapi.net/api/video/delete/{id}
const response = await fetch('https://fmapi.net/api/image/delete/YOUR_FILE_ID', {
    method: 'DELETE',
    headers: {
        'Authorization': 'YOUR_API_TOKEN'
    }
});

const result = await response.json();
console.log('Deleted:', result.message);
curl -X DELETE https://fmapi.net/api/image/delete/YOUR_FILE_ID \
  -H "Authorization: YOUR_API_TOKEN"

File Limits & Formats

  • File Size Limit: 32MB for all file types
  • Supported Formats:
    • Images: PNG, APNG, WebP, JPEG, GIF
    • Audio: MP3, MPEG, OGG, WebM, WAV
    • Video: OGG, MP4, MPEG, WebM, QuickTime (MOV), Matroska (MKV)

Optimization Tips

  • Compress media files before upload to reduce transfer time
  • Use appropriate file formats (WebP for images, MP4 for videos)
  • Implement client-side validation for file types and sizes
  • Use presigned URLs for direct client uploads when possible