Calories and macros for 5.2 million foods#

Search USDA FoodData Central and Open Food Facts by name, barcode, meal description or photo. One API key, JSON responses, and you pay per query.

Each result names its source record, its serving sizes, and the amount its values were measured on. A nutrient the source doesn't list comes back as null, not zero.

Barcode lookup
$ curl 'https://kcal.elbantli.com/v1/barcode?barcode=3017620422003' \
    -H "Authorization: Bearer $KCAL_API_KEY"

{
  "name": "Nutella",
  "brand": "Nutella, Ferrero",
  "source": "off",
  "nutrition": [{
    "preparation": "as_sold",
    "basis": { "quantity": 100, "unit": "g" },
    "nutrients": {
      "kcal": 539, "proteinG": 6.3, "carbsG": 57.5,
      "fatG": 30.9, "sugarsG": 56.3, "saltG": 0.107
    }
  }, …],
  "portions": [ … ]
}

API

Search by name, barcode, meal or photo#

Basic search and barcode lookup read the catalog directly. Smart search and image search split a meal into up to 12 foods and match each one with its amount.

When a food has no confident match, the API marks it no_match or ambiguous instead of picking the nearest result.

  • Basic search

    Find foods by name, brand, or ingredients.

    GET /v1/basic-search
  • Smart search

    Turn a meal description into foods and portions.

    POST /v1/smart-search
  • Image search

    Identify foods and portions from a photo.

    POST /v1/image-transcribe
  • Barcode lookup

    Look up a packaged food by its barcode.

    GET /v1/barcode

Pricing

Pay per successful query#

Your first 10 successful queries are free, with no card. After that, add credit from $5. Failed requests are refunded.

EndpointPer queryPer 1,000
Basic search$0.003$3.00
Smart search$0.040$40.00
Image search$0.055$55.00
Barcode lookup$0.002$2.00

Smart and image search are priced per request, for up to 12 foods. Credits expire 12 months after your last top-up.

Quickstart

Try it with curl#

Create an API key in the console, then run any of these.

Terminal
export KCAL=https://kcal.elbantli.com/v1
export AUTH="Authorization: Bearer $KCAL_API_KEY"

# Search by name, brand, or ingredients
curl "$KCAL/basic-search?q=greek+yogurt&nb_results=3" -H "$AUTH"

# Split a meal description into foods and amounts
curl "$KCAL/smart-search" -H "$AUTH" -H "Content-Type: application/json" \
    -d '{"q": "2 eggs and a slice of sourdough"}'

# Identify the foods in a photo
curl "$KCAL/image-transcribe" -H "$AUTH" -F image=@lunch.jpg

# Look up a packaged food by barcode
curl "$KCAL/barcode?barcode=3017620422003" -H "$AUTH"

Changelog

What changed#

    • Credits expire 12 months after your last top-up. Each new top-up resets the date, and the billing page shows it.
    • Search ranks generic USDA reference foods above unbranded duplicates.
    • Misspelled, French and British food names find their English match: bananna, pomme and crisps return banana, apple and potato chips.
    • Smart and image search results include the reference names used to match each food, in a new references field.
    • Shortened brand names such as coke zero and kitkat rank the branded product first.
    • First release: basic search, smart search, image search and barcode lookup.
    • The first 10 successful queries are free. After that, prepaid credits from $5, and failed requests are refunded.