Nutrition API
Overview
To use Nutrition, you need an API key. You can get one by creating a free account and visiting your dashboard.
GET Endpoint
https://api.apiverve.com/v1/nutritionExample
How to call the Nutrition API in different programming languages.
curl -X GET \
"https://api.apiverve.com/v1/nutrition?food=banana&grams=118" \
-H "X-API-Key: your_api_key_here"const response = await fetch('https://api.apiverve.com/v1/nutrition?food=banana&grams=118', {
method: 'GET',
headers: {
'X-API-Key': 'your_api_key_here',
'Content-Type': 'application/json'
}
});
const data = await response.json();
console.log(data);import requests
headers = {
'X-API-Key': 'your_api_key_here',
'Content-Type': 'application/json'
}
response = requests.get('https://api.apiverve.com/v1/nutrition?food=banana&grams=118', headers=headers)
data = response.json()
print(data)package main
import (
"fmt"
"io"
"net/http"
)
func main() {
req, _ := http.NewRequest("GET", "https://api.apiverve.com/v1/nutrition?food=banana&grams=118", nil)
req.Header.Set("X-API-Key", "your_api_key_here")
req.Header.Set("Content-Type", "application/json")
client := &http.Client{}
resp, err := client.Do(req)
if err != nil {
panic(err)
}
defer resp.Body.Close()
body, _ := io.ReadAll(resp.Body)
fmt.Println(string(body))
}{
"status": "ok",
"error": null,
"data": {
"food": "Bananas, raw",
"fdcId": 173944,
"category": "Fruits and Fruit Juices",
"basis": "per 100g",
"servingSizes": [
{
"label": "1 NLEA serving",
"grams": 126
},
{
"label": "1 extra large (9\" or longer)",
"grams": 152
},
{
"label": "1 large (8\" to 8-7/8\" long)",
"grams": 136
}
],
"nutrition": {
"calories": 89,
"protein": 1.09,
"totalFat": 0.33,
"carbohydrates": 22.8,
"fiber": 2.6,
"sugars": 12.2
},
"micronutrients": {
"sodium": 1,
"potassium": 358,
"cholesterol": 0,
"saturatedFat": 0.112,
"transFat": 0,
"monounsaturatedFat": 0.032,
"polyunsaturatedFat": 0.073,
"calcium": 5,
"iron": 0.26,
"magnesium": 27,
"phosphorus": 22,
"zinc": 0.15,
"vitaminC": 8.7,
"vitaminA": 3,
"vitaminD": 0,
"vitaminE": 0.1,
"vitaminK": 0.5,
"thiamin": 0.031,
"riboflavin": 0.073,
"niacin": 0.665,
"vitaminB6": 0.367,
"folate": 20,
"vitaminB12": 0,
"water": 74.9
},
"analytics": {
"caloriesPerGram": 0.89,
"proteinCaloriePercent": 4.4,
"fatCaloriePercent": 3,
"carbCaloriePercent": 92.6,
"proteinPer100Calories": 1.22
}
}
}Authentication
The Nutrition API requires authentication via API key. Include your API key in the request header:
X-API-Key: your_api_key_hereInteractive API Playground
Test the Nutrition API directly in your browser with live requests and responses.
Parameters
The following parameters are available for the Nutrition API:
Get Nutrition Facts by Food Name
| Parameter | Type | Required | Description | Default | Example |
|---|---|---|---|---|---|
food | string | required | Name of the food to look up (e.g. banana, chicken breast, olive oil) Length: 1 - 100 chars | - | |
gramsPremium | number | optional | Serving weight in grams to scale the nutrition panel to. Defaults to a per-100-gram basis. Range: 1 - 10000 | - |
Response
The Nutrition API returns responses in JSON, XML, YAML, and CSV formats. The JSON response is shown in the Example section above; alternative formats below.
Other Response Formats
<?xml version="1.0" encoding="UTF-8"?>
<response>
<status>ok</status>
<error xsi:nil="true" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/>
<data>
<food>Bananas, raw</food>
<fdcId>173944</fdcId>
<category>Fruits and Fruit Juices</category>
<basis>per 100g</basis>
<servingSizes>
<servingSize>
<label>1 NLEA serving</label>
<grams>126</grams>
</servingSize>
<servingSize>
<label>1 extra large (9" or longer)</label>
<grams>152</grams>
</servingSize>
<servingSize>
<label>1 large (8" to 8-7/8" long)</label>
<grams>136</grams>
</servingSize>
</servingSizes>
<nutrition>
<calories>89</calories>
<protein>1.09</protein>
<totalFat>0.33</totalFat>
<carbohydrates>22.8</carbohydrates>
<fiber>2.6</fiber>
<sugars>12.2</sugars>
</nutrition>
<micronutrients>
<sodium>1</sodium>
<potassium>358</potassium>
<cholesterol>0</cholesterol>
<saturatedFat>0.112</saturatedFat>
<transFat>0</transFat>
<monounsaturatedFat>0.032</monounsaturatedFat>
<polyunsaturatedFat>0.073</polyunsaturatedFat>
<calcium>5</calcium>
<iron>0.26</iron>
<magnesium>27</magnesium>
<phosphorus>22</phosphorus>
<zinc>0.15</zinc>
<vitaminC>8.7</vitaminC>
<vitaminA>3</vitaminA>
<vitaminD>0</vitaminD>
<vitaminE>0.1</vitaminE>
<vitaminK>0.5</vitaminK>
<thiamin>0.031</thiamin>
<riboflavin>0.073</riboflavin>
<niacin>0.665</niacin>
<vitaminB6>0.367</vitaminB6>
<folate>20</folate>
<vitaminB12>0</vitaminB12>
<water>74.9</water>
</micronutrients>
<analytics>
<caloriesPerGram>0.89</caloriesPerGram>
<proteinCaloriePercent>4.4</proteinCaloriePercent>
<fatCaloriePercent>3</fatCaloriePercent>
<carbCaloriePercent>92.6</carbCaloriePercent>
<proteinPer100Calories>1.22</proteinPer100Calories>
</analytics>
</data>
</response>
status: ok
error: null
data:
food: Bananas, raw
fdcId: 173944
category: Fruits and Fruit Juices
basis: per 100g
servingSizes:
- label: 1 NLEA serving
grams: 126
- label: 1 extra large (9" or longer)
grams: 152
- label: 1 large (8" to 8-7/8" long)
grams: 136
nutrition:
calories: 89
protein: 1.09
totalFat: 0.33
carbohydrates: 22.8
fiber: 2.6
sugars: 12.2
micronutrients:
sodium: 1
potassium: 358
cholesterol: 0
saturatedFat: 0.112
transFat: 0
monounsaturatedFat: 0.032
polyunsaturatedFat: 0.073
calcium: 5
iron: 0.26
magnesium: 27
phosphorus: 22
zinc: 0.15
vitaminC: 8.7
vitaminA: 3
vitaminD: 0
vitaminE: 0.1
vitaminK: 0.5
thiamin: 0.031
riboflavin: 0.073
niacin: 0.665
vitaminB6: 0.367
folate: 20
vitaminB12: 0
water: 74.9
analytics:
caloriesPerGram: 0.89
proteinCaloriePercent: 4.4
fatCaloriePercent: 3
carbCaloriePercent: 92.6
proteinPer100Calories: 1.22
| key | value |
|---|---|
| food | Bananas, raw |
| fdcId | 173944 |
| category | Fruits and Fruit Juices |
| basis | per 100g |
| servingSizes | [{label:1 NLEA serving,grams:126},{label:1 extra large (9\ or longer),grams:152},{label:1 large (8\ to 8-7/8\ long),grams:136}] |
| nutrition | {calories:89,protein:1.09,totalFat:0.33,carbohydrates:22.8,fiber:2.6,sugars:12.2} |
| micronutrients | {sodium:1,potassium:358,cholesterol:0,saturatedFat:0.112,transFat:0,monounsaturatedFat:0.032,polyunsaturatedFat:0.073,calcium:5,iron:0.26,magnesium:27,phosphorus:22,zinc:0.15,vitaminC:8.7,vitaminA:3,vitaminD:0,vitaminE:0.1,vitaminK:0.5,thiamin:0.031,riboflavin:0.073,niacin:0.665,vitaminB6:0.367,folate:20,vitaminB12:0,water:74.9} |
| analytics | {caloriesPerGram:0.89,proteinCaloriePercent:4.4,fatCaloriePercent:3,carbCaloriePercent:92.6,proteinPer100Calories:1.22} |
Response Structure
All API responses follow a consistent structure with the following fields:
| Field | Type | Description | Example |
|---|---|---|---|
status | string | Indicates whether the request was successful ("ok") or failed ("error") | ok |
error | string | null | Contains error message if status is "error", otherwise null | null |
data | object | null | Contains the API response data if successful, otherwise null | {...} |
Learn more about response formats →
Response Data Fields
When the request is successful, the data object contains the following fields:
| Field | Type | Sample Value | Description |
|---|---|---|---|
food | string | Matched food name from the USDA database | |
fdcId | number | USDA FoodData Central unique identifier for the food | |
category | string | USDA food category the item belongs to | |
basis | string | Basis the nutrition values are reported on (per 100g, or the requested serving) | |
| [ ] Array items: | array[3] | Common household serving sizes reported for the food | |
└ label | string | Description of the serving size (e.g. 1 cup, sliced) | |
└ grams | number | Weight of the serving in grams | |
nutrition | object | Headline calories and macronutrients | |
└ calories | number | Energy in kilocalories | |
└ protein | number | Protein in grams | |
└ totalFat | number | Total fat in grams | |
└ carbohydrates | number | Total carbohydrates in grams | |
└ fiber | number | Dietary fiber in grams | |
└ sugars | number | Total sugars in grams | |
micronutrients | object | Full micronutrient panel | |
└ sodiumPremium | number | Sodium in milligrams | |
└ potassiumPremium | number | Potassium in milligrams | |
└ cholesterolPremium | number | Cholesterol in milligrams | |
└ saturatedFatPremium | number | Saturated fat in grams | |
└ transFatPremium | number | Trans fat in grams |
Headers
Only X-API-Key is required. Optional headers include Accept for response format negotiation (JSON, XML, or YAML), User-Agent, and X-Request-ID for request tracing. See all request headers →
GraphQL AccessALPHA
Access Nutrition through GraphQL to combine it with other API calls in a single request. Query only the nutrition data you need with precise field selection, and orchestrate complex data fetching workflows.
Credit Cost: Each API called in your GraphQL query consumes its standard credit cost.
POST https://api.apiverve.com/v1/graphqlquery {
nutrition(
input: {
food: "banana"
grams: 118
}
) {
food
fdcId
category
basis
servingSizes
nutrition {
calories
protein
totalFat
carbohydrates
fiber
sugars
}
micronutrients {
sodium
potassium
cholesterol
saturatedFat
transFat
monounsaturatedFat
polyunsaturatedFat
calcium
iron
magnesium
phosphorus
zinc
vitaminC
vitaminA
vitaminD
vitaminE
vitaminK
thiamin
riboflavin
niacin
vitaminB6
folate
vitaminB12
water
}
analytics {
caloriesPerGram
proteinCaloriePercent
fatCaloriePercent
carbCaloriePercent
proteinPer100Calories
}
}
}Note: Authentication is handled via the x-api-key header in your GraphQL request, not as a query parameter.
CORS Support
The Nutrition API accepts cross-origin requests from any origin, so it can be called directly from browser-based applications without a proxy. See CORS support →
Rate Limiting
Nutrition requests are throttled per minute on the Free plan and unthrottled on paid plans. Exceeding the limit returns 429 Too Many Requests; rate-limit usage is reported in the X-RateLimit-Limit, X-RateLimit-Remaining, and X-RateLimit-Reset response headers. See per-plan limits and best practices →
Error Codes
The Nutrition API uses standard HTTP status codes — 200 on success, 400 for invalid parameters, 401 for missing or invalid keys, 403 for insufficient credits, 429 for rate-limit exhaustion, and 500/503 for server-side issues. Each error response includes an X-Request-ID header you can quote when contacting support. See full error handling guide →
SDKs for Nutrition
Official Nutrition packages on npm, PyPI, NuGet, and JitPack — plus a Postman collection and an OpenAPI spec. See the SDK guide →
No-Code Integrations
Nutrition works with Zapier, Make, Pipedream, n8n, and Power Automate using the same API key. See setup guides →
Frequently Asked Questions
How do I get an API key for Nutrition?
How many credits does Nutrition cost?
Each successful Nutrition API call consumes credits based on plan tier. Check the pricing section above for the exact credit cost. Failed requests and errors don't consume credits, so you only pay for successful nutrition lookups.
Can I use Nutrition in production?
The free plan is for testing and development only. For production use of Nutrition, upgrade to a paid plan (Starter, Pro, or Mega) which includes commercial use rights, no attribution requirements, and guaranteed uptime SLAs. All paid plans are production-ready.
Can I use Nutrition from a browser?
What happens if I exceed my Nutrition credit limit?
When you reach your monthly credit limit, Nutrition API requests will return an error until you upgrade your plan or wait for the next billing cycle. You'll receive notifications at 80% and 95% usage to give you time to upgrade if needed.








