NutritionNutrition API

OnlineCredit Usage:1 per callRefreshed 1 month ago
avg: 200ms|p50: 189ms|p75: 207ms|p90: 229ms|p99: 272ms

Overview

To use Nutrition, you need an API key. You can get one by creating a free account and visiting your dashboard.

GET Endpoint

URL
https://api.apiverve.com/v1/nutrition

Example

How to call the Nutrition API in different programming languages.

cURL Request
curl -X GET \
  "https://api.apiverve.com/v1/nutrition?food=banana&grams=118" \
  -H "X-API-Key: your_api_key_here"
JavaScript (Fetch API)
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);
Python (Requests)
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)
Go (net/http)
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))
}
Example 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
    }
  }
}

Authentication

The Nutrition API requires authentication via API key. Include your API key in the request header:

Required Header
X-API-Key: your_api_key_here

Learn more about authentication →

Interactive 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:

Some Nutrition parameters marked with Premium are available exclusively on paid plans.View pricing

Get Nutrition Facts by Food Name

ParameterTypeRequiredDescriptionDefaultExample
foodstringrequired
Name of the food to look up (e.g. banana, chicken breast, olive oil)
Length: 1 - 100 chars
-banana
gramsPremiumnumberoptional
Serving weight in grams to scale the nutrition panel to. Defaults to a per-100-gram basis.
Range: 1 - 10000
-118

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 Response
200 OK
<?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&quot; or longer)</label>
        <grams>152</grams>
      </servingSize>
      <servingSize>
        <label>1 large (8&quot; to 8-7/8&quot; 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>
YAML Response
200 OK
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
CSV Response
200 OK
keyvalue
foodBananas, raw
fdcId173944
categoryFruits and Fruit Juices
basisper 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:

FieldTypeDescriptionExample
statusstringIndicates whether the request was successful ("ok") or failed ("error")ok
errorstring | nullContains error message if status is "error", otherwise nullnull
dataobject | nullContains 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:

Response fields marked with Premium are available exclusively on paid plans.View pricing
FieldTypeSample ValueDescription
foodstring"Bananas, raw"
Matched food name from the USDA database
fdcIdnumber173944
USDA FoodData Central unique identifier for the food
categorystring"Fruits and Fruit Juices"
USDA food category the item belongs to
basisstring"per 100g"
Basis the nutrition values are reported on (per 100g, or the requested serving)
[ ] Array items:array[3]Array of objects
Common household serving sizes reported for the food
labelstring"1 NLEA serving"
Description of the serving size (e.g. 1 cup, sliced)
gramsnumber126
Weight of the serving in grams
nutritionobject{...}
Headline calories and macronutrients
caloriesnumber89
Energy in kilocalories
proteinnumber1.09
Protein in grams
totalFatnumber0.33
Total fat in grams
carbohydratesnumber22.8
Total carbohydrates in grams
fibernumber2.6
Dietary fiber in grams
sugarsnumber12.2
Total sugars in grams
micronutrientsobject{...}
Full micronutrient panel
sodiumPremiumnumber1
Sodium in milligrams
potassiumPremiumnumber358
Potassium in milligrams
cholesterolPremiumnumber0
Cholesterol in milligrams
saturatedFatPremiumnumber0.112
Saturated fat in grams
transFatPremiumnumber0
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.

Test Nutrition in the GraphQL Explorer to confirm availability and experiment with queries.

Credit Cost: Each API called in your GraphQL query consumes its standard credit cost.

GraphQL Endpoint
POST https://api.apiverve.com/v1/graphql
GraphQL Query Example
query {
  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?
Sign up for a free account at dashboard.apiverve.com. Your API key will be automatically generated and available in your dashboard. The same key works for Nutrition and all other APIVerve APIs. The free plan includes 1,000 credits plus a 500 credit bonus.
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?
Yes! The Nutrition API supports CORS with wildcard configuration, so you can call it directly from browser-based JavaScript without needing a proxy server. See the CORS section above for details.
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.

What's Next?

Continue your journey with these recommended resources

Was this page helpful?