Aller au contenu principal
Version: 1.0

Eaternity API

The Eaternity Database API is a Web Service that calculates the Climate Score (CO₂ equivalents), the Vita Score and other environmental footprints of recipes, restaurants, and ingredients dynamically.

It includes daily changing information on origin, seasonality and other factors in the calculation.

Key Features

  • Climate Score: Calculate CO₂ equivalents for recipes and ingredients
  • Vita Score: Nutritional quality rating (A-E scale)
  • Environmental Metrics: Water footprint, rainforest impact, animal welfare, seasonality, and local sourcing ratings
  • Forecast: AI-powered sales predictions for kitchens

Terms & Conditions

By accessing the APIs, you accept Eaternity's Terms & Conditions.

Authentication

Authentication

The Eaternity API uses HTTP Basic Authentication. Your API key is the username - no password is required.

How it works

  1. Enter your API key in the Username field below
  2. The password field is not used (leave empty or ignore)
  3. The browser automatically encodes credentials as Base64 in the Authorization header

The resulting header format is: Authorization: Basic <base64(apikey:)>

Test API Key

Contact info@eaternity.ch to request API access.

cURL Example

# The -u flag handles Base64 encoding automatically
# The colon after the API key indicates empty password
curl -u YOUR_API_KEY: \
-H "Content-Type: application/json" \
https://co2.eaternity.ch/api/kitchens

Programmatic Usage

// JavaScript/Node.js
const apiKey = 'YOUR_API_KEY';
const auth = btoa(apiKey + ':'); // Base64 encode "apikey:"

fetch('https://co2.eaternity.ch/api/kitchens', {
headers: {
'Authorization': 'Basic ' + auth,
'Content-Type': 'application/json'
}
});

Security Scheme Type:

http

HTTP Authorization Scheme:

basic


Advanced Information

Localization

The API is designed such that one request may contain information about an object (e.g. a recipe or a supply) in multiple languages. Every JSON field which is subject to localization has a language array as value:

{
"language": "de",
"value": "Kürbisrisotto"
}

The language field must contain one of the ISO 639-1 alpha-2 codes.

ID Generation

The IDs of recipes, kitchens and supplies can be generated in two different ways:

  1. POST request: ID is generated by Eaternity
  2. PUT request: You provide your own ID in the URL (recommended)

The ID can be any alphanumeric value following this regex pattern: [-a-zA-Z0-9+&@#/%?=~_|!:,.;]*[-a-zA-Z0-9+&@#/%=~_|]

Notes on the Format

  • The API accepts JSON in requests and returns JSON in all responses
  • Only UTF-8 character encoding is supported
  • All requests must be encrypted through SSL

SSL & Server Name Indication (SNI)

Since Eaternity uses distributed servers, the IP-address of the service changes and is shared between different applications. To make SSL work, the desired hostname (co2.eaternity.ch) needs to be specified with every request according to the SNI specification:

openssl s_client -connect co2.eaternity.ch:443 -servername eaternity.ch

We recommend whitelisting the Cloudflare root certificate cloudflare_origin_rsa.pem.


HTTP Status Codes

Success Codes

CodeDescription
200Request succeeded
201Resource created successfully
202Request accepted for async processing (Products)
204Resource deleted successfully (no content)

Client Error Codes

CodeDescription
400Bad request - malformed JSON or invalid content
401No authorization - valid API key not provided
403Forbidden - kitchen not authorized for calculations
404Not found - requested resource does not exist
405Method not allowed

Server Error Codes

CodeDescriptionAction
500Server ErrorRetry the request, or contact support

Validation Error Codes

CodeDescriptionAction
422Request Validation Error — request does not match the expected schema (e.g., integer where string was expected)Fix the request format

Processing Error Codes (Eaternity-specific)

These custom status codes indicate specific processing issues:

CodeNameDescriptionAction
601Manual Matching MissingAn ingredient ID is not yet manually matched in the Eaternity DatabaseRetry once daily
602No Automatic MatchAt least one ingredient name could not be automatically matched in the Eaternity DatabaseRetry once daily or try a different ingredient name
610Missing Required PropertyA required resource property was not given in the requestProvide the required field
611Wrong Property ValueA resource property was not provided according to the documentation — wrong format or invalid valueFix the property value
612Sub-Recipe Not FoundA referenced recipe was not provided in this or a previous requestInclude sub-recipe in batch or create it first
670Recipe Has No IngredientsA sub-recipe was referenced with a positive quantity but has no ingredients itselfAdd ingredients to the sub-recipe

Additional implementation-specific codes

The following codes are returned by the calculation engine for specific processing failures. They are not documented in the canonical API specification but may appear in practice.

CodeNameDescriptionAction
671Missing LCA InventoryNo life cycle inventory found for ingredientContact support with term details
672Missing NutrientsNo nutrient data found for ingredientContact support with term details
673Failed Amount EstimationCould not estimate ingredient amountCheck declaration format
674Failed Ingredient SplitterCould not parse ingredient declarationSimplify ingredient declaration
675Unknown UnitIngredient unit not recognizedUse standard units (gram, liter)
678CO2 Calculation FailedCannot calculate CO2 valueCheck ingredient data completeness
679VitaScore Calculation FailedCannot calculate VitaScoreCheck nutrient data availability
680Environment Score FailedCannot calculate environment scoreCheck environmental data availability

Handling 6xx Errors

The 6xx error codes are specific to Eaternity's calculation system:

  • 601/602: Occur when an ingredient cannot be matched to the Eaternity database. The matching process runs daily, so retry after 24 hours or try a more common ingredient name.

  • 610/611: These relate to missing or invalid request properties. Check the request against the API documentation.

  • 612: Verify that sub-recipes are created before referencing them, or include them in the same batch request.

  • 670: Ensure sub-recipes contain at least one ingredient before referencing them.

  • 671-680: These indicate calculation engine issues. Check that ingredient declarations are properly formatted and use standard units.


Choosing Your API

The Eaternity APIs serve different user groups with distinct requirements.

FeatureEaternity APILCA API
Primary UsersRestaurants, Food Manufacturers, ERP SystemsLCA Practitioners, Researchers
Use CaseOperational sustainability trackingScientific LCA research
Data GranularityRecipe/menu levelFull supply chain detail
Batch ProcessingOptimized for high volumeOptimized for precision

Choose the Eaternity API if you are a restaurant or food service operation, integrating with ERP or food management software, tracking menu sustainability metrics, or generating environmental reports for operations.

Choose the LCA API if you are an LCA practitioner or researcher, conducting detailed supply chain analysis, requiring full lifecycle transparency, or working with research-grade environmental data.

Not a Migration

These APIs serve different purposes. There is no need to migrate between them — choose the one that best fits your use case.