Convert a value between units. $0.005 per request.
Converts a numeric value between units in the same category: length, mass, volume, area, speed, time, data size, or temperature.
| Method | POST |
|---|---|
| Path | /convert |
| Content-Type | application/json |
| field | required | description |
|---|---|---|
value | yes | Numeric value to convert |
from | yes | Source unit |
to | yes | Target unit (same category as 'from') |
length: mm, cm, m, km, in, ft, yd, mi mass: mg, g, kg, oz, lb, ton volume: ml, l, gal, qt, pt, cup, fl_oz
area: sqm, sqft, sqkm, acre, hectare speed: mps, kmh, mph, knot time: ms, s, min, hr, day, week
data: byte, kb, mb, gb, tb, kib, mib, gib temperature: c, f, k
curl -X POST https://unit-converter.pdfextractapi.workers.dev/convert \
-H "Content-Type: application/json" \
-d '{"value": 5, "from": "mi", "to": "km"}'
{ "value": 5, "from": "mi", "to": "km", "category": "length", "result": 8.04672 }
Errors return a non-200 status with { "error": { "code": "...", "message": "..." } }. Common codes: invalid_value, invalid_units, unknown_unit, mismatched_categories.
This endpoint is paid per-request via the x402 protocol (HTTP 402 + USDC). Unpaid requests receive a 402 response with payment instructions.