To scan an EAN-8 barcode using the FatSecret Platform API, you must use the food.find_id_for_barcode method.
Important Prerequisite: This specific method is a Premier-only feature. If you are on the standard "Basic" (Free) plan, you will likely receive a "Missing scope" (Error 14) response. To use this, you need a paid Premier plan or the "Premier Free" tier (available for eligible startups and non-profits).
1. Format the Barcode (EAN-8 to GTIN-13)The FatSecret API expects all barcodes to be in GTIN-13 format.
EAN-8 has 8 digits.
GTIN-13 has 13 digits.
Conversion: You must pad the EAN-8 code with 5 leading zeros.
Example:
Your EAN-8: 12345670
API Input: 0000012345670
You will use the food.find_id_for_barcode method. There are two versions:
v1: Returns only the food_id. (You must then make a second call to food.get to see nutrition info).
v2 (Recommended): Returns the food_id and detailed nutritional information in one call.
Endpoint parameters:
method: food.find_id_for_barcode
barcode: The 13-digit padded string.
format: json (recommended).
region: (Optional but recommended, e.g., US, GB, AU) to get the correct product for your country.
To convert a UPC-E barcode to the standard 12-digit UPC-A (and the 13-digit version often used in database lookup), you have to expand the compressed middle section.
Here is the step-by-step breakdown for your specific barcode: 07096990.
1. The Anatomy of your UPC-EFirst, strip off the first and last digits to reveal the compressed 6-digit code.
System Character (Start): 0
Compressed Content (Middle): 709699
Check Digit (End): 0
The logic for expansion depends entirely on the last digit of that 6-digit middle section. In your case, the content is 709699, so the deciding digit is 9.
2. The Conversion Rule (For Ending Digit 5-9)Because your code ends in a 9, it follows the simplest rule:
Manufacturer ID: Take the first 5 digits of the content.
Product ID: The number 0000 followed by that last digit.
The Final Result:
UPC-A (Standard 12-digit): 070969000090
EAN-13 (Standard 13-digit): 0070969000090 (Just add a leading zero)
If you need to convert other UPC-E codes, look at that 6th digit of the compressed section and apply the corresponding rule below.
(Let's assume the 6-digit content is represented as abcdeM, where M is the last digit)
If M is 0, 1, or 2:
Group: ab + M + 0000 + cde
Example: 210140 => 210000014
If M is 3:
Group: abc + 00000 + de
Example: 123453 => 1230000045
If M is 4:
Group: abcd + 00000 + e
Example: 123454 => 1234000005
If M is 5, 6, 7, 8, or 9 (Your Case):
Group: abcde + 0000 + M
Example: 709699 => 7096900009