Details of the JSON output and object description table of nutrition analysis API of Edamam
In this article, I will clarify the object table and JSON output of the Edamam Nutrition Analysis API. As a programmer, you are likely familiar with the concept of an object table and JSON output, but understanding the specific implementation of these concepts in the Edamam API can be helpful in utilizing the data effectively. By providing a clear explanation of the object table and JSON output, I aim to give you a better understanding of how the data is structured and how you can access and manipulate it to meet your needs.
Object and Description
Objects | Description |
post | |
tags | |
summary | |
description | |
consumes | |
parameters | |
name | |
in | |
x-data-threescale-name | |
description | |
required | |
type |
post: This object represents a single blog post or article. It typically contains information such as the title, author, content, and publication date.
tags: This object contains metadata that is used to categorize or tag blog posts. Tags can be used to group posts together by topic, making it easier for readers to find related content.
summary: This object contains a brief summary of the blog post or article. It is often used as a teaser or preview to give readers a sense of what the post is about before they read the full article.
description: This object contains a longer, more detailed description of the blog post or article. It typically provides more context and information than the summary.
consumes: This object represents the content type that the API endpoint can consume. It defines the format of the data that the API can receive from clients.
parameters: This object contains information about the parameters that can be passed to an API endpoint. Parameters are used to customize the response that the API returns.
name: This object represents the name of a parameter or object.
in: This object represents the location of a parameter or object. For example, a parameter could be in the query string, in the request body, or in the URL path.
x-data-threescale-name: This object is a custom attribute that can be used to specify a different name for a parameter or object than the one defined in the OpenAPI schema.
required: This object specifies whether a parameter is required or optional.
type: This object specifies the data type of a parameter or object. The data type determines the kind of data that can be passed to or returned from the API endpoint.
The information presented in the table is useful because it provides an overview of the different objects that are used in an API endpoint. Understanding the purpose and structure of each object is essential for designing and developing effective API endpoints. For example, knowing the parameters that can be passed to an API endpoint, along with their data type and whether they are required or optional, can help developers create more robust and user-friendly APIs. Additionally, knowing the content type that the API endpoint can consume and the metadata that can be associated with blog posts can help clients interact with the API in a more efficient manner. In summary, the information in the table is useful for both API developers and API consumers, as it helps ensure that APIs are designed to meet the needs of all stakeholders.
JSON output explained
The JSON output describes the endpoints and operations available in the Edamam Nutrition Analysis API. The "swagger" field specifies the version of the Swagger specification used by the API. The "info" object provides basic information about the API, such as the version number, title, and description. The "schemes" field specifies the protocols that the API supports, in this case, HTTPS. The "host" field specifies the hostname of the API. The "tags" field lists the available tags for grouping related API operations. The "paths" object defines the available API endpoints, including the HTTP method used to access each endpoint, the parameters accepted by each endpoint, and the expected response. Specifically, the "post" operation for the "/api/nutrition-details" endpoint returns nutritional information for a given recipe. The "get" operation for the "/api/nutrition-data" endpoint returns nutritional information for a specified food item or ingredient. Both endpoints require authentication via an app ID and app key. The response also includes detailed descriptions of the available parameters and responses for each endpoint.
{
"swagger": "2.0",
"info": {
"version": "1.1",
"title": "",
"description": ""
},
"schemes": [
"https"
],
"host": "api.edamam.com",
"tags": [
{
"name": "Individual Text Line Analysis"
},
{
"name": "Full Recipe Analysis"
}
],
"paths": {
"/api/nutrition-details": {
"post": {
"tags": [
"Full Recipe Analysis"
],
"summary": "<b>Click here to view the documentation</b>",
"description": "This returns the nutritional information based on a POST request of the recipe content. The POST request submits the recipe content, specifically the recipe title and ingredient list. The response the API returns, will contain the nutritional analysis for the recipe based on the information provided.\n \n <b>Access Point:</b> https://api.edamam.com/api/nutrition-details",
"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": "beta",
"in": "query",
"description": "Allow beta features in the request and response",
"type": "boolean"
},
{
"name": "If-None-Match",
"in": "header",
"description": "Each successfully processed recipe will also return a tag in the ETag response header. This value must be preserved together with the recipe. When resubmitting the recipe, you should include the value in the If-None-Match request header and store the updated ETag header.",
"type": "string"
},
{
"name": "force",
"in": "query",
"description": "Forces the re-evaluation of the recipe. The value, if any, is ignored.",
"type": "boolean"
},
{
"name": "body",
"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": {
"type": "object",
"required": [
"title",
"ingr"
],
"properties": {
"title": {
"type": "string"
},
"ingr": {
"type": "array",
"items": {
"type": "string"
}
},
"url": {
"type": "string"
},
"summary": {
"type": "string"
},
"yield": {
"type": "string"
},
"time": {
"type": "string"
},
"img": {
"type": "string"
},
"prep": {
"type": "string"
}
}
}
}
],
"responses": {
"200": {
"description": "OK - Recipe object containing number of servings (yield), total calories for the recipe (calories), nutrient content by nutrient type (totalNutrients, totalDaily), diet and health classification (dietLabels, healthLabels)"
},
"304": {
"description": "Not Modified."
},
"404": {
"description": "Not Found - The specified URL was not found or couldn't be retrieved"
},
"409": {
"description": "The provided ETag token does not match the input data"
},
"422": {
"description": "Unprocessable Entity - Couldn't parse the recipe or extract the nutritional info"
},
"555": {
"description": "Recipe with insufficient quality to process correctly"
}
}
}
},
"/api/nutrition-data": {
"get": {
"tags": [
"Individual Text Line Analysis"
],
"summary": "<b>Click here to view the documentation</b>",
"description": "This returns the nutritional analysis for the specified food text by extracting information from a short unstructured food text (usually an ingredient line and returns the following structured data for the text: quantity, measure and food,) and if available: diet, health and allergen labels for the text. With the built in food logging feature, this allows for change of context. For example, “rice” will normally be matched to raw rice while, with the food logging feature on, it will match to ready to eat ‘cooked rice.’ \n \n <b>Access Point:</b> https://api.edamam.com/api/nutrition-data",
"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": "nutrition-type",
"in": "query",
"description": "Select between the cooking and food logging processor.",
"type": "string",
"default": "cooking",
"enum": [
"cooking",
"logging"
]
},
{
"name": "ingr",
"in": "query",
"description": "The ingredient.",
"required": true,
"type": "string"
},
{
"name": "If-None-Match",
"in": "header",
"description": "First, each successfully processed recipe will also return a tag in the ETag response header. This value must be preserved together with the recipe. Then, when resubmitting the recipe, you should include the value in the 'If-None-Match' request header.",
"type": "string"
}
],
"responses": {
"200": {
"description": "OK - Recipe object containing: number of servings (yield), total calories for the recipe (calories), nutrient content by nutrient type (totalNutrients, totalDaily), and diet and health classifications (dietLabels, healthLabels)"
},
"304": {
"description": "Not Modified"
},
"404": {
"description": "Not Found - The specified URL was not found or couldn't be retrieved"
},
"409": {
"description": "The provided ETag token does not match the input data"
},
"422": {
"description": "Unprocessable Entity - Couldn't parse the recipe or extract the nutritional info"
},
"555": {
"description": "Recipe with insufficient quality to process correctly"
}
}
}
}
}
}
In summary
In this article, we discussed the structure and purpose of an object table and JSON output, as well as the use case and content of the Edamam Nutrition Analysis API. We examined a table of objects used in the API and provided a detailed description of each object, highlighting their significance in developing and utilizing effective API endpoints. Additionally, we analyzed a sample JSON output of the API, which provided information on the available endpoints, operations, parameters, and responses. Overall, this conversation sheds light on the importance of understanding the structure and content of API documentation in developing effective and efficient applications.
Endnote
You can request access to the Edamam Nutrition Analysis API through the third-party data marketplace of World in Data. World in Data is a platform that provides a range of data sources and APIs for developers, researchers, and data scientists. To access the Edamam API through World in Data, you need to create an account on the World in Data website and navigate to the API section. From there, you can request access to the Edamam API and obtain an API key. Once you have the API key, you can use it to access the various endpoints of the API and retrieve nutritional information for recipes or food items. The World in Data platform provides a convenient and user-friendly way to obtain access to the Edamam API and incorporate its features into your application.