files.davidxie.dev

API

Everything the site does can be done over HTTP. Responses are JSON. The examples use .

Authentication

Generate a token on Account and send it with every request:

Authorization: Bearer YOUR_TOKEN

A token can do anything your account can, including admin actions if you're an admin. Make a separate, named token for each device or app, so you can revoke one without breaking the others. Keep tokens out of web pages and public code.

Upload

POST /upload

A multipart/form-data body with up to 10 files in fields named files[]. Compatible with pomf and uguu clients.

curl -H "Authorization: Bearer YOUR_TOKEN" \
  -F "files[]=@photo.png" -F "files[]=@notes.txt" \
  "/upload?expires=24"
{
  "success": true,
  "files": [
    {
      "filename": "k3x9a1bq.png",
      "name": "photo.png",
      "size": 48213,
      "hash": "2fd4e1c6…",
      "url": "https://f.davidxie.dev/k3x9a1bq.png",
      "expires": 1793708415000
    }
  ]
}

expires is a Unix time in milliseconds, or null for files that never expire. If any file in a request fails, none of them are kept, and the response is {"success": false, "errorcode": 413, "description": "…"}.

Your account

GET /api/me

Your username, whether you're an admin, and your limits: maxBytes, defaultHours, maxHours and the expiryOptions you can pick from. Hours can be "never".

GET /api/me/tokens

Your tokens: id, name, created and lastUsed. The tokens themselves are never shown again.

POST /api/me/tokens

Make a token: {"name": "ShareX laptop"}. The response includes token, the only time you'll see it.

DELETE /api/me/tokens/{id}

Revoke one token.

Your files

GET /api/uploads

Your files, newest first: key, name, size, url, created and expires. The owner can add ?all=1 for everyone's, or ?user=name for one person's.

GET /api/uploads/{key}

One file. key is the file's name in its link, like k3x9a1bq.png.

PATCH /api/uploads/{key}

Change how long a file lasts, counted from now, within your limits.

curl -X PATCH -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" -d '{"expires": "never"}' \
  /api/uploads/k3x9a1bq.png

DELETE /api/uploads/{key}

Delete a file. Its link stops working straight away.

Errors

Failed requests return {"error": "…"} with a status code:

Hosting HTML

Files are served from a separate domain from this site, so uploaded HTML pages work fully, scripts included, while having no access to your account. Every file gets its own random name, so a page works best as a single file with its CSS and JavaScript inline, or linking to other uploads by their full URLs. Set expires=never to keep a page up.

Admin and owner

Admins can use:

Anyone with a code can sign up with POST /api/signup {"code", "username", "password"}, which also logs them in.

Everything that touches other people's accounts or files is for the owner only:

ShareX

Account has a button that downloads a ready-made ShareX config with your token filled in.