Migrating from the V2 API
This page is for integrations built on the earlier Nutritionist Pro web service, described in the document "NexGen RESTful API V1". The customer API returns the same information with a cleaner format, and adds recipes, ingredients, and labels as endpoints of their own.
An integration has to change in four places: the base URL, authentication, the routes, and the field names.
Base URL and authentication
The customer API has a new base URL:
https://dev.nutritionistpro.com/v3/customer
Authentication uses one key in place of the earlier key and secret pair.
- Earlier: the secret in the
Authorizationheader, and the key in anapi_tokenquery parameter. - Now: one API key in the
Authorizationheader, asAuthorization: Bearer npcust_....
Earlier keys and secrets are not accepted. Create a new key on the Settings page. See Get started.
Routes
Recipe books were called books, and their recipes were called foods.
GET /booksis nowGET /recipe-books.GET /books/{book}is nowGET /recipe-books/{id}.GET /books/{book}/foodsis nowGET /recipe-books/{id}/recipes. Addview=fullto get the full detail of each recipe, as the earlier route returned.GET /books/date/{date}is nowGET /recipe-books?updated_since={date}.GET /books/date/{date_from}/{date_to}is nowGET /recipe-books?updated_since={date_from}&updated_until={date_to}.
The earlier date routes returned each changed book together with its recipes. The customer API returns the changed books, and the recipes of each book come from GET /recipe-books/{id}/recipes.
These endpoints are new:
GET /recipesandGET /recipes/{id}. Recipes without going through a book.GET /ingredients/{id}. The ingredients behind a recipe.GET /labelsandGET /labels/{id}. Labels.
Response format
Responses are wrapped
Earlier responses were the record or list itself. Every customer API response is wrapped, with the content in data:
{
"status": true,
"code": 200,
"data": {}
}
Lists are paged
The earlier routes returned every record in one response. The customer API returns pages of up to 200 records with a meta block. See Lists and syncing.
Errors use HTTP status codes
Earlier errors were returned with HTTP status 200 and the error code inside the body, with "status": "error". The customer API returns the real HTTP status code, and status is false. See Errors and limits.
A request for a book that does not exist now returns 404. A date that cannot be read returns 400.
Recipe book fields
book_system_idis nowid.book_nameis nowname.foods_countis nowrecipe_count. A recipe listed twice in a book is counted once.client_idandclient_nameare nowaccount.idandaccount.name.creator_idandcreator_nameare nowcreator.idandcreator.name.foodsis nowrecipes.deleted_foods, a list of objects with afood_system_id, is nowdeleted_recipe_ids, a list of IDs.
created_at and updated_at are new.
Recipe fields
food_system_idis nowid.food_nameis nowname.unique_codeis nowcode.client_idandclient_nameare nowaccount.idandaccount.name.creator_idandcreator_nameare nowcreator.idandcreator.name.region, a name, is now an object withidandname.preparation_methodandmeal_componentare unchanged. Each is still a single name.preparation_timeis unchanged.cooking_time, text such as90 min(s), is nowcooking_time_minutes, a number such as90.cooking_temprature, text ending indegrees, is nowcooking_temperature, the text as entered in the recipe.Instructions(shown asinstructionsin the earlier documentation), the steps joined with spaces, is nowinstructions, the steps in order and separated by line breaks.number_of_servingsis unchanged.serving_amount_valueis nowserving.amount.serving_amount_unitis nowserving.unit.serving_amount_gram_weightis nowserving.gram_weight.allergens, a list of names, is now a list of objects withidandname.
serving.note, nutrient_basis, ingredients, created_at, and updated_at are new.
Nutrient fields
nutrient_nameis nowname.nutrient_valueis nowvalue.nutrient_unitis nowunit.
id and abbreviation are new. Match nutrients by id, which does not change if a nutrient is renamed.
The same nutrients are published as before, and values are still for one serving. See Nutrients.
Earlier responses could return nutrients as an object with gaps in its numbering. It is now always a list.
Other differences
- Dates in requests were
YYYY-MM-DDonly. A date and time is now accepted as well. - A date range used to include the first instant of the end date only.
updated_untilwith a date now covers that whole day. - Recipes in Draft status are no longer returned.
- A key returns what its owner can see in Nutritionist Pro. The earlier web service returned the data of every user on the account.
- The earlier web service needed a separate API product on the account. The customer API needs only an active Nutritionist Pro online subscription.
Checklist
- Create an API key on the Settings page.
- Change the base URL.
- Send the key as
Authorization: Bearer, and remove theapi_tokenparameter. - Rename the routes.
- Read records from
data, and page through lists withlimitandoffset. - Rename the fields, and handle the values that changed type.
- Check HTTP status codes for errors.