### GET Request Example (URL-based, OAuth 1.0) Source: https://platform.fatsecret.com/docs/guides Example of a GET request using URL path integration for the food.get.v4 API method with OAuth 1.0. ```http GET https://platform.fatsecret.com/rest/food/v5? food_id=33691& oauth_consumer_key=9a1a6fd1fff5433f9dd77daa4587bf5d& oauth_nonce=1234&oauth_signature=sAyYTJiIxOGkvFpBcH8L%2BlFQRCQ%3D& oauth_signature_method=HMAC-SHA1& oauth_timestamp=1245126631& oauth_version=1.0 ``` -------------------------------- ### GET Request Example (URL-based, OAuth 2.0) Source: https://platform.fatsecret.com/docs/guides Example of a GET request using URL path integration for the food.get.v4 API method with OAuth 2.0. ```http GET https://platform.fatsecret.com/rest/food/v5? food_id=33691& Content-Type: application/json Header: Authorization: Bearer {Access Token} food_id=33691&format=json ``` -------------------------------- ### Example Normalized Parameters String Source: https://platform.fatsecret.com/docs/guides/authentication/oauth1 This example shows the concatenated and sorted query parameters before percent-encoding. Ensure all required OAuth parameters and any custom parameters are included. ```text a=foo&oauth_consumer_key=demo&oauth_nonce=abc&oauth_signature_method=HMAC-SHA1&oauth_timestamp=12345678&oauth_version=1.0&z=bar ``` -------------------------------- ### Access Token Response Example Source: https://platform.fatsecret.com/docs/guides/authentication/oauth2 This is an example of a successful response when requesting an access token. It includes the 'access_token', 'token_type', and 'expires_in' fields. ```http HTTP/1.1 200 OK Content-Type: application/json;charset=UTF-8 Cache-Control: no-store Pragma: no-cache {    "access_token":"eyJhbGciOiJSU... ENjJEM ",    "token_type":"Bearer",    "expires_in":86400 } ``` -------------------------------- ### POST Request Example (Method-based, OAuth 1.0) Source: https://platform.fatsecret.com/docs/guides Example of a POST request using method parameters for the food.get.v5 API method with OAuth 1.0. ```http POST https://platform.fatsecret.com/rest/server.api? food_id=33691& method=food.get.v5& oauth_consumer_key=9a1a6fd1fff5433f9dd77daa4587bf5d& oauth_nonce=1234&oauth_signature=sAyYTJiIxOGkvFpBcH8L%2BlFQRCQ%3D& oauth_signature_method=HMAC-SHA1& oauth_timestamp=1245126631& oauth_version=1.0 ``` -------------------------------- ### OAuth 2.0 Authentication Guide Source: https://platform.fatsecret.com/docs/guides/authentication/oauth2 This guide summarizes the prerequisites for the OAuth Core 2.0 protocol used for signing FatSecret Platform REST API requests. It explains the roles of User, Client, Client ID, Client Secret, Scope, and Access Token, and lists valid scopes. ```APIDOC ## OAuth 2.0 Authentication ### Description This section details the OAuth 2.0 protocol for authenticating requests to the FatSecret Platform API. It defines key terms and outlines the process for obtaining and using access tokens. ### Key Concepts * **User**: The developer making the API request. * **Client**: The developer's application. * **Client ID**: A unique identifier issued to the client application. * **Client Secret**: A secret key issued to the client application for authentication. * **Scope**: Defines the specific FatSecret API resources the Access Token can access. Multiple scopes can be requested, space-delimited (e.g., "premier barcode localization"). * **Access Token**: A generated token that grants access to API resources based on the specified Scope. ### Valid Scopes * basic * premier * barcode * localization * nlp * image-recognition * feedback *Note: If no scope is specified, all accessible scopes will be granted.* ### Requesting Tokens via Proxy Server FatSecret requires OAuth 2.0 tokens to be requested through a proxy server to secure client credentials. This allows for IP address restrictions, especially for PREMIER and PREMIER Free levels, where IP ranges can be specified in CIDR notation. ``` -------------------------------- ### Method Based Integration - Food Get v5 (OAuth 1.0) Source: https://platform.fatsecret.com/docs/guides Example of a POST request to the server.api endpoint for the food.get.v5 method using OAuth 1.0 authentication. ```APIDOC ## POST /api/server.api ### Description Retrieves detailed information about a specific food item using the method parameter with OAuth 1.0 authentication. ### Method POST ### Endpoint https://platform.fatsecret.com/rest/server.api ### Query Parameters - **food_id** (string) - Required - The unique identifier for the food item. - **method** (string) - Required - The API method to call (e.g., food.get.v5). - **oauth_consumer_key** (string) - Required - Your application's consumer key. - **oauth_nonce** (string) - Required - A unique nonce value for the request. - **oauth_signature** (string) - Required - The computed signature for the request. - **oauth_signature_method** (string) - Required - The signature method used (e.g., HMAC-SHA1). - **oauth_timestamp** (string) - Required - The timestamp of the request. - **oauth_version** (string) - Required - The OAuth version (1.0). ### Request Example ``` POST https://platform.fatsecret.com/rest/server.api?food_id=33691&method=food.get.v5&oauth_consumer_key=9a1a6fd1fff5433f9dd77daa4587bf5d&oauth_nonce=1234&oauth_signature=sAyYTJiIxOGkvFpBcH8L%2BlFQRCQ%3D&oauth_signature_method=HMAC-SHA1&oauth_timestamp=1245126631&oauth_version=1.0 ``` ### Response #### Success Response (200) - **food** (object) - Contains detailed information about the food item. - **food_id** (string) - The ID of the food item. - **food_name** (string) - The name of the food item. - **servings** (array) - List of available servings for the food item. - **nutrients** (object) - Nutritional information for the food item. #### Response Example ```json { "food": { "food_id": "33691", "food_name": "Apple", "servings": [ { "serving_id": "1000", "serving_description": "100g" } ], "nutrients": { "ENERC_KCAL": { "nutrient_id": "208", "nutrient_name": "Energy", "nutrient_unit": "kcal", "value": "52" } } } } ``` ``` -------------------------------- ### POST Request Example (Method-based, OAuth 2.0) Source: https://platform.fatsecret.com/docs/guides Example of a POST request using method parameters for the food.get.v5 API method with OAuth 2.0. ```http POST https://platform.fatsecret.com/rest/server.api Content-Type: application/json Header: Authorization: Bearer {Access Token} Parameters: method=food.get.v5&food_id=33691&format=json ``` -------------------------------- ### Method Based Integration - Food Get v5 (OAuth 2.0) Source: https://platform.fatsecret.com/docs/guides Example of a POST request to the server.api endpoint for the food.get.v5 method using OAuth 2.0 authentication. ```APIDOC ## POST /api/server.api ### Description Retrieves detailed information about a specific food item using the method parameter with OAuth 2.0 authentication. ### Method POST ### Endpoint https://platform.fatsecret.com/rest/server.api ### Headers - **Content-Type**: application/json - **Authorization**: Bearer {Access Token} ### Request Body Parameters - **method** (string) - Required - The API method to call (e.g., food.get.v5). - **food_id** (string) - Required - The unique identifier for the food item. - **format** (string) - Optional - The desired response format (e.g., json). ### Request Example ``` POST https://platform.fatsecret.com/rest/server.api Content-Type: application/json Authorization: Bearer {Access Token} Parameters: method=food.get.v5&food_id=33691&format=json ``` ### Response #### Success Response (200) - **food** (object) - Contains detailed information about the food item. - **food_id** (string) - The ID of the food item. - **food_name** (string) - The name of the food item. - **servings** (array) - List of available servings for the food item. - **nutrients** (object) - Nutritional information for the food item. #### Response Example ```json { "food": { "food_id": "33691", "food_name": "Apple", "servings": [ { "serving_id": "1000", "serving_description": "100g" } ], "nutrients": { "ENERC_KCAL": { "nutrient_id": "208", "nutrient_name": "Energy", "nutrient_unit": "kcal", "value": "52" } } } } ``` ``` -------------------------------- ### Request Access Token using Node.js Source: https://platform.fatsecret.com/docs/guides/authentication/oauth2 This Node.js example demonstrates how to request an access token using the 'request' library. It includes setting up authentication headers and form data for the POST request to the token URL. ```javascript var request = require("request"); clientID = 'YOUR_CLIENT_ID' clientSecret = 'YOUR_CLIENT_SECRET' var options = { method: 'POST', url: 'https://oauth.fatsecret.com/connect/token', method : 'POST', auth : { user : clientID, password : clientSecret }, headers: { 'content-type': 'application/x-www-form-urlencoded'}, form: { 'grant_type': 'client_credentials', 'scope' : 'basic' }, json: true }; request(options, function (error, response, body) { if (error) throw new Error(error); console.log(body); }); ``` -------------------------------- ### URL Based Integration - Food Get v5 (OAuth 1.0) Source: https://platform.fatsecret.com/docs/guides Example of a GET request to the food.get.v5 API method using URL-based integration with OAuth 1.0 authentication. ```APIDOC ## GET /api/food/v5 ### Description Retrieves detailed information about a specific food item using its ID with OAuth 1.0. ### Method GET ### Endpoint https://platform.fatsecret.com/rest/food/v5 ### Query Parameters - **food_id** (string) - Required - The unique identifier for the food item. - **oauth_consumer_key** (string) - Required - Your application's consumer key. - **oauth_nonce** (string) - Required - A unique nonce value for the request. - **oauth_signature** (string) - Required - The computed signature for the request. - **oauth_signature_method** (string) - Required - The signature method used (e.g., HMAC-SHA1). - **oauth_timestamp** (string) - Required - The timestamp of the request. - **oauth_version** (string) - Required - The OAuth version (1.0). ### Request Example ``` GET https://platform.fatsecret.com/rest/food/v5?food_id=33691&oauth_consumer_key=9a1a6fd1fff5433f9dd77daa4587bf5d&oauth_nonce=1234&oauth_signature=sAyYTJiIxOGkvFpBcH8L%2BlFQRCQ%3D&oauth_signature_method=HMAC-SHA1&oauth_timestamp=1245126631&oauth_version=1.0 ``` ### Response #### Success Response (200) - **food** (object) - Contains detailed information about the food item. - **food_id** (string) - The ID of the food item. - **food_name** (string) - The name of the food item. - **servings** (array) - List of available servings for the food item. - **nutrients** (object) - Nutritional information for the food item. #### Response Example ```json { "food": { "food_id": "33691", "food_name": "Apple", "servings": [ { "serving_id": "1000", "serving_description": "100g" } ], "nutrients": { "ENERC_KCAL": { "nutrient_id": "208", "nutrient_name": "Energy", "nutrient_unit": "kcal", "value": "52" } } } } ``` ``` -------------------------------- ### URL Based Integration - Food Get v5 (OAuth 2.0) Source: https://platform.fatsecret.com/docs/guides Example of a GET request to the food.get.v5 API method using URL-based integration with OAuth 2.0 authentication. ```APIDOC ## GET /api/food/v5 ### Description Retrieves detailed information about a specific food item using its ID. ### Method GET ### Endpoint https://platform.fatsecret.com/rest/food/v5 ### Query Parameters - **food_id** (string) - Required - The unique identifier for the food item. - **format** (string) - Optional - The desired response format (e.g., json). ### Headers - **Content-Type**: application/json - **Authorization**: Bearer {Access Token} ### Request Example ``` GET https://platform.fatsecret.com/rest/food/v5?food_id=33691&format=json Content-Type: application/json Authorization: Bearer {Access Token} ``` ### Response #### Success Response (200) - **food** (object) - Contains detailed information about the food item. - **food_id** (string) - The ID of the food item. - **food_name** (string) - The name of the food item. - **servings** (array) - List of available servings for the food item. - **nutrients** (object) - Nutritional information for the food item. #### Response Example ```json { "food": { "food_id": "33691", "food_name": "Apple", "servings": [ { "serving_id": "1000", "serving_description": "100g" } ], "nutrients": { "ENERC_KCAL": { "nutrient_id": "208", "nutrient_name": "Energy", "nutrient_unit": "kcal", "value": "52" } } } } ``` ``` -------------------------------- ### Make API Request with Access Token Source: https://platform.fatsecret.com/docs/guides/authentication/oauth2 This example shows how to make a POST request to a FatSecret API endpoint, such as foods.search, by including the obtained access token in the Authorization header. ```http POST https://platform.fatsecret.com/rest/server.api Content-Type: application/json Header: Authorization: Bearer Parameters: method=foods.search&search_expression=toast&format=json ``` -------------------------------- ### Example Signature Base String Source: https://platform.fatsecret.com/docs/guides/authentication/oauth1 This is the final signature base string, formed by concatenating the percent-encoded HTTP method, request URL, and normalized parameters. This string is then used to calculate the oauth_signature. ```text POST&https%3A%2F%2Fplatform.fatsecret.com%2Frest%2Fserver.api&a%3Dfoo%26oauth_consumer_key%3Ddemo%26oauth_nonce%3Dabc%26oauth_signature_method%3DHMAC-SHA1%26oauth_timestamp%3D12345678%26oauth_version%3D1.0%26z%3Dbar ``` -------------------------------- ### Example Percent-Encoded Normalized Parameters Source: https://platform.fatsecret.com/docs/guides/authentication/oauth1 This is the percent-encoded version of the normalized parameters string. All characters that have special meaning in URLs are encoded. ```text a%3Dfoo%26oauth_consumer_key%3Ddemo%26oauth_nonce%3Dabc%26oauth_signature_method%3DHMAC-SHA1%26oauth_timestamp%3D12345678%26oauth_version%3D1.0%26z%3Dbar ``` -------------------------------- ### Access Token Claims Example Source: https://platform.fatsecret.com/docs/guides/authentication/oauth2 This JSON object represents the claims found within a decoded access token. It shows details like the token's expiration, issuer, audience, client ID, and scopes. ```json {    "nbf": 12345,    "exp": 67890,    "iss": "https://oauth.fatsecret.com",    "aud": [      "https://oauth.fatsecret.com/resources",      "basic"    ],    "client_id": "CLIENT_ID",    "scope": [      "basic"    ] } ``` -------------------------------- ### XML Error Response Example Source: https://platform.fatsecret.com/docs/guides/error-codes This XML structure represents an error response from the Fatsecret API, indicating an invalid signature method. ```xml 4 Invalid signature method: oauth_signature_method 'PLAINTEXT' ``` -------------------------------- ### Libraries and Resources Source: https://platform.fatsecret.com/docs/guides/libraries Information on available libraries, Postman walkthroughs, and the developer forum. ```APIDOC ## Libraries ### Postman - A Postman walkthrough guide is available on Github for getting started with the API. ### Third Party Libraries - **Python** - **Php** - **Swift**: Note that the SWIFT library requires storing credentials in plain text and is recommended for proof of concept only. Using a proxy service is advised for securing credentials. ### Developer Forum - A developer forum is available on Google Groups. ``` -------------------------------- ### Request Access Token using C# Source: https://platform.fatsecret.com/docs/guides/authentication/oauth2 This C# code snippet shows how to obtain an access token using HttpClient. It sets up basic authentication with the client credentials and sends a POST request with form-urlencoded content. ```csharp var client = new HttpClient(); var byteArray = Encoding.ASCII.GetBytes("YOUR_CLIENT_ID:YOUR_CLIENT_SECRET"); client.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Basic", Convert.ToBase64String(byteArray)); var values = new Dictionary { { "scope", "basic" }, { "grant_type", "client_credentials" } }; var content = new FormUrlEncodedContent(values); var response = await client.PostAsync("https://oauth.fatsecret.com/connect/token", content); var responseString = await response.Content.ReadAsStringAsync(); ``` -------------------------------- ### JSON Error Response Example Source: https://platform.fatsecret.com/docs/guides/error-codes This JSON structure represents an error response from the Fatsecret API, indicating an invalid signature method. ```json { "error": { "code": "4", "message": "Invalid signature method: oauth_signature_method 'PLAINTEXT'" } } ``` -------------------------------- ### Authentication Overview Source: https://platform.fatsecret.com/docs/guides/authentication Information on how to authenticate with the FatSecret Platform API. Requires developer signup and agreement to terms of service to obtain credentials. ```APIDOC ## Authentication To interact with the FatSecret Platform API, you must first register as a developer and accept the Terms of Service to obtain the necessary credentials. ### Credentials: - **OAuth 2.0**: Requires a `Client ID` and `Client Secret`. - **OAuth 1.0**: Requires a `Consumer Key` and `Shared Secret`. ### Request Types: - **Signed Requests**: Used for general data retrieval (e.g., `food.get.v5`). Verifies the request using shared secrets without user-specific data. - **OAuth 2.0**: Supports Signed Requests using `Client ID` and a token. - **OAuth 1.0**: Supports Signed Requests using `Consumer Key` and a signature. - **Signed and Delegated Requests**: Used for actions on behalf of a specific user (e.g., `weights.get_month.v2`, `food_entry.create`). Requires user profiles and OAuth tokens. - **OAuth 1.0 ONLY**: Supports Signed and Delegated Requests using `Consumer Key`, `Access Token`, and `Signature`. ### Profile Management: - Developers can create **profiles** for users to manage their data. - Profiles can be created with a unique identifier (member name, email, member ID) or without specific user information. - If created without user-specific info, the `oauth_token` and `oauth_secret` must be stored (see `profile.create`). - The Profile Management REST API methods (`profile.create`, `profile.get_auth`) generate OAuth access tokens for signing requests on behalf of users. - Alternatively, FatSecret's 3-legged OAuth can be used to obtain an access token directly linked to a fatsecret.com user account. ``` -------------------------------- ### Call FatSecret API with Access Token Source: https://platform.fatsecret.com/docs/guides/authentication/oauth2 Demonstrates how to use the obtained access token to make authenticated requests to the FatSecret API. ```APIDOC ## Making an API Request ### Description To access FatSecret API resources, include the obtained access token in the `Authorization` header of your request. ### Method POST (or GET, depending on the specific API method) ### Endpoint https://platform.fatsecret.com/rest/server.api ### Headers - **Content-Type**: `application/json` (or as specified by the API method) - **Authorization**: `Bearer ` ### Parameters Parameters are typically sent as query parameters or in the request body, depending on the API method. #### Example: `foods.search` Method - **method** (string) - Required - The API method to call, e.g., `foods.search`. - **search_expression** (string) - Required - The term to search for, e.g., `toast`. - **format** (string) - Required - The desired response format, e.g., `json`. ### Request Example ``` POST https://platform.fatsecret.com/rest/server.api Content-Type: application/json Authorization: Bearer Parameters: method=foods.search&search_expression=toast&format=json ``` ``` -------------------------------- ### Native APIs Source: https://platform.fatsecret.com/docs/guides/storable-data Overview of native API capabilities. ```APIDOC # fatsecret Platform API Documentation ## Native APIs ### Natural Language Processing* Details on NLP capabilities. ### Image Recognition* Details on image recognition features. ### Feedback* Information on providing feedback through the API. ``` -------------------------------- ### Parameters Documentation Source: https://platform.fatsecret.com/docs/guides/parameters Common parameters used across the FatSecret Platform REST API. ```APIDOC ## Parameters Common fatsecret Platform REST API request and response parameters. For further information, please refer to the individual endpoint documentation. ##### Unique Identifiers NAME | TYPE | DESCRIPTION ---|---|--- eaten_foods.food_id | Long | The ID of the food that has been previously consumed exercise_id | Long | Unique exercise identifier feedback.external_id | String | Custom identifier for external use. E.g an external unique user identifier feedback.issue_type_id | Int | The type ID for the request. Valid options are 1 (Wrong Name/Brand), 2 (Wrong Nutrition Info), 3 (Missing Serving Size), 4 (Barcode not found), 99 (Other) feedback.returned_food.food_id | Int | A food ID that is related to the issue (i.e. barcode incorrect food attached). Required when issue_type_id is 1, 2 or 3 feedback.returned_food.serving_id | Int | A foods serving ID that is related to the issue (i.e. incorrect nutrient information). Required when issue_type_id is 2 or 3 food_category_id | Long | Unique identifier of the food category entry food_entry_id | Long | Unique identifier of the food diary entry food_id | Long | Unique food identifier recipe_id | Long | Unique recipe identifier saved_meal_id | Long | Unique saved meal identifier saved_meal_item_id | Long | Unique saved meal item identifier serving_id | Long | Unique serving identifier shift_from_id | Long | ID of the exercise type to shift from shift_to_id | Long | ID of the exercise type to shift to user_id | String | You can set your own ID for the newly created profile if you do not wish to store the auth_token and auth_secret ``` -------------------------------- ### Request Access Token Source: https://platform.fatsecret.com/docs/guides/authentication/oauth2 This endpoint is used to obtain an access token using the Client Credentials grant type. You need to provide your Client ID and Client Secret to get a token that allows access to FatSecret API resources. ```APIDOC ## POST /connect/token ### Description Requests an access token using the 'client_credentials' grant type. ### Method POST ### Endpoint https://oauth.fatsecret.com/connect/token ### Parameters #### Query Parameters - **grant_type** (string) - Required - Must be "client_credentials". - **scope** (string) - Required - Valid scopes are "basic", "premier", "barcode", and "localization". Multiple scopes can be requested separated by spaces (e.g., "premier barcode localization"). #### Request Body This endpoint uses form-urlencoded data for the request body. - **grant_type** (string) - Required - Must be "client_credentials". - **client_id** (string) - Required - Your application's Client ID. - **client_secret** (string) - Required - Your application's Client Secret. - **scope** (string) - Required - Valid scopes are "basic", "premier", "barcode", and "localization". Multiple scopes can be requested separated by spaces (e.g., "premier barcode localization"). ### Request Example (curl) ```bash curl -u : \ -d "grant_type=client_credentials&scope=basic" \ -X POST https://oauth.fatsecret.com/connect/token ``` ### Request Example (Node.js) ```javascript var request = require("request"); clientID = 'YOUR_CLIENT_ID' clientSecret = 'YOUR_CLIENT_SECRET' var options = { method: 'POST', url: 'https://oauth.fatsecret.com/connect/token', method : 'POST', auth : { user : clientID, password : clientSecret }, headers: { 'content-type': 'application/x-www-form-urlencoded'}, form: { 'grant_type': 'client_credentials', 'scope' : 'basic' }, json: true }; request(options, function (error, response, body) { if (error) throw new Error(error); console.log(body); }); ``` ### Request Example (C#) ```csharp var client = new HttpClient(); var byteArray = Encoding.ASCII.GetBytes("YOUR_CLIENT_ID:YOUR_CLIENT_SECRET"); client.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Basic", Convert.ToBase64String(byteArray)); var values = new Dictionary { { "scope", "basic" }, { "grant_type", "client_credentials" } }; var content = new FormUrlEncodedContent(values); var response = await client.PostAsync("https://oauth.fatsecret.com/connect/token", content); var responseString = await response.Content.ReadAsStringAsync(); ``` ### Response #### Success Response (200) - **access_token** (string) - The obtained Bearer token. - **token_type** (string) - The type of the token, usually "Bearer". - **expires_in** (integer) - The lifetime of the access token in seconds (e.g., 86400 for 24 hours). #### Response Example ```json { "access_token":"eyJhbGciOiJSU... ENjJEM ", "token_type":"Bearer", "expires_in":86400 } ``` #### Access Token Claims Example ```json { "nbf": 12345, "exp": 67890, "iss": "https://oauth.fatsecret.com", "aud": [ "https://oauth.fatsecret.com/resources", "basic" ], "client_id": "CLIENT_ID", "scope": [ "basic" ] } ``` ``` -------------------------------- ### Making an OAuth 1.0 Request Source: https://platform.fatsecret.com/docs/guides/authentication/oauth1 The fundamental steps involved in correctly signing and sending requests using OAuth 1.0. ```APIDOC ## Making an OAuth 1.0 Request ### Description Follow these steps to ensure your API requests are properly signed and authenticated using OAuth 1.0. ### Steps 1. **Create a Signature Base String**: Construct the base string according to the OAuth 1.0 protocol specifications. 2. **Calculate the Signature value**: Generate the signature using the appropriate signing method (HMAC-SHA1) and your Consumer Secret and Access Secret (if applicable). 3. **Send the Request**: Include all required OAuth parameters and the generated signature in your API request. ``` -------------------------------- ### Native APIs Overview Source: https://platform.fatsecret.com/docs/guides/authentication/oauth2 Overview of the Native APIs available, including Natural Language Processing, Image Recognition, Food search and retrieval, Brand and Category information, and Recipe search. ```APIDOC ## Native APIs ### Natural Language Processing* * Premier Exclusive method. ### Image Recognition* * Premier Exclusive method. ### Foods * **Autocomplete Search***: Provides food suggestions based on partial input. * Premier Exclusive method. * **Barcode Scanning***: Retrieves food information using a barcode. * Premier Exclusive method. * **Search v5***: Advanced food search functionality. * Premier Exclusive method. * **Get By Id**: Retrieves a specific food item by its ID. * **Search**: General food search functionality. ### Feedback* * Premier Exclusive method. ### Food Brands * **Get All***: Retrieves a list of all food brands. * Premier Exclusive method. ### Food Categories * **Get All***: Retrieves a list of all food categories. * Premier Exclusive method. ### Food Sub Categories * **Get All***: Retrieves a list of all food sub-categories. * Premier Exclusive method. ### Recipes * **Get By Id**: Retrieves a specific recipe by its ID. * **Search**: Searches for recipes based on criteria. ### Recipe Types * **Get All**: Retrieves a list of all available recipe types. ``` -------------------------------- ### Profile - Recipes API (3-Legged OAuth) Source: https://platform.fatsecret.com/docs/guides/data-types Endpoints for managing a user's favorite recipes using 3-Legged OAuth. ```APIDOC ## Profile - Recipes API (3-Legged OAuth) ### Add Favorite Recipe Adds a recipe to the user's favorites. ### Method POST ### Endpoint /profile/favorite_recipes ### Request Body - **recipe_id** (Long) - Required - The ID of the recipe to favorite. ### Delete Favorite Recipe Removes a recipe from the user's favorites. ### Method DELETE ### Endpoint /profile/favorite_recipes/{id} ### Path Parameters - **id** (Long) - Required - The ID of the favorite recipe entry to delete. ### Get All Favorite Recipes Retrieves all recipes marked as favorites by the user. ### Method GET ### Endpoint /profile/favorite_recipes ``` -------------------------------- ### Libraries Source: https://platform.fatsecret.com/docs/guides/storable-data Information about available client libraries for integrating with the API. ```APIDOC # fatsecret Platform API Documentation ## Libraries List of available libraries for various programming languages. ``` -------------------------------- ### Profile - Weight Diary API (3-Legged OAuth) Source: https://platform.fatsecret.com/docs/guides/data-types Endpoints for managing a user's weight log using 3-Legged OAuth. ```APIDOC ## Profile - Weight Diary API (3-Legged OAuth) ### Update Weight For Date Updates or adds a weight log entry for a specific date. ### Method PUT ### Endpoint /profile/weight ### Request Body - **date** (String) - Required - The date of the weight log (YYYY-MM-DD). - **weight** (Decimal) - Required - The weight value. - **weight_type** (String) - Optional - The unit of weight (kg or lb). ### Get Weight For Month Retrieves all weight log entries for a given month. ### Method GET ### Endpoint /profile/weight/month ### Query Parameters - **date** (String) - Required - A date within the desired month (YYYY-MM-DD). ``` -------------------------------- ### Profile - Authentication API Source: https://platform.fatsecret.com/docs/guides/libraries Endpoints for managing user profile creation and retrieving authentication status. ```APIDOC ## Profile - Authentication (3-Legged OAuth) ### Description Endpoints for managing user profile authentication status using 3-Legged OAuth. - **Create Profile**: Creates a new user profile. - **Get Profile Status**: Retrieves the status of the user's profile. - **Get Profile Auth**: Retrieves authentication details for the user's profile. ``` -------------------------------- ### Data Types and Parameters Source: https://platform.fatsecret.com/docs/guides/storable-data Information on the data types and parameters used within the API. ```APIDOC # fatsecret Platform API Documentation ## Data Types Information about the various data types used in the API. ## Parameters Details on the parameters accepted by different API endpoints. ``` -------------------------------- ### Request Access Token using cURL Source: https://platform.fatsecret.com/docs/guides/authentication/oauth2 Use this cURL command to request an access token from the FatSecret API. Replace placeholders with your actual Client ID and Client Secret. Ensure the scope is set correctly for your needs. ```bash -u : -d "grant_type=client_credentials&scope=basic" -X POST https://oauth.fatsecret.com/connect/token ``` -------------------------------- ### Profile - Recipes API Source: https://platform.fatsecret.com/docs/guides/libraries Endpoints for managing user's favorite recipes within their profile. ```APIDOC ## Profile - Recipes (3-Legged OAuth) ### Description Endpoints for managing recipe-related data within a user's profile using 3-Legged OAuth. - **Add Favorite**: Adds a recipe to the user's favorites. - **Delete Favorite**: Removes a recipe from the user's favorites. - **Get All Favorites**: Retrieves a list of all favorited recipes. ``` -------------------------------- ### Authentication API Source: https://platform.fatsecret.com/docs/guides/libraries Details on how to authenticate with the FatSecret Platform API using OAuth 2.0, OAuth 1.0, and 3-Legged OAuth flows. ```APIDOC ## Authentication ### Description Provides information on the authentication methods supported by the FatSecret Platform API. ### Methods - OAuth 2.0 - OAuth 1.0 - 3 Legged OAuth ``` -------------------------------- ### Authentication API Source: https://platform.fatsecret.com/docs/guides/storable-data Details on how to authenticate with the FatSecret Platform API using OAuth 2.0 and OAuth 1.0. ```APIDOC # fatsecret Platform API Documentation ## Authentication ### OAuth 2.0 Details on using OAuth 2.0 for authentication. ### OAuth 1.0 Details on using OAuth 1.0 for authentication. ### 3 Legged OAuth Details on using the 3-legged OAuth flow. ``` -------------------------------- ### Obtaining an Access Token Source: https://platform.fatsecret.com/docs/guides/authentication/oauth1/three-legged Exchange an authorized Request Token for an Access Token by making a signed request to the Access Token URL. This Access Token can then be used to access private user resources. ```APIDOC ## POST /oauth/access_token ### Description Exchange an authorized Request Token for an Access Token. ### Method GET ### Endpoint https://authentication.fatsecret.com/oauth/access_token ### Parameters #### Query Parameters - **oauth_consumer_key** (string) - Required - Your consumer key. - **oauth_token** (string) - Required - The authorized Request Token. - **oauth_signature_method** (string) - Required - Must be "HMAC-SHA1". - **oauth_timestamp** (integer) - Required - The date and time in seconds since January 1, 1970 GMT. - **oauth_nonce** (string) - Required - A randomly generated string. - **oauth_version** (string) - Required - Must be "1.0". - **oauth_verifier** (string) - Required - The verification code received from user authorization. ### Request Example ``` GET https://authentication.fatsecret.com/oauth/access_token?oauth_consumer_key=YOUR_CONSUMER_KEY&oauth_token=AUTHORIZED_REQUEST_TOKEN&oauth_signature_method=HMAC-SHA1&oauth_timestamp=1678886400&oauth_nonce=some_random_string&oauth_version=1.0&oauth_verifier=VERIFICATION_CODE&oauth_signature=GENERATED_SIGNATURE ``` ### Response #### Success Response (200) - **oauth_token** (string) - The Access Token. - **oauth_token_secret** (string) - The Access Token Secret. #### Response Example ```json { "oauth_token": "ACCESS_TOKEN", "oauth_token_secret": "ACCESS_TOKEN_SECRET" } ``` **Note:** The request must be signed using HMAC-SHA1. The signing key is the concatenation of your Consumer Secret and the `oauth_token_secret` (obtained previously), separated by an '&' character. ``` -------------------------------- ### Profile - Exercise Diary API (3-Legged OAuth) Source: https://platform.fatsecret.com/docs/guides/data-types Endpoints for managing a user's exercise diary entries using 3-Legged OAuth. ```APIDOC ## Profile - Exercise Diary API (3-Legged OAuth) ### Get All Exercise Entries Retrieves all exercise diary entries for a given date. ### Method GET ### Endpoint /profile/exercise/entries ### Query Parameters - **date** (String) - Required - The date for which to retrieve entries (YYYY-MM-DD). ### Commit Day Commits the exercise diary for a specific day. ### Method POST ### Endpoint /profile/exercise/commit_day ### Request Body - **date** (String) - Required - The date to commit (YYYY-MM-DD). ### Get All Exercise Entries For Date Retrieves all exercise diary entries for a specific date. ### Method GET ### Endpoint /profile/exercise/day ### Query Parameters - **date** (String) - Required - The date for which to retrieve entries (YYYY-MM-DD). ### Get Calories Expended For Month Retrieves the total calories expended from exercise for a given month. ### Method GET ### Endpoint /profile/exercise/month ### Query Parameters - **date** (String) - Required - A date within the desired month (YYYY-MM-DD). ### Save Template Saves a set of exercise entries as a template for future use. ### Method POST ### Endpoint /profile/exercise/save_template ### Request Body - **template_name** (String) - Required - The name of the template. - **entries** (Array) - Required - An array of exercise entries to save. - **exercise_id** (Long) - Required - The ID of the exercise. - **exercise_name** (String) - Required - The name of the exercise. - **duration** (Long) - Required - The duration of the exercise in minutes. - **calories_burned** (Int) - Required - The number of calories burned. ### Edit Entries For Date Edits or adds exercise entries for a specific date. ### Method PUT ### Endpoint /profile/exercise/entries ### Request Body - **date** (String) - Required - The date of the entries (YYYY-MM-DD). - **entries** (Array) - Required - An array of exercise entries. - **exercise_id** (Long) - Required - The ID of the exercise. - **exercise_name** (String) - Required - The name of the exercise. - **duration** (Long) - Required - The duration of the exercise in minutes. - **calories_burned** (Int) - Required - The number of calories burned. ``` -------------------------------- ### Profile - Authentication API (3-Legged OAuth) Source: https://platform.fatsecret.com/docs/guides/data-types Endpoints for managing user profiles and authentication status using 3-Legged OAuth. ```APIDOC ## Profile - Authentication API (3-Legged OAuth) ### Create Profile Creates a new user profile. ### Method POST ### Endpoint /profile ### Get Profile Status Retrieves the status of the user's profile. ### Method GET ### Endpoint /profile/status ### Get Profile Auth Retrieves authentication details for the user's profile. ### Method GET ### Endpoint /profile/auth ``` -------------------------------- ### OAuth 1.0 Authentication Parameters Source: https://platform.fatsecret.com/docs/guides/authentication/oauth1 This section details the mandatory parameters required for each request when using OAuth 1.0 for signing fatsecret Platform REST API requests. ```APIDOC ## OAuth 1.0 Authentication Parameters ### Description These parameters must be included in every request when using OAuth 1.0 to authenticate with the fatsecret Platform REST API. ### Parameters #### Query Parameters - **oauth_consumer_key** (String) - Required - Your API key obtained upon developer registration. - **oauth_signature_method** (String) - Required - The method used for signature generation. Only HMAC-SHA1 is supported. - **oauth_timestamp** (Int) - Required - The date and time in seconds since January 1, 1970, 00:00:00 GMT. Must be a positive integer and greater than or equal to the timestamp of previous requests. - **oauth_nonce** (String) - Required - A randomly generated string for the request, used with the timestamp to create a unique value. - **oauth_version** (String) - Required - Must be set to "1.0". - **oauth_signature** (String) - Required - The generated signature, created by concatenating request elements into a single string used for hashing or signing algorithms. ``` -------------------------------- ### Recipe Types API Source: https://platform.fatsecret.com/docs/guides/data-types Endpoints for retrieving a list of all available recipe types. ```APIDOC ## Recipe Types API ### Get All Recipe Types Retrieves a list of all available recipe types. ### Method GET ### Endpoint /recipe_types ### Query Parameters - **page** (Int) - Optional - The page number for pagination. - **max_results** (Int) - Optional - The maximum number of results per page. ``` -------------------------------- ### Profile - Weight Diary API Endpoints Source: https://platform.fatsecret.com/docs/guides/authentication/oauth1 Endpoints for logging and retrieving weight data. ```APIDOC ## Profile - Weight Diary API Endpoints ### Description These endpoints allow users to log and retrieve their weight measurements over time. ### Endpoints - **Update For Date** - **Method**: PUT (Assumed) - **Endpoint**: `/profile/weight/date/{date}` (Assumed path with placeholder) - **Description**: Updates or logs the user's weight for a specific date. - **Get For Month** - **Method**: GET (Assumed) - **Endpoint**: `/profile/weight/month/{year}/{month}` (Assumed path with placeholders) - **Description**: Retrieves all weight log entries for a specified month and year. ``` -------------------------------- ### Localization Source: https://platform.fatsecret.com/docs/guides/storable-data Information regarding localization support in the API. ```APIDOC # fatsecret Platform API Documentation ## Localization* Details on localization features and settings. ``` -------------------------------- ### OAuth Definitions Source: https://platform.fatsecret.com/docs/guides/authentication/oauth1 Key definitions related to OAuth authentication within the FatSecret Platform. ```APIDOC ## OAuth Definitions ### Description Understanding these terms is crucial for implementing OAuth authentication with the FatSecret Platform. ### Definitions - **User**: Refers to you, the developer. - **Consumer**: Refers to your application. - **Consumer Key**: A unique identifier issued to your application upon registration. - **Consumer Secret**: A secret key issued to your application to verify its identity. - **Access Token**: Identifies a user of your application, used for making requests on their behalf. - **Access Secret**: A secret key associated with an Access Token, used to authorize requests made on behalf of a user. ``` -------------------------------- ### Localization Parameters Source: https://platform.fatsecret.com/docs/guides/localization The Localization feature allows for localized responses by specifying region and language parameters. This is a premium feature. ```APIDOC ## Localization **Localization** is a premium feature only made available to select accounts for specific languages and regions. Accounts with access to this feature are able to nominate locale information when executing particular REST API methods. Responses for these methods are localized by specifying an additional parameter named region. While each region has a default language, unique combinations of region and language can be achieved by adding a further parameter named language. Thus the options for localizing responses are as follows: 1. Specify neither **region** nor **language** : The response will default to the "US" (United States) region and "en" (English) language. 2. Specify the **region** only: The response will be in the nominated region, using the region's default language. For instance, if the region "NL" (Netherlands) is specified, the language will default to "nl" (Dutch). 3. Specify both the **region** and **language** : The response will be in the nominated region and the nominated language. ###### Parameters Note: The language parameter is ignored unless region is also specified. NAME | TYPE$ | REQUIRED | DESCRIPTION ---|---|---|--- region | String | Optional | Results will be filtered by region. E.G.: "FR" returns results from France. If not specified this will default to "US" (United States). language | String | Optional | (Ignored unless region is also specified) Results will be in the specified language. E.G.: "fr" returns results in French ``` -------------------------------- ### Profile - Recipes API Endpoints Source: https://platform.fatsecret.com/docs/guides/storable-data Endpoints for managing a user's favorite recipes. ```APIDOC ## Profile - Recipes ### Add Favorite Adds a recipe to the user's favorites. ### Delete Favorite Removes a recipe from the user's favorites. ### Get All Favorites Retrieves all recipes marked as favorites. ``` -------------------------------- ### Profile - Weight Diary API Endpoints Source: https://platform.fatsecret.com/docs/guides/storable-data Endpoints for managing a user's weight diary entries. ```APIDOC ## Profile - Weight Diary ### Update For Date Updates the weight entry for a specific date. ### Get For Month Retrieves all weight entries for a given month. ``` -------------------------------- ### Signature Base String Format Source: https://platform.fatsecret.com/docs/guides/authentication/oauth1 This is the format for constructing the signature base string. It concatenates the HTTP method, request URL, and normalized parameters, all percent-encoded and separated by '&'. ```text **&****&** ``` -------------------------------- ### Recipe Types API Endpoints Source: https://platform.fatsecret.com/docs/guides/authentication/oauth1 Endpoints for retrieving a list of all available recipe types. ```APIDOC ## Recipe Types API Endpoints ### Description This endpoint allows you to retrieve a list of all defined recipe types available on the platform. ### Endpoints - **Get All** - **Method**: GET (Assumed) - **Endpoint**: `/recipe_types` (Assumed path) - **Description**: Fetches a list of all available recipe types. ```