How does the JSON output and object description table of food information API created by Edamam work?

In this article, I will provide a clear understanding of the object table and JSON output of the Edamam food information API. As a programmer, it is essential to have a comprehensive understanding of these concepts to extract the necessary information accurately. The object table is a data structure used to store information in a table format, where each column represents a unique attribute, and each row contains the values of the attributes for a specific instance. On the other hand, JSON (JavaScript Object Notation) is a lightweight data interchange format used for data transfer between servers and web applications. By understanding the structure and content of the object table and JSON output, programmers can effectively retrieve and manipulate data from the Edamam food information API.

Object and Description of API Output

ObjectsDescription
tags
name
paths
summary
description
name
in
collectionFormat
uniqueItems
items
type
enum
  • tags: An array of strings used to categorize and organize data in a meaningful way.

  • name: A string that represents the name of an object.

  • paths: A collection of paths used to access and manipulate data.

  • summary: A brief description or summary of an object.

  • description: A more detailed description of an object.

  • in: Specifies the location of an object in a request (e.g., query string, header, path, etc.).

  • collectionFormat: Specifies the format of an array in a request (e.g., CSV, TSV, etc.).

  • uniqueItems: A boolean that indicates whether an array should contain only unique items.

  • items: Defines the type and format of items in an array.

  • type: Specifies the data type of an object.

  • enum: An array of possible values for an object.

The information in the table is useful for developers who are working with APIs and need to understand the structure and meaning of the data being returned. By knowing the objects and their descriptions, developers can better understand how to interact with the API and how to parse and use the data in their applications. For example, understanding the "in" object can help developers know where to look for specific data in a request, while knowing the "type" object can help them determine how to handle and format the data. Additionally, having a clear understanding of the objects can help developers communicate more effectively with other members of their team and with the API provider.

JSON explained

The JSON output provided is the specification of the Edamam Food Information API, which is a RESTful web service that provides access to food and nutrition-related data. The output describes various objects, including the "swagger" version, "info" about the API, "schemes" for accessing the API, "host" where the API is located, "tags" for categorizing the endpoints, and "paths" containing the endpoints and their corresponding methods. The output also includes "parameters" that specify the information required to access the endpoints and "responses" that indicate the type of data that will be returned. Additionally, the output defines "definitions" that specify the objects used in the API and their properties. Overall, this JSON output serves as a reference guide for developers looking to integrate the Edamam Food Information API into their applications.

