Skip to main content
RapidDev - Software Development Agency
bolt-ai-integrationsBolt Chat + API Route

How to Integrate Bolt.new with MyFitnessPal

MyFitnessPal shut down its public API in 2017 and has no official developer access. To build a nutrition tracking app in Bolt.new, use Nutritionix API (largest food database), USDA FoodData Central (free, no key required for basic use), or Edamam Nutrition Analysis API instead. All three are HTTP-based and work seamlessly in Bolt's WebContainer. This guide builds a full nutrition tracker using these alternatives.

What you'll learn

  • Why MyFitnessPal's API is unavailable and which alternatives to use instead
  • How to set up Nutritionix API for natural language food search in Bolt.new
  • How to query the free USDA FoodData Central API for detailed nutritional data
  • How to build a food search, calorie logging, and macro tracking interface
  • How to display daily nutrition summaries with calorie and macro charts
Book a free consultation
4.9Clutch rating
600+Happy partners
17+Countries served
190+Team members
Intermediate12 min read35 minutesOtherApril 2026RapidDev Engineering Team
TL;DR

MyFitnessPal shut down its public API in 2017 and has no official developer access. To build a nutrition tracking app in Bolt.new, use Nutritionix API (largest food database), USDA FoodData Central (free, no key required for basic use), or Edamam Nutrition Analysis API instead. All three are HTTP-based and work seamlessly in Bolt's WebContainer. This guide builds a full nutrition tracker using these alternatives.

Build a Nutrition Tracker in Bolt.new Without MyFitnessPal

MyFitnessPal's API was active until 2017 when the company discontinued developer access, citing misuse and data quality concerns. Under Under Armour and subsequent ownership by Francisco Partners, no public API program has been announced, and unofficial access attempts violate the Terms of Service. The good news: several alternatives offer equal or better nutrition data for building apps in Bolt.new.

The best replacement for most use cases is the Nutritionix API, which powers the Nutritionix iOS and Android apps with over 1 million branded food items and a natural language processing endpoint — you can query 'one cup of oatmeal with almond milk' and get structured nutritional data back. It has a generous free tier (500 calls/day) and is used by major health apps. For scientific accuracy and government-sourced data, the USDA FoodData Central API is completely free with no rate limits for basic queries and covers 300,000+ foods with lab-tested nutrient values. Edamam provides a nutrition analysis endpoint that can parse recipe text and return detailed per-serving nutritional breakdowns.

Building a nutrition tracker in Bolt follows the standard API route pattern: create a Next.js API route that proxies food search queries to whichever provider you choose, return structured calorie and macro data to the frontend, and store daily food logs in Bolt Database or Supabase. The core features — food search, calorie logging, macro tracking, and daily summary — are all achievable with these free or low-cost alternatives.

Integration method

Bolt Chat + API Route

Because MyFitnessPal has no public API, this integration uses alternative nutrition data providers. Nutritionix, USDA FoodData Central, and Edamam all offer REST APIs that work in Bolt's WebContainer via Next.js API routes. API keys are stored in environment variables and calls are proxied server-side to avoid CORS issues. No webhooks are needed for nutrition data lookups.

Prerequisites

  • A Nutritionix developer account (free at developer.nutritionix.com) OR a USDA FoodData Central API key (free at fdc.nal.usda.gov/api-guide.html) — or both
  • An Edamam developer account if using recipe analysis (free tier at developer.edamam.com)
  • A Bolt.new project using Next.js (for server-side API routes to handle CORS)
  • Bolt Database or Supabase connected for storing food logs
  • No MyFitnessPal account needed — this guide uses alternative nutrition APIs

Step-by-step guide

1

Get API Keys for Nutrition Data Providers

Since MyFitnessPal has no API, choose one or more of these alternatives. For natural language food search (the closest experience to MyFitnessPal): go to developer.nutritionix.com, click 'Get API Keys', register a free account, and you'll receive an App ID and App Key. The free tier allows 500 requests per day. For scientific/government food data (free, no limits): go to fdc.nal.usda.gov/api-guide.html and request a free API key — basic searches work without a key, but a key increases rate limits. For recipe analysis: go to developer.edamam.com, choose the Nutrition Analysis API, register, and get an App ID and App Key. The free tier allows 5,000 calls per month. Add your chosen credentials to your .env.local file. Nutritionix requires both the App ID and App Key in request headers. USDA requires just the API key as a query parameter. Edamam requires both App ID and App Key as query parameters. All three APIs use HTTPS — outbound calls work in Bolt's WebContainer during development. Because Nutritionix and Edamam restrict browser origins for CORS, proxy all calls through a Next.js API route rather than calling from client-side code.

