PixShift

Developer Reference

API Reference

Everything you need to integrate PixShift image processing into your application.

Quick Start

Get your first API call working in under 5 minutes.

  1. 1Register at pixshift.com/register
  2. 2Log in → go to API Keys → create a key → copy it immediately. It is shown once only.
  3. 3Make your first call — convert a PNG to WebP:
  4. 4Check your usage at the dashboard.
curl -X POST https://pixshift.com/api/v1/convert \
  -H "X-API-Key: YOUR_API_KEY" \
  -F "file=@/path/to/image.png" \
  -F "target_format=webp" \
  --output converted.webp

Overview

The PixShift API converts, compresses, and resizes images via simple HTTP requests. Send a file, get a file back. No SDKs required.

Base URLhttps://pixshift.com/api/v1
Current versionv1 — included in the URL path
Request formatmultipart/form-data for all image endpoints
Success response{ "success": true, "data": { … } }
Error response{ "success": false, "error": { "message": "…", "code": "…" } }
Image responseBinary image body with Content-Type header — not JSON

Breaking changes will increment the version to v2. The v1 endpoint will remain available with advance notice before any deprecation.

Authentication

Image endpoints use API key authentication. Create a key in your dashboard, then include it in every request:

X-API-Key: pxs_live_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

Key format: pxs_live_ prefix followed by 32 random hex characters.

Security rules: Store the key in an environment variable, never in source code. The raw key is shown once at creation — if lost, revoke it and create a new one. If a key is compromised, revoke it immediately from the dashboard.

Limits

Max file size4 MB
Accepted input formatsJPEG, PNG, WebP, AVIF, GIF
Accepted output formatsJPEG, PNG, WebP, AVIF
GIF as outputNot supported — GIF can only be used as input

Format is detected from the file's content (magic bytes), not the file extension. Renaming a JPEG to .png will not change how it is processed.

POST/api/v1/convert

Convert an image from one format to another. Supports JPEG, PNG, WebP, AVIF, and GIF as input; JPEG, PNG, WebP, and AVIF as output.

Auth:X-API-Key header

Request — multipart/form-data

FieldTypeRequiredDescription
fileFileYesThe image to convert. Max 4 MB.
target_formatstringYesOutput format. One of: png, jpg, webp, avif.

Response

Binary image. Content-Type is set to the target format's MIME type.

png → image/png · jpg → image/jpeg · webp → image/webp · avif → image/avif

curl -X POST https://pixshift.com/api/v1/convert \
  -H "X-API-Key: YOUR_API_KEY" \
  -F "file=@/path/to/image.png" \
  -F "target_format=webp" \
  --output converted.webp

Errors

CodeHTTPMeaning
UNAUTHORIZED401Missing or invalid API key
VALIDATION_ERROR400file or target_format missing, invalid target_format value, or request is not multipart/form-data
FILE_TOO_LARGE413File exceeds 4 MB
UNSUPPORTED_MEDIA_TYPE415File content not recognised as a supported format
INTERNAL_ERROR500Conversion failed on the server
POST/api/v1/compress

Compress an image to reduce file size. Output stays in the same format as the input — only file size changes, not the format.

Auth:X-API-Key header

Request — multipart/form-data

FieldTypeRequiredDescription
fileFileYesThe image to compress. Max 4 MB.
qualityintegerYes1 (smallest file) to 100 (best quality). Recommended: 75–85.

Response

Binary image in the same format as the input. Content-Type matches the input MIME type.

curl -X POST https://pixshift.com/api/v1/compress \
  -H "X-API-Key: YOUR_API_KEY" \
  -F "file=@/path/to/photo.jpg" \
  -F "quality=80" \
  --output compressed.jpg

Errors

CodeHTTPMeaning
UNAUTHORIZED401Missing or invalid API key
VALIDATION_ERROR400file or quality missing, or quality not in range 1–100
FILE_TOO_LARGE413File exceeds 4 MB
UNSUPPORTED_MEDIA_TYPE415File content not recognised as a supported format
INTERNAL_ERROR500Compression failed on the server
POST/api/v1/resize

Resize an image to specific dimensions. Output stays in the same format as the input.

Auth:X-API-Key header

Request — multipart/form-data

FieldTypeRequiredDefaultDescription
fileFileYesThe image to resize. Max 4 MB.
widthintegerYesTarget width in pixels. Range: 1–5000.
heightintegerYesTarget height in pixels. Range: 1–5000.
keep_aspect_ratio"true" | "false"No"true"When true, image is fit within the box without distortion.
Aspect ratio behaviour: When keep_aspect_ratio is true (the default), the image is scaled to fit within the specified box without distortion. Example: a 1000×500 image resized to 400×400 produces 400×200 — width fills the box, height scales proportionally. When false, the image is stretched to exactly the requested dimensions.

Response

Binary image in the same format as the input. Content-Type matches the input MIME type.

curl -X POST https://pixshift.com/api/v1/resize \
  -H "X-API-Key: YOUR_API_KEY" \
  -F "file=@/path/to/image.png" \
  -F "width=800" \
  -F "height=600" \
  -F "keep_aspect_ratio=true" \
  --output resized.png

Errors

CodeHTTPMeaning
UNAUTHORIZED401Missing or invalid API key
VALIDATION_ERROR400file, width, or height missing; dimensions outside 1–5000
FILE_TOO_LARGE413File exceeds 4 MB
UNSUPPORTED_MEDIA_TYPE415File content not recognised as a supported format
INTERNAL_ERROR500Resize failed on the server

Error Reference

Every error response shares the same shape, regardless of which endpoint returned it.

{
  "success": false,
  "error": {
    "message": "Human-readable explanation",
    "code": "MACHINE_READABLE_CODE"
  }
}
CodeHTTPMeaning
VALIDATION_ERROR400A required field is missing, a value is out of range, or the request body is malformed
UNAUTHORIZED401No API key in the header, or the key is invalid or revoked
FORBIDDEN403Authenticated but not permitted to access this resource
NOT_FOUND404The requested resource does not exist
CONFLICT409Resource already exists
FILE_TOO_LARGE413File exceeds the 4 MB limit
UNSUPPORTED_MEDIA_TYPE415File type not accepted — see Limits section for supported formats
RATE_LIMITED429Reserved for future rate limiting — not currently triggered
INTERNAL_ERROR500Something went wrong on the server — try again or contact support

Common Mistakes

  1. 1

    Setting Content-Type manually

    Do not set the Content-Type header yourself when sending multipart/form-data. The browser and fetch set it automatically with the required boundary value. Setting it manually breaks the request.

  2. 2

    Parsing the response as JSON

    Image endpoints return a binary image body, not JSON. Read the response with .blob() in JavaScript or res.content in Python — not .json().

  3. 3

    Trusting the file extension

    The API detects format from the file's bytes, not the name. A file called image.png that contains JPEG data is treated as JPEG.

  4. 4

    Losing the API key

    The raw key is shown once, at creation. If it is not saved immediately, it cannot be recovered. Revoke it and create a new one.