fatsecret Platform API Documentation

Foods: Find Id For Barcode

OAuth 2.0 OAuth 1.0 Latest Premier Exclusive
Description

Returns the food_id matching the barcode specified. Barcodes must be specified as GTIN-13 numbers - a 13-digit number filled in with zeros for the spaces to the left. UPC-A, EAN-13 and EAN-8 barcodes may be specified. UPC-E barcodes should be converted to their UPC-A equivalent (and then specified as GTIN-13 numbers).

An interactive demonstration of our Barcode API can be accessed here

Parameters
URL / Method
NAME TYPE REQUIRED DESCRIPTION
URL (new)
Method
N/A Required "https://platform.fatsecret.com/rest/food/barcode/find-by-id/v1"
HTTP "GET"
OR
method String Required "food.find_id_for_barcode" (included with other parameters)
Additional Parameters
NAME TYPE REQUIRED DESCRIPTION
barcode String Required 13-digit GTIN-13 formatted sequence of digits representing the barcode to search against
region String Optional Results will be filtered by region. E.G.: "FR" returns results from France
language String Optional (Ignored unless region is also specified) Results will be in the specified language. E.G.: "fr" returns results in French
format String Optional The desired response format. Valid response formats are "xml" or "json" (default value is "xml").
Scopes for OAuth2 integration: barcode
Response
The only storable value returned by this call is food_id.

Each food_id element contains information as follows:

NAME TYPE DESCRIPTION
food_id Long Unique food identifier

Example Response

Example 1:

<?xml version="1.0" encoding="utf-8"?>
<food_id xmlns="http://platform.fatsecret.com/api/1.0/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://platform.fatsecret.com/api/1.0/ http://platform.fatsecret.com/api/1.0/fatsecret.xsd">4384</food_id>

Example 1:

{
  "food_id": {
    "value": "4384"
  }
}
Error Codes
CODE TYPE DESCRIPTION
2 OAuth 1.0 Missing required oauth parameter: '<details>'
3 OAuth 1.0 Unsupported oauth parameter: '<details>'
4 OAuth 1.0 Invalid signature method: '<details>'
5 OAuth 1.0 Invalid consumer key: '<details>'
6 OAuth 1.0 Invalid/expired timestamp: '<details>'
7 OAuth 1.0 Invalid/used nonce: '<details>'
8 OAuth 1.0 Invalid signature: '<details>'
9 OAuth 1.0 Invalid access token: '<details>'
13 OAuth 2.0 Invalid token: '<details>'
14 OAuth 2.0 Missing scope: '<details>'
101 Parameter Missing required parameter: '<details>'