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
- Camera captures UPC/EAN (12 or 13 digits)
- App sends barcode to API
- API matches against packaged food database
- 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
| Format | Digits | Region |
|---|---|---|
| UPC-A | 12 | North America |
| EAN-13 | 13 | International |
A robust UPC food nutrition API handles both formats and normalizes leading zeros.
When Barcode Lookup Fails
| Issue | Solution |
|---|---|
| 404 not found | Fall back to text search |
| Wrong product | Let user confirm or correct |
| Regional barcode | Try alternate regional databases |
| Damaged label | Manual 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
Related Guides
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.
