The Nutritionix data CSV will always be an all-inclusive list of all active items in the Nutritionix database. As a result, it is important to properly create your syncing script that ingests the Nutritionix CSV.
At minimum, we recommend that you store and update the following fields in your local production food item table:
| Field Name | Description |
|---|---|
| item_id | Nutritionix Unique ID for Item |
| nutritionix_last_sync | The timestamp time syncing script ran and touched on this item. You should always update all of the attributes of the item. |
| nutritionix_last_sync | The last_updated field from Nutritionix indicating when Nutritionix updated any data attribute on this item. |
| nutritionix_last_sync | The timestamp that your syncing script iterated over your local DB and found no match in the latest Nutritionix DB export (this indicates Nutritionix has deleted the item) |
Recommended Syncing Flow
Here is our recommended syncing script logic flow:
- Import all records from latest Nutritionix export into a staging DB
- Create a “status report” query that compares your production DB to the staging DB to determine:
- What items have been added?
- What items have been deleted?
- What items have been modified? (using the last_updated timestamp from Nutritionix)
- Use the results of the status report query to perform quality assurance on your syncing script.
- Once you are satisfied with the status report results, write a query or update script that performs the CRUD operations necessary on your production DB.
In general, Nutritionix adds or updates over 1000 food items in the DB every month, so we strongly recommend that you run your syncing script at least quarterly, if not more often.