Skip to content

Food Barcode Lookup API: How to Add Scanning to Any App

Published June 5, 2026

A food API barcode lookup resolves a UPC or EAN barcode to nutritional data — calories, macros, and brand info — without manual search. To get nutrition from barcode API endpoints, pass the scanned code to a REST URL and render the JSON response in your app.

How Barcode Lookup Works

  1. Camera captures UPC/EAN (12 or 13 digits)
  2. App sends barcode to API
  3. API matches against packaged food database
  4. Response returns calories, macros, brand, serving size
curl "https://api.calorieapi.com/api/v1/search/barcode/012345678905" \
  -H "X-API-Key: YOUR_API_KEY"

Example Response

{
  "id": 88234,
  "name": "Organic Peanut Butter",
  "brand": "Example Brand",
  "calories": 188,
  "protein_g": 8.0,
  "carbohydrates_g": 6.0,
  "fat_g": 16.0,
  "serving_size": "32g",
  "barcode": "012345678905"
}

Mobile Integration (React Native)

import { BarCodeScanner } from 'expo-barcode-scanner';

async function onBarcodeScanned({ data }) {
  const res = await fetch(
    `https://api.calorieapi.com/api/v1/search/barcode/NULL`,
    { headers: { 'X-API-Key': API_KEY } }
  );
  if (res.status === 404) {
    alert('Product not found — try manual search');
    return;
  }
  const food = await res.json();
  addToFoodLog(food);
}

UPC vs EAN

FormatDigitsRegion
UPC-A12North America
EAN-1313International

A robust UPC food nutrition API handles both formats and normalizes leading zeros.

When Barcode Lookup Fails

IssueSolution
404 not foundFall back to text search
Wrong productLet user confirm or correct
Regional barcodeTry alternate regional databases
Damaged labelManual entry option

Use Cases

  • Grocery scanning in calorie trackers
  • Barcode to calories API for quick logging
  • Retail nutrition label apps
  • Food label API by barcode for compliance tools

Get your free API key | Docs

Frequently Asked Questions

How do I get nutrition data from a barcode?

Scan the UPC or EAN code, send it to a barcode lookup API endpoint, and parse the returned JSON with calories, macros, and serving information.

What barcode formats do food APIs support?

Most support UPC-A (12 digits) and EAN-13 (13 digits). The API normalizes leading zeros and matches against packaged food databases.

What happens if a barcode is not found?

The API returns 404. Your app should fall back to manual text search and optionally let users submit missing products.

Can I add barcode scanning to a React app?

Yes. Use a camera barcode library (ZXing, QuaggaJS, or Expo BarCodeScanner) to capture the code, then call the barcode API endpoint.

Is barcode lookup included in free tiers?

Most major food APIs include barcode lookup on free tiers with standard rate limits. Check your plan quota before shipping to production.

← Back to all articles

Start building with the Calorie API

Get a free API key and access 4M+ foods with search, barcode lookup, and full macro data.