Bolt.new Prompt

Create a .env.local file with placeholder values for nutrition API credentials: NUTRITIONIX_APP_ID=your_app_id, NUTRITIONIX_APP_KEY=your_app_key, USDA_API_KEY=your_usda_key, EDAMAM_APP_ID=your_app_id, EDAMAM_APP_KEY=your_app_key. Then create a Next.js API route at app/api/nutrition/search/route.ts that proxies food searches to the Nutritionix /v2/search/instant endpoint using the credentials from environment variables.

Paste this in Bolt.new chat

.env.local
1// .env.local
2NUTRITIONIX_APP_ID=your_app_id_here
3NUTRITIONIX_APP_KEY=your_app_key_here
4USDA_API_KEY=your_usda_api_key_here
5EDAMAM_APP_ID=your_edamam_app_id_here
6EDAMAM_APP_KEY=your_edamam_app_key_here

Pro tip: USDA FoodData Central allows up to 1,000 requests per hour without an API key (demo key). For a production app with real users, register for a free key at fdc.nal.usda.gov to get higher rate limits.

Expected result: API credentials are stored in environment variables and ready for use in server-side API routes.

2

Build the Food Search API Route

Create a Next.js API route that accepts a food search query and returns structured nutritional data. The Nutritionix Instant Search endpoint (`/v2/search/instant`) accepts natural language input and returns both branded products and common foods. For each result it returns serving size, calories, protein, carbohydrates, fat, and fiber. The USDA FoodData Central search endpoint (`/v1/foods/search`) returns more detailed data including vitamins and minerals but requires mapping the response to a simpler structure for display. Your API route should normalize the response from whichever provider you use into a consistent shape: food name, brand (if applicable), serving size with unit, calories, protein, carbs, fat. This normalized shape keeps your frontend components provider-agnostic — you can swap providers without changing the UI.

Bolt.new Prompt

Create app/api/nutrition/search/route.ts that accepts a query param 'q' and fetches food matches from the Nutritionix /v2/search/instant endpoint. Send x-app-id and x-app-key headers from environment variables. Return normalized results as an array of: { id, name, brand, servingSize, servingUnit, calories, protein, carbs, fat, fiber }. Handle errors gracefully.

Paste this in Bolt.new chat

app/api/nutrition/search/route.ts
1// app/api/nutrition/search/route.ts
2import { NextRequest, NextResponse } from 'next/server';
3
4interface NutritionixFood {
5 food_name: string;
6 brand_name?: string;
7 serving_qty: number;
8 serving_unit: string;
9 nf_calories: number;
10 nf_protein: number;
11 nf_total_carbohydrate: number;
12 nf_total_fat: number;
13 nf_dietary_fiber: number;
14 nix_item_id?: string;
15 tag_id?: string;
16}
17
18export async function GET(request: NextRequest) {
19 const query = request.nextUrl.searchParams.get('q');
20 if (!query || query.length < 2) {
21 return NextResponse.json({ results: [] });
22 }
23
24 const res = await fetch(
25 `https://trackapi.nutritionix.com/v2/search/instant?query=${encodeURIComponent(query)}&detailed=true`,
26 {
27 headers: {
28 'x-app-id': process.env.NUTRITIONIX_APP_ID!,
29 'x-app-key': process.env.NUTRITIONIX_APP_KEY!,
30 'Content-Type': 'application/json',
31 },
32 }
33 );
34
35 if (!res.ok) {
36 return NextResponse.json({ error: 'Search failed' }, { status: res.status });
37 }
38
39 const data = await res.json();
40 const foods: NutritionixFood[] = [
41 ...(data.common ?? []),
42 ...(data.branded ?? []),
43 ];
44
45 const results = foods.slice(0, 20).map((food) => ({
46 id: food.nix_item_id ?? food.tag_id ?? food.food_name,
47 name: food.food_name,
48 brand: food.brand_name ?? null,
49 servingSize: food.serving_qty,
50 servingUnit: food.serving_unit,
51 calories: Math.round(food.nf_calories ?? 0),
52 protein: Math.round((food.nf_protein ?? 0) * 10) / 10,
53 carbs: Math.round((food.nf_total_carbohydrate ?? 0) * 10) / 10,
54 fat: Math.round((food.nf_total_fat ?? 0) * 10) / 10,
55 fiber: Math.round((food.nf_dietary_fiber ?? 0) * 10) / 10,
56 }));
57
58 return NextResponse.json({ results });
59}

