MyFitnessPal's public API was deprecated in 2019. Connect Retool to nutrition data using CSV exports from MyFitnessPal uploaded to a Retool Database or PostgreSQL table, or by integrating with active alternatives like Nutritionix API. Build nutrition tracking dashboards for health coaching programs, corporate wellness, or clinical teams who collect dietary data from MyFitnessPal users.
| Fact | Value |
|---|---|
| Tool | MyFitnessPal |
| Category | Other |
| Method | REST API Resource |
| Difficulty | Intermediate |
| Time required | 30 minutes |
| Last updated | April 2026 |
Build a Nutrition Tracking Dashboard in Retool Using MyFitnessPal Data
MyFitnessPal is one of the world's largest nutrition tracking platforms with over 200 million users and a database of more than 14 million foods. While its public API was deprecated in 2019 — cutting off direct programmatic access for most developers — the underlying data users generate in MyFitnessPal remains highly valuable for health coaches, nutritionists, corporate wellness programs, and clinical teams. Building a Retool dashboard around this data requires understanding the available bridge patterns and selecting the right approach for your use case.
The most accessible pattern for most teams is the CSV export workflow. MyFitnessPal allows users to export their complete food diary history from the website (not the mobile app). This CSV, which includes date, meal type, food name, calories, carbohydrates, fat, protein, sodium, and sugar for every logged food item, can be uploaded directly into Retool Database or a connected PostgreSQL instance. Once imported, Retool's full query and visualization capabilities apply: SQL queries for aggregations, Charts for macro trend visualization, and Forms for adding coaching notes tied to specific users or dates.
For organizations building active wellness programs that need real-time nutrition data rather than periodic exports, the Nutritionix API is the most appropriate integration path. Nutritionix provides a comprehensive food and nutrition database REST API with natural language food lookup (e.g., '2 eggs and toast'), barcode scanning support, and restaurant menu data. A Retool REST API Resource pointed at Nutritionix enables food search, macro lookup, and meal planning features that complement or replace MyFitnessPal as the data source.
Integration method
MyFitnessPal deprecated its public API in 2019, so direct REST API integration is no longer available to new developers. The recommended approach for Retool integration is a two-step data bridge: users export their food diary data as CSV from MyFitnessPal's website, which is then uploaded into a Retool Database or PostgreSQL table and queried via Retool's native database connectors. For organizations needing active API access, the Nutritionix API provides a fully supported food and nutrition database REST API that can be connected to Retool as a REST API Resource with Bearer token auth.
Prerequisites
- A MyFitnessPal account with food diary data to export (or a Nutritionix API account for the active API path)
- Access to export food diary CSV from MyFitnessPal's website (Settings → Diary Settings → Export)
- A connected database in Retool (Retool Database, PostgreSQL, or MySQL) to store imported CSV data
- For Nutritionix integration: a Nutritionix developer account with an App ID and App Key (free tier available at developer.nutritionix.com)
- A Retool account with permission to create Resources and upload data to Retool Database
Step-by-step guide
Export MyFitnessPal food diary data and prepare for import
MyFitnessPal allows users to export their food diary history from the web application. The export is not available in the mobile app — users must log into myfitnesspal.com on a desktop browser. Once logged in, navigate to Reports in the top navigation bar. Click the export icon or navigate to Settings → Diary Settings → Export Data. MyFitnessPal generates a CSV file containing all logged food entries with columns including: Date, Meal, Food Name, Calories, Carbohydrates (g), Fat (g), Protein (g), Sodium (mg), Sugar (g), and optionally Fiber (g) and Saturated Fat (g) depending on the foods logged. Download this CSV file. Before importing into Retool, clean the data: open the CSV in a spreadsheet editor and check for blank rows (which appear when a daily diary entry has no logged foods), rows with 'Totals' labels (which MyFitnessPal inserts as daily summary rows), and any special characters in food names that may interfere with SQL INSERT statements. Remove 'Totals' rows and ensure the Date column uses a consistent format (YYYY-MM-DD or MM/DD/YYYY). If handling multiple clients or users, add a client_id or user_email column to identify whose data each row belongs to. Save the cleaned CSV. For ongoing programs, establish a weekly export schedule where participants download and submit their CSV files — a simple file upload form can be built in Retool to receive these submissions.
Pro tip: MyFitnessPal exports food entries at the meal-level granularity (Breakfast, Lunch, Dinner, Snacks). Each row is one food item within a meal, not an aggregated daily total. Your SQL queries will need GROUP BY date (and optionally user_id) with SUM() aggregations to compute daily totals — keep the raw row-level data intact for maximum flexibility.
Expected result: A cleaned CSV file containing MyFitnessPal food diary entries is ready for import, with consistent date formatting and optional user identification columns.
Create a database table and import the CSV data
With a cleaned CSV ready, create the target database table and import the data. If using Retool Database (the built-in managed PostgreSQL), navigate to the Retool Database tab in the left sidebar, click Create Table, and name it 'nutrition_log'. Define these columns: id (auto-increment primary key), user_email (text), entry_date (date), meal_type (text), food_name (text), calories (integer), carbohydrates_g (decimal), fat_g (decimal), protein_g (decimal), sodium_mg (decimal), sugar_g (decimal), fiber_g (decimal), imported_at (timestamp, default now()). Click the Import CSV button in the Retool Database interface and upload your cleaned MyFitnessPal CSV. Map each CSV column to the corresponding table column in the import dialog. For ongoing data collection, create a second table named 'nutrition_clients' with columns: id, name, email, program_start_date, calorie_target, protein_target_g, notes. This clients table lets you reference targets when flagging non-adherent days. If using an existing PostgreSQL connection, write and run the CREATE TABLE statement in Retool's SQL query editor against your PostgreSQL resource, then use Retool's table CSV import feature or a Python script to load the data. After import, run a verification query: SELECT COUNT(*), MIN(entry_date), MAX(entry_date) FROM nutrition_log to confirm all rows loaded correctly.
1-- Create the nutrition_log table (run in Retool's SQL editor)2CREATE TABLE IF NOT EXISTS nutrition_log (3 id SERIAL PRIMARY KEY,4 user_email TEXT NOT NULL,5 entry_date DATE NOT NULL,6 meal_type TEXT,7 food_name TEXT,8 calories INTEGER DEFAULT 0,9 carbohydrates_g DECIMAL(8,2) DEFAULT 0,10 fat_g DECIMAL(8,2) DEFAULT 0,11 protein_g DECIMAL(8,2) DEFAULT 0,12 sodium_mg DECIMAL(8,2) DEFAULT 0,13 sugar_g DECIMAL(8,2) DEFAULT 0,14 fiber_g DECIMAL(8,2) DEFAULT 0,15 imported_at TIMESTAMP DEFAULT NOW()16);1718-- Verify import19SELECT20 user_email,21 COUNT(*) AS total_entries,22 MIN(entry_date) AS earliest_entry,23 MAX(entry_date) AS latest_entry24FROM nutrition_log25GROUP BY user_email26ORDER BY total_entries DESC;Pro tip: If participants will be submitting their own CSV exports regularly, build a simple Retool app page with a File Upload component and a JavaScript query that parses the uploaded CSV using Retool's built-in FileReader API. The parsed rows can be bulk-inserted into the nutrition_log table using a single parameterized INSERT query with an array of values, avoiding the need for manual database imports each week.
Expected result: The nutrition_log table exists in the connected database, contains the imported MyFitnessPal rows, and a verification query confirms the expected count and date range of entries.
Configure the Nutritionix REST API Resource (for active food lookup)
For organizations that need active food nutrition lookups rather than relying solely on imported exports, configure the Nutritionix API as a second Retool Resource alongside the database resource. First, sign up for a free developer account at developer.nutritionix.com — the free tier provides 500 natural language queries per day and access to the branded food database. Once registered, note your App ID and App Key from the developer portal dashboard. In Retool Resources, click Add Resource and select REST API. Name it 'Nutritionix API'. Set Base URL to https://trackapi.nutritionix.com/v2. Under Authentication, select Header Auth. Add two headers: x-app-id with value {{ retoolContext.configVars.NUTRITIONIX_APP_ID }} and x-app-key with value {{ retoolContext.configVars.NUTRITIONIX_APP_KEY }}. Also add Content-Type: application/json as a default header. Store your App ID and App Key in Retool Configuration Variables (Settings → Configuration Variables) named NUTRITIONIX_APP_ID and NUTRITIONIX_APP_KEY, with the App Key marked as a secret. Click Save and test by creating a test query: POST to /natural/nutrients with body { 'query': '1 large egg' } — a successful response returns a foods array with macro breakdowns confirming the integration works.
1{2 "method": "POST",3 "path": "/natural/nutrients",4 "body": {5 "query": "{{ foodSearchInput.value }}"6 },7 "headers": {8 "x-app-id": "{{ retoolContext.configVars.NUTRITIONIX_APP_ID }}",9 "x-app-key": "{{ retoolContext.configVars.NUTRITIONIX_APP_KEY }}"10 }11}Pro tip: Nutritionix's natural language endpoint (/natural/nutrients) accepts conversational food descriptions like '2 scrambled eggs with butter' and returns per-ingredient breakdowns. For more precise lookups, use the /search/instant endpoint which searches the branded food and common food databases with autocomplete — better suited for searching specific packaged products.
Expected result: The Nutritionix API Resource is configured in Retool, and a test POST to /natural/nutrients with a sample food description returns a foods array with calorie and macro data.
Build the nutrition tracking dashboard
With both the database resource (for imported diary data) and optionally the Nutritionix resource (for food lookup) configured, build the main dashboard. Start with a Select component named 'clientSelect' that populates from a query against the nutrition_clients table: SELECT id, name, email FROM nutrition_clients ORDER BY name. Add a Date Range Picker named 'dateRange' for filtering the analysis period, defaulting to the last 30 days. Create the core analytics query 'getDailyTotals': SELECT entry_date, SUM(calories) as total_calories, SUM(protein_g) as protein, SUM(carbohydrates_g) as carbs, SUM(fat_g) as fat FROM nutrition_log WHERE user_email = {{ clientSelect.value }} AND entry_date BETWEEN {{ dateRange.start }} AND {{ dateRange.end }} GROUP BY entry_date ORDER BY entry_date. Bind this query's data to a Line Chart showing daily calorie trend over the selected period, with a reference line at the client's calorie target. Below the chart, add three Stat components showing average daily calories, average protein, and average adherence rate (percentage of days within 10% of calorie target). Add a second Table below showing the daily totals with color-coded Tags for days that are 'On Track', 'Under Target', or 'Over Target' based on comparison to the client's goal. For the Nutritionix food lookup panel, add a Text Input and Search Button that trigger the Nutritionix query and display results in a detail Card with a breakdown of macros and a 'Add to Meal Plan' button.
1-- Daily nutrition totals query for selected client and date range2SELECT3 entry_date,4 SUM(calories) AS total_calories,5 ROUND(SUM(protein_g)::numeric, 1) AS protein_g,6 ROUND(SUM(carbohydrates_g)::numeric, 1) AS carbs_g,7 ROUND(SUM(fat_g)::numeric, 1) AS fat_g,8 ROUND(SUM(sodium_mg)::numeric, 1) AS sodium_mg,9 COUNT(DISTINCT meal_type) AS meals_logged10FROM nutrition_log11WHERE user_email = {{ clientSelect.value }}12 AND entry_date BETWEEN {{ dateRange.start }}::date13 AND {{ dateRange.end }}::date14GROUP BY entry_date15ORDER BY entry_date;Pro tip: Add a secondary query that computes a rolling 7-day average of calories using a SQL window function: AVG(SUM(calories)) OVER (ORDER BY entry_date ROWS BETWEEN 6 PRECEDING AND CURRENT ROW). Overlay this 7-day average line on the daily calorie chart to smooth out single-day outliers and make adherence trends more visible for coaching conversations.
Expected result: The nutrition dashboard displays daily calorie and macro trends for the selected client and date range, with stat cards for averages and color-coded adherence tags in the daily totals table.
Add coaching notes and progress reporting
To make the dashboard a complete health coaching tool, add coaching workflow features. Create a 'coaching_notes' table in the connected database with columns: id, client_email, note_date, note_text, coach_name, created_at. In the Retool dashboard, add a Notes section below the nutrition charts with a Text Area input, a Text Input for the coach's name, and a Save Note button that runs an INSERT query. Display existing notes in a small Table sorted by note_date descending, allowing coaches to track the history of their observations per client. Add a Report generation feature: a Button labeled 'Generate Weekly Summary' that triggers a JavaScript query computing key metrics for the current week (total calories, avg protein, best and worst adherence days, streak of consecutive logging days), formats them into a text summary, and copies it to the clipboard for pasting into emails. Finally, add a macro balance pie chart using a Chart component in Donut mode, with data computed from the getDailyTotals averages: protein calories (protein_g × 4), carb calories (carbs_g × 4), and fat calories (fat_g × 9), showing the macronutrient distribution as percentages. For complex integrations involving multi-coach access control, automated weekly report emails, and integration with clinical EMR systems, RapidDev's team can help architect and build your Retool nutrition management solution.
1// JavaScript transformer: compute macro balance percentages for Pie Chart2const totals = getDailyTotals.data || [];3if (!totals.length) return [];45const avgProtein = totals.reduce((s, d) => s + (d.protein_g || 0), 0) / totals.length;6const avgCarbs = totals.reduce((s, d) => s + (d.carbs_g || 0), 0) / totals.length;7const avgFat = totals.reduce((s, d) => s + (d.fat_g || 0), 0) / totals.length;89const proteinCal = avgProtein * 4;10const carbCal = avgCarbs * 4;11const fatCal = avgFat * 9;12const total = proteinCal + carbCal + fatCal;1314return [15 { macro: 'Protein', calories: Math.round(proteinCal), pct: ((proteinCal / total) * 100).toFixed(1) },16 { macro: 'Carbohydrates', calories: Math.round(carbCal), pct: ((carbCal / total) * 100).toFixed(1) },17 { macro: 'Fat', calories: Math.round(fatCal), pct: ((fatCal / total) * 100).toFixed(1) }18];Pro tip: Enable Retool's row-level permissions on the coaching_notes table if multiple coaches share the Retool app — use Retool's current user email ({{ current_user.email }}) in the coach_name field automatically, and filter the notes query to show each coach's own notes plus a 'shared' visibility flag for notes intended for the full team.
Expected result: Coaches can add dated notes per client, view the note history, generate text summaries of weekly progress, and see a macro balance chart showing average protein, carbohydrate, and fat distribution.
Common use cases
Build a health coaching nutrition review dashboard
Create a Retool panel for health coaches to review client food diary exports. A coach selects a client from a dropdown, views their 30-day calorie and macro trend charts, and sees a Table of daily diary entries with total calories, protein, carbs, and fat per day. The dashboard flags days where the client's calories fell below their target or protein intake dropped below a minimum threshold, giving the coach an at-a-glance view of adherence.
Build a Retool nutrition coaching dashboard. A Select component lists client names from a clients table. Selecting a client loads their food diary entries from the nutrition_log table (filtered by client_id). Show a Line Chart of daily calories over 30 days, three Stat cards for avg protein/carb/fat, and a Table of daily entries with flag badges for days under 1200 calories.
Copy this prompt to try it in Retool
Build a corporate wellness program nutrition tracker
Create a Retool admin panel for a corporate wellness manager to track nutrition data uploaded by program participants. Show aggregate statistics (average calories per participant per day, percentage of participants meeting their protein goals), individual progress tables, and allow the wellness manager to add coaching notes tied to specific participants. Include a bulk CSV upload interface for ingesting weekly MyFitnessPal exports from multiple participants at once.
Build a Retool corporate wellness nutrition panel. Show a summary Table of all program participants with their average daily calories, protein intake, and goal adherence percentage. Allow the wellness manager to click a participant and view their full diary history in a Chart. Add a Text Area for coaching notes that saves to a notes table.
Copy this prompt to try it in Retool
Build a food nutrition lookup tool using Nutritionix API
Create a Retool internal tool for dietitians to look up nutritional information for any food using the Nutritionix API. A text input accepts natural language food descriptions ('100g grilled chicken breast'), a query fetches the macro breakdown from Nutritionix, and the results display in a formatted panel showing calories, protein, carbohydrates, fat, fiber, and micronutrients. Add a 'Save to Meal Plan' button that appends the food item to a meal plan table in a connected database.
Build a Retool food lookup tool using Nutritionix API. A Text Input accepts a natural language food description. A Button triggers a POST to Nutritionix natural language endpoint. Display the response in a detail card showing calories, protein, carbs, fat, fiber, sodium, and sugar. Add a Save button that inserts the item into a meal_plan table.
Copy this prompt to try it in Retool
Troubleshooting
MyFitnessPal CSV export is missing data or shows zero calories for many entries
Cause: MyFitnessPal's CSV export may omit entries where the calorie count was not specified, or when a user logged a food without nutritional data (custom foods without a nutrition label). Entries with zero calories are also common for tracked water intake or non-food items.
Solution: After importing, run a validation query to identify zero-calorie entries: SELECT food_name, COUNT(*) FROM nutrition_log WHERE calories = 0 GROUP BY food_name ORDER BY count DESC. Review these entries and decide whether to retain them (water, supplements) or flag them for client follow-up. Add a data quality filter to the dashboard queries using WHERE calories > 0 to exclude them from macro calculations while keeping them visible in the raw diary table.
Nutritionix API returns 401 Unauthorized — 'Invalid app credentials'
Cause: The x-app-id or x-app-key header values are incorrect, using the wrong Configuration Variable names, or the Nutritionix developer account credentials have been reset.
Solution: Log in to developer.nutritionix.com and verify your App ID and App Key in the account dashboard. Update the NUTRITIONIX_APP_ID and NUTRITIONIX_APP_KEY Configuration Variables in Retool Settings. Note that Nutritionix App Keys are not the same as API Keys — ensure you are using the correct credential pair. Test with a hard-coded value first in the resource headers to isolate whether the issue is the credentials themselves or the Configuration Variable reference.
CSV import fails with 'invalid date format' or duplicate key errors
Cause: MyFitnessPal exports dates in MM/DD/YYYY format by default, which may conflict with the DATE column format expected by PostgreSQL (YYYY-MM-DD). Duplicate key errors occur when the same CSV is imported multiple times without deduplication.
Solution: Before inserting, cast the date string to PostgreSQL's date format using TO_DATE(csv_date_column, 'MM/DD/YYYY') in the INSERT statement. For deduplication, use INSERT INTO nutrition_log ... ON CONFLICT (user_email, entry_date, meal_type, food_name) DO NOTHING — first add a unique constraint on those four columns to enable the ON CONFLICT clause. This makes re-imports idempotent.
1-- Add unique constraint to prevent duplicate imports2ALTER TABLE nutrition_log3ADD CONSTRAINT nutrition_log_unique4UNIQUE (user_email, entry_date, meal_type, food_name);Dashboard shows no data for a selected client despite entries being imported
Cause: The clientSelect component is returning the client's name rather than their email address, causing the WHERE user_email = {{ clientSelect.value }} filter to find no matching rows in the nutrition_log table.
Solution: Ensure the SELECT query populating clientSelect returns the email column as the value option and the name as the label. In the Select component settings, set Value to email and Label to name. This way, clientSelect.value returns the email address that matches the nutrition_log user_email column, not the display name.
Best practices
- Establish a clear data governance policy for health data — nutrition diary data is sensitive personal health information; restrict Retool app access to authorized coaches and wellness staff only using Retool's Groups and permissions system
- Implement a weekly CSV submission workflow with clear instructions for participants, including a step-by-step guide on how to export from MyFitnessPal's website, to ensure consistent data quality and completeness
- Add data validation on import — check for missing required fields, date range plausibility, and unrealistic values (e.g., 10,000 calories in a single meal) before inserting into the database to maintain dashboard accuracy
- Keep raw row-level food diary data intact in the nutrition_log table rather than pre-aggregating to daily totals — this allows flexible queries for meal-type analysis (e.g., breakfast vs dinner macro distribution) without requiring re-import
- Store client calorie and macro targets in a separate clients table and reference them in dashboard queries to automatically compute adherence metrics — hardcoding targets in queries makes the dashboard difficult to maintain as goals change
- Use Retool's query caching (60-120 seconds) on aggregate queries like getDailyTotals, which involve GROUP BY across potentially thousands of rows — caching significantly improves dashboard load time for coaches reviewing multiple clients
- For the Nutritionix integration, implement free-tier rate limit awareness (500 requests/day) by displaying a query counter stat card on the dashboard, alerting coaches when they are approaching the daily limit
Alternatives
Garmin Connect provides an active OAuth 2.0 API for activity and fitness data from Garmin devices — choose Garmin if your wellness program participants use Garmin wearables and you need real-time activity data rather than manually exported nutrition logs.
Fitbit's Web API provides active OAuth access to activity, sleep, and basic nutrition data — choose Fitbit if participants use Fitbit devices and you need ongoing programmatic data access without the CSV export workflow.
Withings focuses on body measurements (weight, blood pressure, sleep) via smart devices with an active OAuth API — choose Withings when your wellness program tracks biometric measurements alongside nutrition data.
Frequently asked questions
Does MyFitnessPal have an API I can use in 2024?
MyFitnessPal's public API was deprecated in 2019 and is no longer available to new developers. Enterprise partnerships may be available for large health organizations through MyFitnessPal's business sales team, but there is no self-serve API access. The recommended approach for most teams is to use MyFitnessPal's CSV export feature combined with a database import workflow in Retool, or to use the Nutritionix API as an active food and nutrition data source.
How often should participants export their MyFitnessPal data for the Retool dashboard?
Weekly exports are the most practical cadence for health coaching programs — participants export and submit their previous week's diary data at the start of each coaching session. For more frequent monitoring (daily check-ins), consider having participants export and submit data every 2-3 days. Set clear instructions: log into myfitnesspal.com, go to Reports, export the last 7 days, and upload the file through the designated Retool form.
Can I build a food calorie lookup tool in Retool without MyFitnessPal?
Yes. The Nutritionix API is the best alternative for active food and nutrition lookups. Its natural language endpoint accepts plain English descriptions ('a cup of brown rice') and returns detailed macro breakdowns. The free developer tier provides 500 natural language queries per day, sufficient for coaching tools with a small number of users. Configure it as a REST API Resource in Retool using your App ID and App Key from developer.nutritionix.com.
Is it safe to store participant nutrition and health data in Retool Database?
Retool Database is a managed PostgreSQL instance with encryption at rest and in transit, SOC 2 Type II certification, and GDPR compliance mechanisms. For health coaching programs not subject to HIPAA, Retool Database is a practical storage option. If your program involves clinical settings subject to HIPAA, use a HIPAA-compliant database (such as a self-hosted PostgreSQL with appropriate BAA agreements) and configure Retool's self-hosted deployment to keep all data within your VPC.
Can multiple coaches access the same Retool nutrition dashboard simultaneously?
Yes. Retool apps support multiple concurrent users with individual logins managed through Retool's Groups and Permissions system. You can create a 'Coaches' group with access to the nutrition dashboard while restricting sensitive aggregated data views to a 'Wellness Managers' group. Retool's current_user variable lets you personalize the experience — for example, pre-filtering the client list to show only each coach's assigned clients.
Talk to an Expert
Our team has built 600+ apps. Get personalized help with your project.
Book a free consultation