API Documentation

Everything you need to integrate MicroTools into your application.

Overview

MicroTools provides three developer APIs — webpage screenshots, HTML-to-PDF conversion, and image optimization — through a single, consistent interface. All endpoints are available at:

https://batian.icu/api/v1/
📸
Screenshot
URL → PNG/JPEG
📄
HTML → PDF
URL/HTML → PDF
🖼️
Image Optimize
Resize & Convert

Authentication

All API requests require an API key passed in the Authorization header as a Bearer token.

Authorization: Bearer mt_your_api_key_here

Get your free API key at batian.icu/dashboard.

Error Handling

All errors return a consistent JSON structure:

{
  "error": "error_code",
  "message": "Human-readable description of what went wrong."
}
CodeErrorMeaning
400url_required, invalid_url, image_requiredBad request — check your parameters
401missing_api_key, invalid_api_keyMissing or invalid API key
403forbiddenInternal/private URLs are blocked
429usage_limit_exceeded, rate_limitedLimit exceeded — upgrade plan or wait
500screenshot_failed, pdf_failed, image_failedServer error — retry or contact support
504screenshot_timeout, pdf_timeoutTarget page took too long to load

Rate Limits & Headers

60 requests per minute. Usage is tracked per API key per calendar month. Response headers include:

HeaderDescription
X-Usage-RemainingRequests remaining this month
X-Request-IdUnique request identifier
X-Savings-Percent(Image API only) Compression savings %

API Endpoints

POST /api/v1/screenshot

Capture a screenshot of any webpage. Returns the image binary directly.

Parameters (JSON body)

FieldTypeDefaultDescription
url *stringURL of the page to screenshot
widthinteger1280Viewport width (max 2560)
heightinteger800Viewport height (max 2048)
full_pagebooleanfalseCapture the entire scrollable page
formatstringpngOutput format: png or jpeg
curl -X POST https://batian.icu/api/v1/screenshot \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"url":"https://example.com","width":1280,"full_page":true}' \
  -o screenshot.png
POST /api/v1/pdf

Convert a URL or raw HTML string into a PDF document.

FieldTypeDefaultDescription
urlstringURL to convert (use url OR html)
htmlstringRaw HTML to convert (use url OR html)
formatstringA4Page size: A4, Letter, Legal, Tabloid
marginstring10mmPage margin (CSS value)
curl -X POST https://batian.icu/api/v1/pdf \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"html":"

Invoice

Amount: $500

","format":"A4","margin":"10mm"}' \ -o document.pdf
POST /api/v1/image

Optimize, resize, and convert images. Upload a file or pass an image URL. Supports WebP, AVIF, JPEG, PNG.

FieldTypeDescription
filefile (multipart)Image file to upload (max 10MB)
urlstringURL of image to optimize (use instead of file)
widthintegerResize to width (preserves aspect ratio)
heightintegerResize to height (preserves aspect ratio)
formatstringConvert to: webp, avif, jpeg, png
qualityintegerQuality 1-100 (default 80)
# File upload
curl -X POST https://batian.icu/api/v1/image \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -F "file=@photo.jpg" \
  -F "width=800" \
  -F "format=webp" \
  -F "quality=85" \
  -o optimized.webp

# URL mode
curl -X POST https://batian.icu/api/v1/image \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"url":"https://example.com/photo.jpg","width":800,"format":"webp"}' \
  -o optimized.webp
GET /api/v1/usage

Get your current monthly usage and plan information.

curl https://batian.icu/api/v1/usage \
  -H "Authorization: Bearer YOUR_API_KEY"

# Response:
# {"plan":"pro","usage_this_month":342,"limit":10000,"remaining":9658,"by_endpoint":[...]}

Account Endpoints

POST/api/auth/register
curl -X POST https://batian.icu/api/auth/register \
  -H "Content-Type: application/json" \
  -d '{"email":"you@example.com","password":"your_password_min_8_chars"}'

# Response: {"api_key":"mt_...","plan":"free","token":"..."}
POST/api/auth/login
curl -X POST https://batian.icu/api/auth/login \
  -H "Content-Type: application/json" \
  -d '{"email":"you@example.com","password":"your_password"}'

# Response: {"api_key":"mt_...","plan":"pro","token":"..."}