xtract.bot
POST /api/mime-detect

Identify a file by its magic-byte signature. Returns the MIME type and canonical extension. Recognises common image / audio / video / archive / document formats.

Examines the first bytes of the input and returns the detected MIME type and canonical file extension. Recognises ~150 common formats: images (PNG / JPEG / WebP / AVIF / HEIC / GIF / TIFF / BMP / ICO / SVG), audio (MP3 / WAV / FLAC / OGG / M4A), video (MP4 / WebM / MOV / MKV), archives (ZIP / GZ / ZSTD / TAR / 7Z / RAR), documents (PDF / DOC / DOCX / XLS / XLSX / PPTX), fonts (TTF / OTF / WOFF / WOFF2), and more. Useful when you receive a file from an untrusted source and need to confirm it really is what its filename or Content-Type header claims.

Inputs

NameTypeDefaultDescription
data*fileFile bytes (any format).

Response

Modes: json. Cache: yes (24h TTL).

Code samples

Built from the jpeg-fixture example.

# Download or substitute the example input:
#   curl -O https://xtract.bot/examples/image-resize-jpeg/sample.jpg
DATA=$(base64 -w0 < sample.jpg)

curl -X POST https://api.xtract.bot/api/mime-detect \
  -H "Content-Type: application/json" \
  -H "Accept: application/json" \
  -H "X-Account-Id: $XTRACT_ACCOUNT_ID" \
  -H "X-Api-Key: $XTRACT_API_KEY" \
  -d '{
  "data": "'"$DATA"'"
}'