GymTea Food API
Search the public GymTea food catalog and retrieve nutrition data as JSON. No account, login, or API key is required. All endpoints are read-only.
Base URL: https://gymtea.app/api/v1
Machine-readable contract: Download the OpenAPI specification. Agents and API tools can use this JSON file for operation names, parameters, response schemas, and errors. No authentication is required to read it.
Quick start
- Search for ice cream.
- Choose a food from the response’s
foodsarray. - Fetch its
apiUrlto get nutrients and serving sizes.
curl 'https://gymtea.app/api/v1/foods?q=ice%20cream&limit=5'
In JavaScript, follow the returned detail URL rather than constructing one from a food name:
const origin = 'https://gymtea.app';
async function readJson(path) {
const response = await fetch(new URL(path, origin));
if (!response.ok) {
throw new Error(`GymTea API returned HTTP ${response.status}`);
}
return response.json();
}
const results = await readJson('/api/v1/foods?q=ice%20cream&limit=5');
const firstFood = results.foods[0];
if (firstFood) {
const food = await readJson(firstFood.apiUrl);
console.log(food.displayName, food.per100g, food.servingAmounts);
}
Search foods
GET /api/v1/foods?q={query}&limit={limit}&offset={offset}
q— required. Between 2 and 128 UTF-16 code units after trimming, with at most eight words. Matching ignores case and accents. Every query word must appear somewhere in the food name; word order does not matter.limit— optional. Number of results, from 1 to 50. Defaults to 20.offset— optional. Number of matching results to skip, from 0 to 10000. Defaults to 0. Increase it bylimitto retrieve the next page.
URL-encode query values. Unknown parameters, repeated parameters, and invalid
values return HTTP 400.
The response includes schemaVersion, generatedAt, query, limit, offset,
total (all matches), and foods (the requested page). No matches return
HTTP 200 with total: 0 and an empty array.
Each summary in foods contains:
id: stable food identifier, unchanged when the name changes.displayNameandslug: the current name and website slug.imageUrl: image URL, ornullwhen unavailable.pageUrl: absolute URL of the human-readable food page.apiUrl: path of the food’s JSON endpoint, relative tohttps://gymtea.app.
Results are sorted by display name, with ID as a tie-breaker. Pagination can shift when a new catalog snapshot is published.
Get a food’s nutrients
GET /api/v1/foods/{key}.json
Use the apiUrl returned by search or the catalog. The key is an opaque URL
identifier; it is not the food’s name-based website slug. Keep the food’s id
when you need a stable reference across renames.
The response includes the summary fields above, schemaVersion, generatedAt,
nullable description and foodCategory, and:
servingAmounts: an array of serving names and their weight ingrams.per100g: nutrition for 100 grams of the food, containingcaloriesKcal,proteinG,carbsG,fatG, nullablefiberG, andmicronutrients.per100g.micronutrients: an array ofname,amount, andunit, using readable names such as “Vitamin C” and “Calcium” without USDA numeric IDs. Missing amounts arenull, not zero. A unit can also benullwhen unreported. Reported units aremgormcg.
The API exposes the website’s selected vitamins and minerals. It does not expose every nutrient held in the underlying catalog.
To calculate nutrition for a serving, multiply each known per100g amount by
the serving weight in grams divided by 100. Preserve unknown values as null.
Download the catalog
GET /api/v1/food-catalog.json
Open the JSON catalog to retrieve all public food
summaries in one response. It includes schemaVersion, generatedAt, and
foods, using the same summary fields as search. Download once and search
locally when that suits your application; fetch individual detail URLs as needed.
Freshness and caching
Food pages and API responses use a published snapshot. Catalog updates appear
after the next website publication. generatedAt is the snapshot generation
time, not the time of the latest individual food edit. Successful API responses
advertise a five-minute cache lifetime.
Only foods available on the public website are included. A food can be renamed, removed, or hidden in a later snapshot. Check HTTP status codes when following saved detail URLs.
Limits and errors
The public API currently allows approximately 30 requests per 10 seconds per
IP address. Excess requests are blocked for 10 seconds with HTTP 429.
Clients sharing an IP also share this limit. Cache responses and wait before
retrying; avoid sending parallel requests for the entire dataset.
200: successful JSON response, including searches with no matches.400: invalid search parameters (invalid_query).404: food or API route not found (not_found).405: unsupported request method.429: rate limit or service quota reached. Wait before retrying.503: the search catalog is temporarily unavailable (catalog_unavailable).
Check the status before parsing JSON. Rate-limit and hosting errors can have non-JSON bodies. Availability is also subject to the service’s daily request quota; a quota error may require a longer wait than the per-IP rate limit.
Browser access
Cross-origin anonymous GET and HEAD requests are supported. Use a simple
fetch(url) without credentials or custom request headers. Do not set a
Content-Type header on a GET request.
The search endpoint also supports OPTIONS. Existing static catalog and
food-detail files return 405 for OPTIONS, so avoid request headers that
trigger browser preflight for those files.
For questions about the API, contact GymTea support.