API Documentation

Comprehensive documentation for PicOptimize API endpoints, including authentication, rate limits, request/response examples, and integration guides.

API Endpoints

POST /api/compress

Public

Endpoint Details

  • Description: Image compression and WebP conversion endpoint
  • Method: POST
  • Authentication: None (public endpoint)
  • Rate Limit: 60 requests per minute per IP

Request Format (multipart/form-data)

  • files: Array of image files (PNG, JPG, WebP)
  • options: JSON string with compression settings

Request Options

{
  "quality": 0.8,
  "resize": {
    "width": 1200,
    "height": 800
  },
  "format": "webp"
}

Example Request (cURL)

curl -X POST https://picoptimize.com/api/compress \
  -F "[email protected]" \
  -F "[email protected]" \
  -F 'options={"quality": 0.8, "resize": {"width": 1200}}'

Example Response (Success)

{
  "success": true,
  "compressedFiles": [
    "https://picoptimize.com/compressed/image1.webp",
    "https://picoptimize.com/compressed/image2.webp"
  ],
  "processingTimeMs": 850,
  "originalSize": "2.4 MB",
  "compressedSize": "380 KB",
  "savingsPercent": 84
}

Error Responses

  • 400 Bad Request: Invalid file types or missing parameters
  • 413 Payload Too Large: Files exceeding size limits (max 50MB/file)
  • 500 Internal Server Error: Server-side compression failure
  • 501 Not Implemented: Server-side compression not available (current state)

Planned Public API Features

PicOptimize Pro and Team tiers will include additional public API endpoints for programmatic access to advanced features:

POST /api/v1/compress/batch

Batch compression of multiple images with synchronized processing

POST /api/v1/compress/url

Compress images from external URLs without downloading

POST /api/v1/compress/optimize

Advanced optimization with preset quality profiles

GET /api/v1/compress/presets

Retrieve available compression presets (web, mobile, print)

GET /api/v1/compress/metadata

Extract image metadata (dimensions, color profile, EXIF)

GET /api/v1/account/usage

Monitor API usage and quota for Pro/Team accounts

Integration Guides

Quick start guides for popular frameworks and platforms:

Next.js

Server-side rendering with edge functions for preprocessing

View Guide

React

Client-side implementation with file upload components

View Guide

Node.js

Server-to-server image processing with streaming

View Guide

Python

Flask/FastAPI integration for batch processing workflows

View Guide

WordPress

Plugin architecture with shortcode embedding

View Guide

Vanilla JS

Lightweight browser implementation with fetch API

View Guide

Authentication

Public Endpoints (Current)

The current /api/compress endpoint is publicly accessible without authentication. This allows anyone to use the compression service directly from their applications.

Pro/Team API Keys (Planned)

Paid tiers will include API key authentication for higher rate limits and advanced features:

  • API keys generated in dashboard (one per project)
  • Bearer token authentication: Authorization: Bearer pk_live_...
  • Rate limits: Free (60/min), Pro (600/min), Team (3000/min)
  • Webhook support for async batch processing notifications

API Versioning

The API follows semantic versioning. Breaking changes will be introduced in major version updates and communicated via deprecation notices. Minor updates maintain backward compatibility.

  • Current version: v1 (in URL path: /api/v1/...)
  • Legacy endpoint: /api/compress (redirects to v1)
  • Deprecation notice: 90 days before breaking changes
  • Changelog available at /api/changelog

Ready to Integrate?

Start compressing images programmatically with PicOptimize API. Free tier includes 60 requests/minute.

Try Compression Tool
Last updated: October 2024