API
Convert images to SVG from your own code. Same engine as the website, one endpoint.
Quick start
1. Create a free account, confirm your email, and make an API key on your account page.
2. Send an image to POST /api/v1/convert with the key in the Authorization header.
curl https://pix2path.app/api/v1/convert \
-H "Authorization: Bearer $P2P_KEY" \
-F image=@photo.jpg \
-F format=svg \
-o photo.svg
Authentication
Every request needs an API key, sent as Authorization: Bearer p2p_… (or X-API-Key: p2p_…). Keys belong to your account; you can have up to five and revoke any of them at any time. Keep keys on your server: don't put them in web pages or apps that other people download.
Convert an image
POST https://pix2path.app/api/v1/convert
Send the image in either of two ways:
- Form upload:
multipart/form-datawith the file in a field namedimage. Options can be extra form fields. - Raw bytes: the image file as the request body, with
Content-Type: image/png(or the matching image type). Options go in the query string.
Accepted formats: PNG, JPEG, WebP, BMP, GIF (first frame) and TIFF, up to 40 MB and 40 megapixels.
Options
| Name | Values | What it does |
|---|---|---|
format | svg · json (default) | svg returns the bare SVG file. json returns the SVG plus details. Sending Accept: image/svg+xml also selects svg. |
detail | low · medium (default) · high · max | How many shapes to use. More detail follows the image more closely and makes a larger file. |
content | auto (default) · photo · graphic | graphic is tuned for logos, text, documents and diagrams (exact colours, crisp lettering). auto picks for you. |
gradients | 1 (default) · 0 | Smooth colour ramps as SVG gradients. Turn off for flat fills only. |
seams | 1 (default) · 0 | Hairline strokes that hide anti-aliasing gaps between touching shapes. Turn off for cutters and plotters. |
max_side | 64–2560 (default 2560) | Larger images are processed at this size; the SVG keeps the original dimensions. Smaller images are always processed at their full size. 0 means the default. |
Responses
format=svg
200 with Content-Type: image/svg+xml. Details are in headers: X-P2P-Width, X-P2P-Height, X-P2P-Shapes, X-P2P-Ms and X-P2P-Content (photo or graphic).
format=json
{
"svg": "<svg xmlns=…>…</svg>",
"width": 1600, "height": 900, // image size in px
"bytes": 128406, // SVG size
"ms": 1840, // conversion time
"info": { "paths": 912, "ellipses": 24, "gradients": 0, "content": "graphic" },
"options": { "detail": "medium", "content": "auto" }
}
Every response carries X-RateLimit-Quota and X-RateLimit-Used with your monthly allowance and how much of it you've used, plus RateLimit-Limit, RateLimit-Remaining and RateLimit-Reset (seconds) for the per-minute limit.
Errors
Errors are JSON: {"error": "message"}.
| Status | Meaning |
|---|---|
400 | Missing image or a bad option value. |
401 | Missing, invalid or revoked API key. |
413 | The file is larger than 40 MB. |
415 | The file isn't an image we can read. |
422 | The image was read but could not be converted. Try another content setting. |
429 | Per-minute rate limit or monthly quota reached. Wait for Retry-After seconds. |
503 | The converter is busy or starting. Retry after a few seconds. |
Limits
- 500 conversions per calendar month (UTC) per account. Failed requests don't count.
- 60 requests per minute per key.
- 40 MB and 40 megapixels per image. Larger images get
413. - Most images take 1–4 seconds. Set your HTTP timeout to at least 60 seconds.
Need more? Contact us and we'll raise your limits.
Python client
A one-file client with no dependencies (Python 3.8+). It handles uploads, retries while the converter starts, and errors.
curl -O https://pix2path.app/static/clients/pix2path_client.py
export P2P_KEY=p2p_your_key
from pix2path_client import Pix2Path
p2p = Pix2Path() # reads P2P_KEY, or Pix2Path("p2p_...")
p2p.convert_file("logo.png", "logo.svg", detail="high")
svg = p2p.convert("diagram.png", content="graphic") # SVG as a string
info = p2p.convert("photo.jpg", format="json") # dict: svg, width, height, info, ms
print(p2p.last["X-RateLimit-Used"], "of", p2p.last["X-RateLimit-Quota"], "used this month")
# a whole folder
import glob
for path in glob.glob("images/*.png"):
p2p.convert_file(path)
It also works from the command line: python pix2path_client.py input.png output.svg --detail high.
Examples
Python with requests
import os, requests
with open("logo.png", "rb") as f:
r = requests.post(
"https://pix2path.app/api/v1/convert",
headers={"Authorization": f"Bearer {os.environ['P2P_KEY']}"},
files={"image": f},
data={"detail": "high", "format": "svg"},
timeout=120,
)
r.raise_for_status()
open("logo.svg", "w", encoding="utf-8").write(r.text)
JavaScript (Node 18+)
import { readFile, writeFile } from "node:fs/promises";
const form = new FormData();
form.append("image", new Blob([await readFile("logo.png")]), "logo.png");
form.append("format", "json");
const res = await fetch("https://pix2path.app/api/v1/convert", {
method: "POST",
headers: { Authorization: `Bearer ${process.env.P2P_KEY}` },
body: form,
});
const out = await res.json();
if (!res.ok) throw new Error(out.error);
await writeFile("logo.svg", out.svg);
console.log(out.width, out.height, out.info.paths, "shapes");
Raw bytes with curl
curl "https://pix2path.app/api/v1/convert?detail=high&format=svg" \
-H "Authorization: Bearer $P2P_KEY" \
-H "Content-Type: image/png" \
--data-binary @diagram.png \
-o diagram.svg
Health check
GET /api/v1/status returns {"ok": true, "ready": true}. It needs no key.
Data handling
Images are converted in memory and discarded when the response is sent. We never store images or SVGs, and we don't log their contents. See Privacy.