{
"swagger": "2.0",
"info": {
"version": "2.0",
"title": "",
"description": ""
},
"schemes": [
"https"
],
"host": "api.edamam.com",
"tags": [
{
"name": "Food Request Step 1 - Parser"
},
{
"name": "Food Request Step 2 - Nutrients"
},
{
"name": "Food Search Autocomplete"
}
],
"paths": {
"/api/food-database/v2/parser": {
"get": {
"tags": [
"Food Request Step 1 - Parser"
],
"summary": "<b>Click here to view the documentation</b>",
"description": "The parser access point handles text search for foods as well as filters for the foods like presence specific nutrient content or exclusion of allergens. <ul> <li>Search for a phrase or keyword using NLP to get food entities from it.</li> <li> Get basic nutrition facts and ingredients for each food </li> <li> Search for food by given nutrient quantity for 28 nutrients </li> <li> Search for foods within a given brand </li> <li> With the build in food-logging context it allows for requests which do not contain quantity and suggest expected quantities for them. </li> </ul>\n \n <b>Access Point:</b> https://api.edamam.com/api/food-database/v2/parser",
"parameters
": [
{
"name": "app_id",
"in": "query",
"x-data-threescale-name": "app_ids",
"description": "The application ID",
"required": true,
"type": "string"
},
{
"name": "app_key",
"in": "query",
"x-data-threescale-name": "app_keys",
"description": "The application key",
"required": true,
"type": "string"
},
{
"name": "ingr",
"in": "query",
"description": "A keyword search parameter to be found in the food name. Not required when upc is present",
"type": "string"
},
{
"name": "upc",
"in": "query",
"description": " valid UPC, EAN, or PLU code. Not required when ingr is present",
"type": "string"
},
{
"name": "nutrition-type",
"in": "query",
"description": "Select between cooking and food logging processor.",
"type": "string",
"default": "cooking",
"enum": [
"cooking",
"logging"
]
},
{
"name": "health",
"in": "query",
"description": "Health label",
"type": "array",
"collectionFormat": "multi",
"uniqueItems": true,
"items": {
"type": "string",
"enum": [
"alcohol-free",
"celery-free",
"crustacean-free",
"dairy-free",
"egg-free",
"fish-free",
"fodmap-free",
"gluten-free",
"immuno-supportive",
"keto-friendly",
"kidney-friendly",
"kosher",
"low-fat-abs",
"low-potassium",
"low-sugar",
"lupine-free",
"mustard-free",
"no-oil-added",
"paleo",
"peanut-free",
"pescatarian",
"pork-free",
"red-meat-free",
"sesame-free",
"shellfish-free",
"soy-free",
"sugar-conscious",
"tree-nut-free",
"vegan",
"vegetarian",
"wheat-free"
]
}
},
{
"name": "calories",
"in": "query",
"description": "The format is calories=RANGE where RANGE is replaced by the value in kcal. RANGE is in one of MIN+, MIN-MAX or MAX, where MIN and MAX are non-negative integer numbers. The + symbol needs to be properly encoded. Examples: “calories=100-300” will return all recipes with which have between 100 and 300 kcal per serving.",
"type": "string"
},
{
"name": "category",
"in": "query",
"description": "Categories",
"type": "array",
"collectionFormat": "multi",
"uniqueItems": true,
"items": {
"type": "string",
"enum": [
"generic-foods",
"generic-meals",
"packaged-foods",
"fast-foods"
]
}
},
{
"name": "nutrients[CA]",
"in": "query",
"description": "Calcium, Ca. Unit: mg. Input the range which is one of MIN+, MIN-MAX or MAX, where MIN and MAX are non-negative floating point numbers. <br> <br> For example: nutrients[CA]=50+ means minimum 50mg calcium, where ‘50+’ has to be properly encoded as ‘50%2B’ nutrients[FAT]=30 means maximum 30g fat and nutrients[FE]=5-10 means iron between 5mg and 10mg inclusive",
"pattern": "(?:[+-]?\\d+(?:\\.\\d*)?)|(?:(?:[+-]?\\d+(?:\\.\\d*)?)-(?:[+-]?\\d+(?:\\.\\d*)?))|(?:(?:[+-]?\\d+(?:\\.\\d*)?)[+-])",
"type": "string"
},
{
"name": "nutrients[CHOCDF]",
"in": "query",
"description": "Carbohydrate, by difference. Unit: g. Input the range which is one of MIN+, MIN-MAX or MAX, where MIN and MAX are non-negative floating point numbers. <br> <br> See calcium for an example for how to fill in the range.",
"pattern": "(?:[+-]?\\d+(?:\\.\\d*)?)|(?:(?:[+-]?\\d+(?:\\.\\d*)?)-(?:[+-]?\\d+(?:\\.\\d*)?))|(?:(?:[+-]?\\d+(?:\\.\\d*)?)[+-])",
"type": "string"
},
{
"name": "nutrients[CHOCDF.net]",
"in": "query",
"description": "Carbohydrates (net). Unit: g. Input the range which is one of MIN+, MIN-MAX or MAX, where MIN and MAX are non-negative floating point numbers. <br> <br> See calcium for an example for how to fill in the range.",
"pattern": "(?:[+-]?\\d+(?:\\.\\d*)?)|(?:(?:[+-]?\\d+(?:\\.\\d*)?)-(?:[+-]?\\d+(?:\\.\\d*)?))|(?:(?:[+-]?\\d+(?:\\.\\d*)?)[+-])",
"type": "string"
},
{
"name": "nutrients[CHOLE]",
"in": "query",
"description": "Cholesterol. Unit: mg. Input the range which is one of MIN+, MIN-MAX or MAX, where MIN and MAX are non-negative floating point numbers. <br> <br>See calcium for an example for how to fill in the range.",
"pattern": "(?:[+-]?\\d+(?:\\.\\d*)?)|(?:(?:[+-]?\\d+(?:\\.\\d*)?)-(?:[+-]?\\d+(?:\\.\\d*)?))|(?:(?:[+-]?\\d+(?:\\.\\d*)?)[+-])",
"type": "string"
},
{
"name": "nutrients[ENERC_KCAL]",
"in": "query",
"description": "Energy. Unit: kcal. Input the range which is one of MIN+, MIN-MAX or MAX, where MIN and MAX are non-negative floating point numbers. <br> <br> See calcium for an example for how to fill in the range.",
"pattern": "(?:[+-]?\\d+(?:\\.\\d*)?)|(?:(?:[+-]?\\d+(?:\\.\\d*)?)-(?:[+-]?\\d+(?:\\.\\d*)?))|(?:(?:[+-]?\\d+(?:\\.\\d*)?)[+-])",
"type": "string"
},
{
"name": "nutrients[FAMS]",
"in": "query",
"description": "Fatty acids, total monounsaturated. Unit: g. Input the range which is one of MIN+, MIN-MAX or MAX, where MIN and MAX are non-negative floating point numbers. <br> <br> See calcium for an example for how to fill in the range.",
"pattern": "(?:[+-]?\\d+(?:\\.\\d*)?)|(?:(?:[+-]?\\d+(?:\\.\\d*)?)-(?:[+-]?\\d+(?:\\.\\d*)?))|(?:(?:[+-]?\\d+(?:\\.\\d*)?)[+-])",
"type": "string"
},
{
"name": "nutrients[FIBTG]",
"in": "query",
"description": "Fiber, total dietary. Unit: g. Input the range which is one of MIN+, MIN-MAX or MAX, where MIN and MAX are non-negative floating point numbers. <br> <br> See calcium for an example for how to fill in the range.",
"pattern": "(?:[+-]?\\d+(?:\\.\\d*)?)|(?:(?:[+-]?\\d+(?:\\.\\d*)?)-(?:[+-]?\\d+(?:\\.\\d*)?))|(?:(?:[+-]?\\d+(?:\\.\\d*)?)[+-])",
"type": "string"
},
{
"name": "nutrients[FOLAC]",
"in": "query",
"description": "Folic acid. Unit: µg. Input the range which is one of MIN+, MIN-MAX or MAX, where MIN and MAX are non-negative floating point numbers. <br> <br> See calcium for an example for how to fill in the range.",
"pattern": "(?:[+-]?\\d+(?:\\.\\d*)?)|(?:(?:[+-]?\\d+(?:\\.\\d*)?)-(?:[+-]?\\d+(?:\\.\\d*)?))|(?:(?:[+-]?\\d+(?:\\.\\d*)?)[+-])",
"type": "string"
},
{
"name": "nutrients[FOLDFE]",
"in": "query",
"description": "Folate, DFE. Unit: µg. Input the range which is one of MIN+, MIN-MAX or MAX, where MIN and MAX are non-negative floating point numbers. <br> <br> See calcium for an example for how to fill in the range.",
"pattern": "(?:[+-]?\\d+(?:\\.\\d*)?)|(?:(?:[+-]?\\d+(?:\\.\\d*)?)-(?:[+-]?\\d+(?:\\.\\d*)?))|(?:(?:[+-]?\\d+(?:\\.\\d*)?)[+-])",
"type": "string"
},
{
"name": "nutrients[FOLFD]",
"in": "query",
"description": "Folate (food). Unit: µg. Input the range which is one of MIN+, MIN-MAX or MAX, where MIN and MAX are non-negative floating point numbers. <br> <br> See calcium for an example for how to fill in the range.",
"pattern": "(?:[+-]?\\d+(?:\\.\\d*)?)|(?:(?:[+-]?\\d+(?:\\.\\d*)?)-(?:[+-]?\\d+(?:\\.\\d*)?))|(?:(?:[+-]?\\d+(?:\\.\\d*)?)[+-])",
"type": "string"
},
{
"name": "nutrients[K]",
"in": "query",
"description": "Potassium, K. Unit: mg. Input the range which is one of MIN+, MIN-MAX or MAX, where MIN and MAX are non-negative floating point numbers. <br> <br> See calcium for an example for how to fill in the range.",
"pattern": "(?:[+-]?\\d+(?:\\.\\d*)?)|(?:(?:[+-]?\\d+(?:\\.\\d*)?)-(?:[+-]?\\d+(?:\\.\\d*)?))|(?:(?:[+-]?\\d+(?:\\.\\d*)?)[+-])",
"type": "string"
},
{
"name": "nutrients[MG]",
"in": "query",
"description": "Magnesium. Unit: mg. Input the range which is one of MIN+, MIN-MAX or MAX, where MIN and MAX are non-negative floating point numbers. <br> <br> See calcium for an example for how to fill in the range.",
"pattern": "(?:[+-]?\\d+(?:\\.\\d*)?)|(?:(?:[+-]?\\d+(?:\\.\\d*)?)-(?:[+-]?\\d+(?:\\.\\d*)?))|(?:(?:[+-]?\\d+(?:\\.\\d*)?)[+-])",
"type": "string"
},
{
"name": "nutrients[VITB12]",
"in": "query",
"description": "Vitamin B12. Unit: µg. Input the range which is one of MIN+, MIN-MAX or MAX, where MIN and MAX are non-negative floating point numbers. <br> <br> See calcium for an example for how to fill in the range.",
"pattern": "(?:[+-]?\\d+(?:\\.\\d*)?)|(?:(?:[+-]?\\d+(?:\\.\\d*)?)-(?:[+-]?\\d+(?:\\.\\d*)?))|(?:(?:[+-]?\\d+(?:\\.\\d*)?)[+-])",
"type": "string"
},
{
"name": "nutrients[VITB6A]",
"in": "query",
"description": "Vitamin B6. Unit: mg. Input the range which is one of MIN+, MIN-MAX or MAX, where MIN and MAX are non-negative floating point numbers. <br> <br> See calcium for an example for how to fill in the range.",
"pattern": "(?:[+-]?\\d+(?:\\.\\d*)?)|(?:(?:[+-]?\\d+(?:\\.\\d*)?)-(?:[+-]?\\d+(?:\\.\\d*)?))|(?:(?:[+-]?\\d+(?:\\.\\d*)?)[+-])",
"type": "string"
},
{
"name": "nutrients[VITC]",
"in": "query",
"description": "Vitamin C, total ascorbic acid. Unit: mg. Input the range which is one of MIN+, MIN-MAX or MAX, where MIN and MAX are non-negative floating point numbers. <br> <br> See calcium for an example for how to fill in the range.",
"pattern": "(?:[+-]?\\d+(?:\\.\\d*)?)|(?:(?:[+-]?\\d+(?:\\.\\d*)?)-(?:[+-]?\\d+(?:\\.\\d*)?))|(?:(?:[+-]?\\d+(?:\\.\\d*)?)[+-])",
"type": "string"
},
{
"name": "nutrients[VITD]",
"in": "query",
"description": "Vitamin D (D2 + D3). Unit: µg. Input the range which is one of MIN+, MIN-MAX or MAX, where MIN and MAX are non-negative floating point numbers. <br> <br> See calcium for an example for how to fill in the range.",
"pattern": "(?:[+-]?\\d+(?:\\.\\d*)?)|(?:(?:[+-]?\\d+(?:\\.\\d*)?)-(?:[+-]?\\d+(?:\\.\\d*)?))|(?:(?:[+-]?\\d+(?:\\.\\d*)?)[+-])",
"type": "string"
},
{
"name": "nutrients[VITK1]",
"in": "query",
"description": "Vitamin K (phylloquinone). Unit: µg. Input the range which is one of MIN+, MIN-MAX or MAX, where MIN and MAX are non-negative floating point numbers. <br> <br> See calcium for an example for how to fill in the range.",
"pattern": "(?:[+-]?\\d+(?:\\.\\d*)?)|(?:(?:[+-]?\\d+(?:\\.\\d*)?)-(?:[+-]?\\d+(?:\\.\\d*)?))|(?:(?:[+-]?\\d+(?:\\.\\d*)?)[+-])",
"type": "string"
},
{
"name": "nutrients[WATER]",
"in": "query",
"description": "Water. Unit: g. Input the range which is one of MIN+, MIN-MAX or MAX, where MIN and MAX are non-negative floating point numbers. <br> <br> See calcium for an example for how to fill in the range.",
"pattern": "(?:[+-]?\\d+(?:\\.\\d*)?)|(?:(?:[+-]?\\d+(?:\\.\\d*)?)-(?:[+-]?\\d+(?:\\.\\d*)?))|(?:(?:[+-]?\\d+(?:\\.\\d*)?)[+-])",
"type": "string"
},
{
"name": "nutrients[ZN]",
"in": "query",
"description": "Zinc, Zn. Unit: mg. Input the range which is one of MIN+, MIN-MAX or MAX, where MIN and MAX are non-negative floating point numbers. <br> <br> See calcium for an example for how to fill in the range.",
"pattern": "(?:[+-]?\\d+(?:\\.\\d*)?)|(?:(?:[+-]?\\d+(?:\\.\\d*)?)-(?:[+-]?\\d+(?:\\.\\d*)?))|(?:(?:[+-]?\\d+(?:\\.\\d*)?)[+-])",
"type": "string"
}
],
"responses": {
"200": {
"description": "List of food objects, with each food object containing: kcal per 100gr, protein per 100 grams, carbohydrates per 100 grams, brand of the food, if the food is generic or brandid, a list of existing measures for the food, contents label of the food"
},
"404": {
"description": "The specified URL was not found or couldn’t be retrieved",
"schema": {
"$ref": "#/definitions/Errors"
}
}
}
}
},
"/api/food-database/v2/nutrients": {
"post": {
"tags": [
"Food Request Step 2 - Nutrients"
],
"summary": "<b>Click here to view the documentation</b>",
"description": "In the response to your parser request you receive the a food ID for each database match. Using the food ID and the measure URI, which parser provides, you can make a request to the nutrients access point. The nutrients access points returns nutrition with diet and health labels for a given quantity of the food.\n \n <b>Access Point:</b> https://api.edamam.com/api/food-database/v2/nutrients",
"consumes
": [
"application/json"
],
"parameters": [
{
"name": "app_id",
"in": "query",
"x-data-threescale-name": "app_ids",
"description": "App ID from your dashboard",
"required": true,
"type": "string"
},
{
"name": "app_key",
"in": "query",
"x-data-threescale-name": "app_keys",
"description": "App key from your dashboard",
"required": true,
"type": "string"
},
{
"name": "ingredients",
"in": "body",
"description": "Using the food ID and the measure URI which parser provides you can make a request to the nutrients access point. The nutrients access points returns nutrition with diet and health labels for a given quantity of the food.",
"required": true,
"schema": {
"$ref": "#/definitions/List"
}
}
],
"responses": {
"200": {
"description": "Object containing number of servings (yield), total calories for the food (calories), nutrient content by nutrient type (totalNutrients, totalDaily), diet and health classification (dietLabels, healthLabels)"
},
"404": {
"description": "The specified URL was not found or couldn’t be retrieved",
"schema": {
"$ref": "#/definitions/Errors"
}
},
"422": {
"description": "Couldn’t parse the request or extract the nutritional info",
"schema": {
"$ref": "#/definitions/Errors"
}
},
"555": {
"description": "Text with insufficient quality to process correctly",
"schema": {
"$ref": "#/definitions/Errors"
}
}
}
}
},
"/auto-complete": {
"get": {
"tags": [
"Food Search Autocomplete"
],
"summary": "<b>Click here to view the documentation</b>",
"description": "Edamam provides a convenient autocomplete functionality which can be implemented for use when searching for ingredients. Just send in the current query as the \"q\" parameter and the number of suggestions you wish to receive as the \"limit\" parameter. \n \n <b>Access Point:</b> https://api.edamam.com/auto-complete",
"parameters
": [
{
"name": "app_id",
"in": "query",
"x-data-threescale-name": "app_ids",
"description": "The application ID",
"required": true,
"type": "string"
},
{
"name": "app_key",
"in": "query",
"x-data-threescale-name": "app_keys",
"description": "The application key",
"required": true,
"type": "string"
},
{
"name": "q",
"in": "query",
"description": "Query text. For example q=chi. This or the r parameter are required",
"required": true,
"type": "string"
},
{
"name": "limit",
"in": "query",
"description": "response limit",
"type": "integer"
}
],
"responses": {
"200": {
"description": "Object containing number of servings (yield), total calories for the food (calories), nutrient content by nutrient type (totalNutrients, totalDaily), diet and health classification (dietLabels, healthLabels)"
}
}
}
}
},
"definitions": {
"Ingredients": {
"type": "object",
"properties": {
"quantity": {
"type": "number"
},
"measureURI": {
"type": "string"
},
"foodId": {
"type": "string"
}
}
},
"Errors": {
"type": "array",
"items": {
"$ref": "#/definitions/Error"
}
},
"Error": {
"properties": {
"errorCode": {
"type": "string"
},
"message": {
"type": "string"
},
"params": {
"type": "array",
"items": {
"type": "string"
}
}
}
},
"List": {
"type": "object",
"properties": {
"ingredients": {
"type": "array",
"items": {
"$ref": "#/definitions/Ingredients"
}
}
}
}
}
}

Conclusion

In this article, we discussed the concept of object tables and JSON output in the context of the Edamam food information API. We started by creating an object table and then described each object in detail. We then looked at a sample JSON output from the API, where we analyzed the various objects, their properties, and their usefulness. Overall, the conversation provided insight into how object tables and JSON outputs are used in APIs and highlighted the importance of understanding these concepts for effective data analysis and programming.

Footnote

You can request access to the Edamam food information API through the third party data marketplace of Worldindata. Worldindata provides access to a wide range of APIs, including Edamam's food information API, which allows developers to retrieve detailed nutrition data for a vast array of food products. By leveraging this API, developers can create innovative applications and services that help people make more informed decisions about their diet and nutrition. To request access to the Edamam food information API on Worldindata, you can visit their website and follow the steps outlined in the API documentation.