Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Introduction

...

Genesis Graph API URLs:

Production: https://api.trustwell.com/genesis

Preview: TBD

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

To start using the Genesis Foods API, you need to - follow these steps:

  1. Log into the Genesis Foods application.

  2. Generate an API Key.

...

    1. Only

...

    1. Administrators with API Access will have the ability to generate an API Key.

...

  1. Include this API Key

...

  1. in the request headers for every request you make.

Example API Key Format

Code Block
{ 
  "X-API-KEY": "XXXYYYYBBBBZZZZ" 
}

Notes

  • The API has enforces rate and usage limits.

  • The API only responds to Requests are only processed over HTTPS. Any requests sent via HTTP return an HTTP 301 redirect to corresponding HTTPS resourcesHTTP requests will be redirected to the corresponding HTTPS resource.

  • The Genesis Foods API is a GraphQL API with uses GraphQL and has a single endpoint. Read more about working with GraphQL API’s hereFor more information on how GraphQL works, please visit http://graphql.org.

Authentication/Authorization

An You can generate an API Key can be generated in through the Genesis Foods application if , provided your user has been given the appropriate permission. Please contact your Account Manager if you don’t see the ability necessary permissions. If you do not have access to generate API Keys, please contact your Account Manager for assistance.The

Include your API Key

...

in the

...

request headers

Code Block
languagejson
{ 
  "X-API-KEY": "XXXYYYYBBBBZZZZ" 
}

API Operations: Queries and Mutations

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.

Info

Genesis GraphQL API URL

Production: https://api.trustwell.com/genesis

Preview: TBD

Searching

Searching for foods is a key action that users utilize to build recipes. Search results are paginated.

...

Expand
titleResponse
Code Block
languagejson
"data": {
        "foods": {
            "search": {
                "foodSearchResults": [
                    ...
                    {
                        "id": "423f0ddd-14b2-4114-8323-7f8ccc11ddac",
                        "name": "granola, prepared from recipe",
                        "modified": "2023-03-27T16:57:27.4906008+00:00",
                        "created": "2023-03-27T16:57:27.4838005+00:00",
                        "versionName": "V1",
                        "foodType": "Ingredient",
                        "product": "USDA",
                        "supplier": "USDA SR-Legacy",
                        "isApproved": true,
                        "versionHistoryId": "4b7f32ab-3bae-469d-bce8-2dfd28b726d0"
                    },
                    {
                        "id": "21b52b33-2fde-498e-9a44-5023f98260b4",
                        "name": "taffy, prepared from recipe",
                        "modified": "2023-03-27T18:53:40.3575528+00:00",
                        "created": "2023-03-27T18:53:40.3504859+00:00",
                        "versionName": "V1",
                        "foodType": "Ingredient",
                        "product": "Canadian Nutrient File",
                        "supplier": "Health Canada (Canadian Nutrient File)",
                        "isApproved": true,
                        "versionHistoryId": "fb308722-32c1-45c8-8666-42ba8e0a329c"
                    },
                    {
                        "id": "a7eaee32-6ecd-4ece-90d0-48300d9d4439",
                        "name": "divinity, prepared from recipe",
                        "modified": "2023-03-27T17:44:05.6121672+00:00",
                        "created": "2023-03-27T17:44:05.6036143+00:00",
                        "versionName": "V1",
                        "foodType": "Ingredient",
                        "product": "USDA",
                        "supplier": "USDA SR-Legacy",
                        "isApproved": true,
                        "versionHistoryId": "db00f784-1a0d-4b14-a4cd-dd53b8487475"
                    },
                    ...
                ],
                "totalCount": 1407,
                "pageInfo": {
                    "cursor": 10,
                    "hasNextPage": true,
                    "startCursor": 0,
                    "endCursor": 1407
                }
            }
        }
    }
}

Getting an Analysis

Querying Standard Entities

Creating an Ingredient

Creating a Recipe