Pro tip: Nutritionix's /v2/search/instant endpoint returns both 'common' foods (generic items like 'apple') and 'branded' foods (packaged products). Show both with the branded items clearly labeled.

Expected result: GET /api/nutrition/search?q=chicken+breast returns a list of matching foods with calories and macros.

3

Build the Food Log and Daily Summary

With food search working, build the logging interface. Users search for a food, select a result, optionally adjust the serving size (e.g., 2 servings instead of 1), and log it to their daily diary. Store food log entries in Bolt Database or Supabase in a table with: user_id, food_name, brand, serving_size, serving_unit, servings_consumed, calories, protein, carbs, fat, logged_at (timestamp). Calculate macros by multiplying the per-serving values by the servings_consumed. Query the database to get all entries for today (where logged_at is today's date) and sum the totals. Display these totals as progress bars toward the user's daily goals. A standard 2000 calorie diet with typical macro splits is 150g protein, 225g carbohydrates, 67g fat — use these as default goals but let users customize. For the charting component, a horizontal bar chart showing each macro's progress toward the daily goal works well and renders clearly on mobile.

Bolt.new Prompt

Build a nutrition tracker with: (1) a FoodSearch component with a search input that queries /api/nutrition/search, shows autocomplete results, and lets users select a food and enter servings count; (2) a food log stored in Supabase in a food_logs table (user_id, food_name, brand, calories, protein, carbs, fat, servings, logged_at); (3) a DailySummary component showing today's total calories, protein, carbs, fat as progress bars toward daily goals (2000 kcal, 150g protein, 225g carbs, 67g fat); (4) a food log table showing today's entries with a delete button for each.

Paste this in Bolt.new chat

Pro tip: Ask Bolt to generate the Supabase migration SQL for the food_logs table along with the component code. Include a Row Level Security policy so each user only sees their own logs.

Expected result: Users can search foods, log them with serving counts, and see their daily calorie and macro progress update in real time.

4

Add USDA FoodData Central as a Free Backup Provider

The USDA FoodData Central API is a valuable complement to Nutritionix — it's completely free, requires no API key for basic use, covers 300,000+ foods with lab-tested nutrient values including vitamins and minerals, and has no enforced rate limits (though fair use applies). It's particularly useful for educational nutrition apps, detailed micronutrient analysis, or as a fallback when the Nutritionix free tier is exhausted. The search endpoint is `https://api.nal.usda.gov/fdc/v1/foods/search?query={term}&api_key=DEMO_KEY`. DEMO_KEY allows 30 requests per IP per hour — register a free key for higher limits. The USDA response includes detailed nutrient arrays for each food item. Map the nutrient array to named values using the nutrient ID numbers: 1008 = Energy (kcal), 1003 = Protein, 1004 = Total fat, 1005 = Carbohydrates, 1079 = Dietary fiber. Since outbound HTTPS calls work in Bolt's WebContainer, you can test USDA searches directly in the preview.

Bolt.new Prompt

Add a USDA FoodData Central food search route at app/api/nutrition/usda/route.ts. It should accept a 'q' query param and search the USDA FoodData Central API at https://api.nal.usda.gov/fdc/v1/foods/search. Use USDA_API_KEY from environment variables (fall back to DEMO_KEY if not set). Map nutrient IDs to named fields: 1008=calories, 1003=protein, 1004=fat, 1005=carbs. Return normalized results matching the same format as the Nutritionix search route.

Paste this in Bolt.new chat

app/api/nutrition/usda/route.ts
1// app/api/nutrition/usda/route.ts
2import { NextRequest, NextResponse } from 'next/server';
3
4interface UsdaNutrient {
5 nutrientId: number;
6 value: number;
7}
8
9const NUTRIENT_MAP: Record<number, string> = {
10 1008: 'calories',
11 1003: 'protein',
12 1004: 'fat',
13 1005: 'carbs',
14 1079: 'fiber',
15};
16
17export async function GET(request: NextRequest) {
18 const query = request.nextUrl.searchParams.get('q');
19 if (!query) return NextResponse.json({ results: [] });
20
21 const apiKey = process.env.USDA_API_KEY || 'DEMO_KEY';
22 const url = `https://api.nal.usda.gov/fdc/v1/foods/search?query=${encodeURIComponent(query)}&pageSize=15&api_key=${apiKey}`;
23
24 const res = await fetch(url);
25 if (!res.ok) return NextResponse.json({ error: 'USDA search failed' }, { status: res.status });
26
27 const data = await res.json();
28 const results = (data.foods ?? []).map((food: {
29 fdcId: number;
30 description: string;
31 brandOwner?: string;
32 servingSize?: number;
33 servingSizeUnit?: string;
34 foodNutrients: UsdaNutrient[];
35 }) => {
36 const nutrients: Record<string, number> = {};
37 food.foodNutrients.forEach((n) => {
38 const key = NUTRIENT_MAP[n.nutrientId];
39 if (key) nutrients[key] = Math.round(n.value * 10) / 10;
40 });
41 return {
42 id: String(food.fdcId),
43 name: food.description,
44 brand: food.brandOwner ?? null,
45 servingSize: food.servingSize ?? 100,
46 servingUnit: food.servingSizeUnit ?? 'g',
47 calories: nutrients.calories ?? 0,
48 protein: nutrients.protein ?? 0,
49 carbs: nutrients.carbs ?? 0,
50 fat: nutrients.fat ?? 0,
51 fiber: nutrients.fiber ?? 0,
52 };
53 });
54
55 return NextResponse.json({ results });
56}

Pro tip: USDA FoodData Central data is measured per 100g by default, not per serving. Adjust displayed values by the actual serving size when showing them to users.

Expected result: GET /api/nutrition/usda?q=banana returns USDA nutritional data for banana-related foods with detailed nutrient values.

Common use cases

Calorie and Macro Tracker

Let users search for foods, log meals with portion sizes, and see their daily intake of calories, protein, carbohydrates, and fat compared to their personal goals. Data is stored in a database and persists across sessions.

Bolt.new Prompt

Build a calorie tracker app using the Nutritionix API. Users can search foods by name, select a result, enter a portion size, and log it to their daily food diary. Show a daily summary with total calories and macros (protein, carbs, fat) as progress bars toward goals of 2000 kcal, 150g protein, 250g carbs, 65g fat. Store food logs in Supabase.

Copy this prompt to try it in Bolt.new

Recipe Nutrition Analyzer

Users paste or type a recipe ingredient list and the app returns the total and per-serving nutritional information. Uses Edamam's nutrition analysis API which accepts free-form ingredient text.

Bolt.new Prompt

Build a recipe nutrition analyzer using the Edamam Nutrition Analysis API. Users can type or paste a list of recipe ingredients (e.g., '2 cups flour, 3 eggs, 1 cup milk'). The app calls Edamam to analyze the nutrition and shows total calories, protein, carbs, fat, fiber, and sugar for the whole recipe plus a per-serving breakdown. Let users specify number of servings.

Copy this prompt to try it in Bolt.new

USDA Food Database Browser

A searchable database of over 300,000 foods from the USDA FoodData Central, showing detailed nutritional profiles. Free to use, no API key required for basic search. Good for educational nutrition apps or reference tools.

Bolt.new Prompt

Build a food nutrition database browser using the USDA FoodData Central API (free, no key required for basic search at api.nal.usda.gov). Users can search for any food and see a detailed nutritional profile including all vitamins and minerals. Show results as a nutritional label card similar to the FDA Nutrition Facts label format.

Copy this prompt to try it in Bolt.new

Troubleshooting

Nutritionix API returns 401 Unauthorized

Cause: The x-app-id and x-app-key headers are missing, incorrect, or the environment variables are not loaded.

Solution: Verify NUTRITIONIX_APP_ID and NUTRITIONIX_APP_KEY are set in .env.local. Confirm the headers in the API route use the exact names 'x-app-id' and 'x-app-key' (not 'Authorization'). Check the Nutritionix developer dashboard to confirm your API credentials are active.

typescript
1headers: {
2 'x-app-id': process.env.NUTRITIONIX_APP_ID!,
3 'x-app-key': process.env.NUTRITIONIX_APP_KEY!,
4 'Content-Type': 'application/json',
5}

Food search returns no results for common foods

Cause: The search query may be too short (less than 2 characters) or the Nutritionix free tier's daily quota of 500 requests has been exceeded.

Solution: Check the Nutritionix developer dashboard for API usage. If the quota is exceeded, use the USDA FoodData Central API as a fallback (free, no daily quota). Add quota-exceeded error handling to the search route that automatically switches to the USDA endpoint.

CORS error when calling Nutritionix directly from the browser

Cause: Nutritionix does not whitelist browser origins — their API is designed for server-to-server calls. Direct fetch() calls from client-side React code will be blocked.

Solution: All Nutritionix and Edamam calls must go through a Next.js API route (app/api/nutrition/search/route.ts). Never call these APIs directly from client components. The API route runs server-side and is not subject to CORS restrictions.

typescript
1// WRONG — direct client call fails with CORS
2const data = await fetch('https://trackapi.nutritionix.com/v2/search/instant?query=apple');
3
4// CORRECT — proxy through your API route
5const data = await fetch('/api/nutrition/search?q=apple');

USDA FoodData Central returns 'API_KEY_INVALID' with DEMO_KEY

Cause: The DEMO_KEY rate limit of 30 requests per IP per hour has been exceeded.

Solution: Register a free API key at fdc.nal.usda.gov/api-guide.html. Free registered keys get 1,000 requests per hour. Add the key as USDA_API_KEY in your .env.local file.

Best practices

  • Be honest in your app that you use Nutritionix or USDA data — do not imply MyFitnessPal integration that doesn't exist
  • Cache frequent food searches in memory or a database to reduce API calls and stay within free tier limits
  • Use USDA FoodData Central as a free fallback when Nutritionix quota is exceeded — the two APIs have different food coverage and complement each other
  • Never call Nutritionix or Edamam APIs directly from client-side code — always proxy through server-side API routes to avoid CORS errors and hide API keys
  • Normalize API responses to a consistent shape in your API routes so frontend components are not tied to a specific provider's response format
  • Store food logs with a timestamp so you can display weekly trends and track progress over time, not just today's intake
  • Round nutritional values to one decimal place when displaying — showing '15.37g protein' looks unscientific compared to '15.4g'

Alternatives

Frequently asked questions

Is there any way to access MyFitnessPal data through an API?

No. MyFitnessPal shut down its public API program in 2017 and has not announced any official replacement. Unofficial scraping or workarounds violate MyFitnessPal's Terms of Service. Use Nutritionix, USDA FoodData Central, or Edamam as legitimate alternatives with comparable food databases.

Which nutrition API is the best free option for a Bolt.new app?

For natural language food search similar to MyFitnessPal, Nutritionix is the best free option (500 calls/day, 1 million food items). For unlimited free access with government-sourced data, USDA FoodData Central is unmatched. For recipe analysis, Edamam's free tier allows 5,000 calls per month. Many production apps use all three as complementary sources.

Can I build a MyFitnessPal clone with Bolt.new?

Yes, the core features of a calorie and macro tracker can be built in Bolt using Nutritionix for food search, Supabase or Bolt Database for food log storage, and Recharts for progress visualization. You can replicate the diary view, macro tracking, and nutrition goals without any MyFitnessPal access.

Do nutrition API calls work in Bolt's WebContainer preview?

Outbound HTTPS calls to Nutritionix, USDA, and Edamam work fine in Bolt's WebContainer — these are standard HTTP requests, not TCP connections. However, you must proxy them through a Next.js API route rather than calling from client-side components, because these APIs restrict browser origins with CORS.

How do I deploy a Bolt.new nutrition tracker to Netlify?

Connect Netlify in Bolt's Settings → Applications and click Publish. After deploying, add your API credentials as environment variables in Netlify's Site Configuration → Environment Variables: NUTRITIONIX_APP_ID, NUTRITIONIX_APP_KEY, USDA_API_KEY, and any Edamam keys. Redeploy to apply the variables. No webhook registration is needed for nutrition APIs.

RapidDev

Talk to an Expert

Our team has built 600+ apps. Get personalized help with your project.

Book a free consultation

Need help with your project?

Our experts have built 600+ apps and can accelerate your development. Book a free consultation — no strings attached.

Book a free consultation

We put the rapid in RapidDev

Need a dedicated strategic tech and growth partner? Discover what RapidDev can do for your business! Book a call with our team to schedule a free, no-obligation consultation. We'll discuss your project and provide a custom quote at no cost.