Portal
SandboxAPI v1Not signed inExternal user: —

Python authentication

FoodAPI uses API key authentication on every request. Constructor from foodapi import FoodAPI client = FoodAPI(api_key="foodapi_your_key") The key is sent as…

FoodAPI uses API key authentication on every request.

Constructor

from foodapi import FoodAPI

client = FoodAPI(api_key="foodapi_your_key")

The key is sent as Authorization: Bearer <api_key>.

Environment variable

import os
from foodapi import FoodAPI

client = FoodAPI(api_key=os.environ["FOODAPI_API_KEY"])

Multi-tenant external users

Pass external_user_id to scope pantry and reasoning to an end-user in your product:

client = FoodAPI(
    api_key="foodapi_your_key",
    external_user_id="user_123",
)

Per-request override on reasoning:

client.reason(recipe_id="...", goal="RECOMMENDATION", external_user_id="user_456")

Errors

Exception HTTP When
AuthenticationError 401, 403 Missing/invalid key or insufficient scope
RateLimitError 429 Quota exceeded; check retry_after_seconds
ValidationError 400, 422 Invalid request body or query
NotFoundError 404 Unknown resource id
ServerError 5xx API or gateway failure

Full hierarchy: errors reference.