Ingredient Density API
A free JSON API for the question “how many grams is one cup of ___?” — 80 cooking and baking ingredients, with grams per US cup, tablespoon, teaspoon and mL. No API key, no sign-up, CORS enabled, CC BY 4.0.
Quick start
curl https://exactcup.github.io/api/v1/ingredients/honey.json
{
"slug": "honey",
"name": "Honey",
"category": "sugar",
"category_name": "Sugars & Syrups",
"aliases": [],
"grams_per_us_cup": 340,
"grams_per_us_tablespoon": 21.25,
"grams_per_us_teaspoon": 7.083,
"grams_per_ml": 1.4371,
"ounces_per_us_cup": 11.993,
"url": "https://exactcup.github.io/cups-to-grams/honey/",
"conversions": {
"cups_to_grams": [
{
"cups": "1/2",
"grams": 170
},
{
"cups": "2/3",
"grams": 226.7
},
{
"cups": "3/4",
"grams": 255
}
],
"…": "…"
},
"source": "https://exactcup.github.io/ingredient-density-data/",
"license": {
"name": "CC BY 4.0",
"url": "https://creativecommons.org/licenses/by/4.0/"
},
"attribution": {
"required": true,
"text": "Ingredient density data by ExactCup",
"url": "https://exactcup.github.io/",
"html": "<a href=\"https://exactcup.github.io/\">Ingredient density data by ExactCup</a>"
}
}
Endpoints
| Endpoint | Returns |
|---|---|
GET /api/v1/index.json | This document: API metadata, license and the endpoint list. |
GET /api/v1/ingredients.json | Every ingredient with its density (grams per US cup, tablespoon, teaspoon and mL). |
GET /api/v1/ingredients/{slug}.json | One ingredient, plus precomputed cups→grams, tablespoons→grams and grams→cups tables. |
GET /api/v1/categories.json | Ingredient categories with the slugs in each. |
GET /api/v1/units.json | Volume units in mL and weight units in grams, so you can convert any unit yourself. |
Base URL: https://exactcup.github.io/api/v1/ — start at index.json, which lists everything above. Browse the raw files: ingredients.json · categories.json · units.json.
The ingredient object
| Field | Meaning |
|---|---|
slug | Stable identifier, also the URL segment on this site. |
name | Display name, e.g. “All-Purpose Flour”. |
category / category_name | One of 5 groups (flour, sugar, dairy, baking, grain). |
aliases | Other names the ingredient goes by (“plain flour”, “confectioners sugar”) — useful for matching recipe text. |
grams_per_us_cup | The core value: weight in grams of one level US customary cup (236.588 mL). |
grams_per_us_tablespoon / grams_per_us_teaspoon | The same density divided by 16 and 48. |
grams_per_ml | Density in g/mL — multiply by any volume in mL to get grams. |
ounces_per_us_cup | Weight in avoirdupois ounces per US cup. |
url | The human page for that ingredient on ExactCup. |
Converting any unit
Because grams_per_ml is included, one multiply converts any volume unit — US cups, metric cups, imperial fluid ounces, Australian tablespoons — using the mL table in units.json:
const [ing, units] = await Promise.all([
fetch("https://exactcup.github.io/api/v1/ingredients/all-purpose-flour.json").then(r => r.json()),
fetch("https://exactcup.github.io/api/v1/units.json").then(r => r.json()),
]);
// 1.5 metric cups of flour, in grams
const grams = 1.5 * units.volume_ml.metric_cup * ing.grams_per_ml;
// -> 190.2 g
Python is just as short:
import requests
d = requests.get("https://exactcup.github.io/api/v1/ingredients/granulated-sugar.json").json()
print(d["conversions"]["cups_to_grams"]) # [{"cups": "1/8", "grams": ...}, ...]
Terms of use
- Free, no key, no limit. Static files on a CDN. Cache them — don’t proxy a fetch per page view.
- Licence: CC BY 4.0. Commercial use, redistribution and adaptation are all fine.
- Attribution required. Credit ExactCup with a link wherever the numbers appear:
- Accuracy. Nominal values (±~5% in real kitchens) — see the dataset page for method and sources. Don’t use them where a precise weight is safety-critical.
- Versioning. Fields may be added inside
/api/v1/; nothing existing gets removed or renamed. Breaking changes would ship as/api/v2/.
Prefer something ready-made?
If you want the numbers rather than the plumbing: the same data is downloadable as CSV or JSON, there are free embeddable converter widgets for websites, and the cups to grams converter covers every fraction of a cup by hand.
FAQ
Do I need an API key?
No. There is no key, no sign-up and no account. The endpoints are plain JSON files served over HTTPS from a CDN with permissive CORS headers, so you can fetch them straight from browser JavaScript, a server, a shell script or a spreadsheet.
Is there a rate limit?
There is no application rate limit — the files are static and cached by the CDN, so normal use costs nothing. Please cache responses on your side rather than re-fetching per request; the data changes rarely, and every response includes an 'updated' date you can check.
Can I use it in a commercial app?
Yes. The data is licensed CC BY 4.0, which permits commercial use, redistribution and adaptation. The only condition is attribution: credit ExactCup with a link, in your app's about/credits screen or near where the numbers appear.
Where do the numbers come from?
The same verified dataset behind the ExactCup converters: values follow the King Arthur Baking ingredient weight chart, cross-checked against USDA FoodData Central and standard culinary references. They are nominal weights for level, unpacked measures (brown sugar packed), accurate to roughly 5% in real kitchens.
How do I convert grams back to cups?
Divide by the density: cups = grams / grams_per_us_cup. Each per-ingredient document also ships a precomputed grams_to_cups table for common weights (100 g, 250 g, 500 g…), so simple apps need no arithmetic at all.
Does it support metric or UK cups?
Yes — units.json lists every volume unit in millilitres, including the 250 mL metric cup used in the UK, Australia and New Zealand, the 284 mL imperial cup and the 20 mL Australian tablespoon. Multiply the unit's mL value by grams_per_ml to get grams.
Will the URLs keep working?
The /api/v1/ paths are meant to be stable: new fields may be added, but existing fields and paths will not be removed or renamed inside v1. Anything breaking would ship as /api/v2/.