UnifyUnits Developers
POST /v1/unit-price Requires API key

Compare offers by price per unit

Compares two to fifty offers by price per unit of measure. Quantities are written as people write them (`750 ml`, `6 x 330 ml`, `1 lb 4 oz`) and read with the same rules as Normalize. All offers must measure the same kind of thing. Prices are decimal strings in one currency of your choice; no currency conversion happens. Returns each offer's price per unit, its rank (1 is cheapest, ties share a rank), and how much more it costs than the cheapest offer. Requires the Developer plan or higher.

Prefer a language client when available: JavaScript / TypeScript, Python, or PHP (Laravel). Samples on this page stay raw HTTP so they match the OpenAPI contract.

Parameters

Name Type Required Description
offers array Yes 2 to 50 objects with a decimal-string `price` and a written `quantity`
per string No Unit to compare in (for example l or kg). Defaults to the category base unit.
locale string No Language tag used to read quantities such as "1,5 l"
decimals integer No Round unit prices to this many fractional places (0-40, half-even).

Possible errors

INVALID_REQUEST · INVALID_VALUE · UNKNOWN_UNIT · AMBIGUOUS_UNIT · INCOMPATIBLE_UNITS · PLAN_REQUIRED · UNAUTHORIZED · INVALID_API_KEY · RATE_LIMIT_EXCEEDED · QUOTA_EXCEEDED

All endpoints · Error reference

cURL
curl "https://api.unifyunits.com/v1/unit-price" \
  -X POST \
  -H "Authorization: Bearer $UNIFYUNITS_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"offers":[{"price":"4.99","quantity":"750 ml"},{"price":"6.49","quantity":"1 l"}],"decimals":2}'

Response 200

json
{
  "data": {
    "category": "volume",
    "per": "l",
    "items": [
      {
        "index": 0,
        "price": "4.99",
        "quantity": { "value": "750", "unit": "ml" },
        "kind": "single",
        "unit_price": { "value": "6.65", "per": "l" },
        "rank": 2,
        "cheapest": false,
        "premium_percent": "2.52"
      },
      {
        "index": 1,
        "price": "6.49",
        "quantity": { "value": "1", "unit": "l" },
        "kind": "single",
        "unit_price": { "value": "6.49", "per": "l" },
        "rank": 1,
        "cheapest": true,
        "premium_percent": "0.00"
      }
    ]
  }
}