Atlassian uses cookies to improve your browsing experience, perform analytics and research, and conduct advertising. Accept all cookies to indicate that you agree to our use of cookies on your device. Atlassian cookies and tracking notice, (opens new window)
/
Getting Started with the Trustwell Genesis Foods GraphQL API
Getting Started with the Trustwell Genesis Foods GraphQL API
The Trustwell Genesis Foods API provides a powerful way to access food data, perform analyses, query standard entities, and create new ingredients or recipes. Built on GraphQL, the API allows you to define precisely what data you need and retrieve it efficiently. This guide will walk you through how to authenticate and start making queries and mutations using the API.
Obtaining your API Key
Only Administrators with API Access will have the ability to generate an API Key.
Treat your API Key like a password. Keep it secret; keep it safe.
To start using the Genesis Foods API, follow these steps:
Log into the Genesis Foods application.
In the lower left, click the vertical ellipsis next to your Organization Name / Username.
Select Profile.
Select API Tokens along the top.
Click Create API Token.
Enter a Label. A Label is just the name, meant to provide future reference to identify the intended use of this particular Token.
Click Create Token.
Once created, we recommend using the Copy button to copy the string to the clipboard.
Important: This is the only time you will be able to obtain this Token. Should this be lost, the Token should be deleted and a new one created.
Preserve this Token string as you would other secrets / passwords.
Include this API Key in the request headers for every request you make.
Example API Key Format
Note the example below is meant as a representation of the actual Token. The full string of characters generated will be much longer.
{
"X-API-KEY": "Xi13X6Y8Yhy44bB4Pb6zAzZ..."
}
Notes
The API enforces rate and usage limits.
Requests are only processed over HTTPS. HTTP requests will be redirected to the corresponding HTTPS resource.
The Genesis Foods API uses GraphQL and has a single endpoint. For more information on how GraphQL works, please visit https://graphql.org/.
Authentication/Authorization
You can generate an API Key through the Genesis Foods application, provided your user has the necessary permissions. If you do not have access to generate API Keys, please contact Trustwell Support for assistance.
Include your API Key in the request headers
{
"X-API-KEY": "Xi13X6Y8Yhy44bB4Pb6zAzZ..."
}
API Reference Documentation
The Genesis Foods GraphQL API reference documentation.
The Trustwell Genesis Foods API offers a range of operations that allow you to interact with the system through both queries and mutations. Queries enable you to fetch data, such as searching for foods or retrieving nutritional analysis, while mutations allow you to create or update data, like adding ingredients or recipes. Each operation is designed to be flexible and powerful, giving you control over the specific data you need and minimizing unnecessary overhead.
Below are examples of common API operations, showing how to construct requests and handle responses for both queries and mutations.
Analyzing your foods is a core use case for Genesis. There are 2 types of analyses you can request: Gross and Net.
Query
query($input : GetAnalysisInput!){
analysis{
getAnalysis(input: $input){
analysis{
analysisType
nutrientInfos{
nutrient{
id
name
}
value
}
amountAnalyzed{
quantity{
value
}
unit{
name
}
}
weight{
quantity{
value
}
unit{
name
}
}
}
}
}
}
mutation($input : CreateFoodInput!){
foods{
create(input:$input)
{
food{
id
name
definingAmount{
quantity{
value
}
unit{
id
name
}
}
conversions{
from{
quantity{
value
}
unit{
id
name
}
}
to{
quantity{
value
}
unit{
id
name
}
}
}
}
}
}
}