๐Ÿ”‘ API & API Key

JSON endpoints for listing, uploading, and deleting images.

๐Ÿ›ก๏ธAuthentication Options

  • Session: Login at /login in your browser, then call APIs.
  • API Key: Send header X-API-Key: <YOUR_KEY> with requests.

โš™๏ธSet or Change API Key

  1. Login at /login with your credentials.
  2. Open /settings/api-key (Settings โ†’ API Key).
  3. Enter a new key (8+ characters) and Save. It is stored in .env as API_KEY=....
Tip: You can also set API_KEY directly in your .env file.

๐Ÿ“ฅList Images

GET /api/images

Query params: category (optional), name (contains), ext (png|jpg|jpeg|gif|webp), offset (0), limit (100)

curl -H "X-API-Key: <YOUR_KEY>" "http://127.0.0.1:8000/api/images"

Response:

{
  "count": 2,
  "items": [
    {"category": "Inventory", "filename": "image.jpg", "url": "/media_storage/Inventory/image.jpg", "size": 12345, "modified": 1732380234.0}
  ]
}

โฌ†๏ธUpload Image

POST /api/images

Form-data: file (binary), category (existing)

curl -H "X-API-Key: <YOUR_KEY>" -F "category=Inventory" -F "file=@C:\\path\\to\\image.jpg" http://127.0.0.1:8000/api/images

Response:

{"category":"Inventory","filename":"image.jpg","url":"http://127.0.0.1:8000/media_storage/Inventory/image.jpg"}

๐Ÿ—‘๏ธDelete Image

DELETE /api/images/{category}/{filename}

curl -H "X-API-Key: <YOUR_KEY>" -X DELETE "http://127.0.0.1:8000/api/images/Inventory/image.jpg"

Response: 204 No Content on success.

๐Ÿ”’Security Tips

  • Use long, random API keys and rotate them if exposed.
  • Prefer HTTPS when exposing your server on a network.
  • Restrict access to the server to trusted clients only.

๐ŸŽฎFiveM screenshot-basic Integration

The citizenfx/screenshot-basic resource can upload client screenshots directly to this server. Since it canโ€™t send custom headers, use the query param key with your API key.

Endpoint: POST /api/screenshot-upload?category=Inventory&key=YOUR_KEY

  • Multipart field name: any (e.g. file, files[]) โ€” the server detects the first file.
  • Category: via query (category) or form field category. Defaults to Uncategorized.
  • Auto-creates the category folder if it doesnโ€™t exist.

Client example (Lua):

-- fxmanifest includes 'screenshot-basic' as a dependency
    

Expected response:

{"category":"Inventory","filename":"screenshot_1.jpg","url":"/media_storage/Inventory/screenshot_1.jpg"}