Mac/Linux:
export UPC_API_KEY="4190D3F1E6057DD921DA7E426A79AAF3"
npm run start:proxyWindows (PowerShell):
$env:UPC_API_KEY="4190D3F1E6057DD921DA7E426A79AAF3"
npm run start:proxyWindows (CMD):
set UPC_API_KEY=4190D3F1E6057DD921DA7E426A79AAF3
npm run start:proxyThe proxy will start on http://localhost:8787
In a separate terminal:
npm startThe app will be available at http://localhost:3002
- API Key:
4190D3F1E6057DD921DA7E426A79AAF3 - Status: Configured and working
- Endpoint: Via proxy at
http://localhost:8787 - Authentication: Bearer token in Authorization header
- Status: Free, no API key required
- Coverage: Excellent for food products worldwide
- Endpoint: Direct API call (no proxy needed)
- Status: Free, no API key required
- Coverage: Cosmetics and beauty products
- Endpoint: Direct API call (no proxy needed)
- Status: Using demo key (free tier)
- Coverage: General products
- Note: For production, get your own API key from barcodelookup.com
- Status: Free, open database
- Coverage: Open product database
- Endpoint: Direct API call
When a barcode is scanned:
- Barcode Detection: Browser's native Barcode Detection API detects the barcode
- API Query: The app queries 5 APIs in parallel:
- Open Food Facts (fastest, free)
- UPC Database (via proxy with your API key)
- Open Beauty Facts (for cosmetics)
- Barcode Lookup (demo key)
- GTIN Search (open database)
- First Result Wins: Uses
Promise.any()to get the first successful response - Fallback: If all parallel requests fail, tries sequential fallback
- Caching: Results are cached for 5 minutes to reduce API calls
- Display: Product info is displayed and saved to scan history
- Start the proxy:
export UPC_API_KEY="..." && npm run start:proxy - Start the app:
npm start - Navigate to:
http://localhost:3002/app/scanner - Scan a barcode: Use your camera or upload an image
- Check console: You should see API calls and responses
- Make sure
UPC_API_KEYis set in the environment - Check that port 8787 is not in use
- Verify the proxy is running:
curl http://localhost:8787/product/0123456789012
- Check browser console for API errors
- Verify the proxy is running
- Try scanning a known barcode (e.g., common food products)
- Check that the barcode is 8-14 digits (required format)
- The proxy handles CORS for UPC Database
- Other APIs may have CORS restrictions (errors are caught gracefully)
- The app will use whichever API responds first
The APIs are queried in this order (first successful response wins):
- Open Food Facts (fastest, best for food)
- UPC Database (your API key, reliable)
- Open Beauty Facts (for cosmetics)
- Barcode Lookup (demo key, may have rate limits)
- GTIN Search (open database, may be slower)