Get started with the customer API
Every request to the customer API needs an API key. This page covers creating a key, making a first request, and replacing or removing a key.
Create your API key
- Sign in to Nutritionist Pro online and open the Settings page from the user profile menu in the top-right corner.
- Go to the API Key card.
- Select Generate Key.
- Copy the key shown under Your new API key. It begins with
npcust_.
Copy the key and save it in a secure location, such as a password manager, before you leave the page. Nutritionist Pro does not store the key in a readable form, so it cannot be shown again. If you lose it, regenerate a new one.
The card also shows the API base URL with a copy button. Use that value as the start of every request URL.
Make a first request
Replace <API_KEY> with your key:
curl -H "Authorization: Bearer <API_KEY>" \
"https://dev.nutritionistpro.com/v3/customer/recipes?limit=1"
A working key returns HTTP 200 and a JSON body whose status is true. If you get a 401, check that the whole key was copied, including the npcust_ prefix. See Errors and limits for every status code.
Check when a key was used
Once a key exists, the API Key card shows:
- Created. When the key was generated.
- Last used. The most recent request made with the key, or "never". This value is updated at most once every five minutes.
- Used today. How many of your 500 daily requests you have made today. The count resets at midnight UTC. See Daily request limit.
Regenerate a key
Select Regenerate Key to replace your key with a new one. The new key is shown once, in the same way as the first.
Regenerating invalidates the previous key immediately. Any integration still using the old key receives a 401 until it is updated with the new one.
Revoke a key
Select Revoke Key and confirm to delete your key without creating a replacement. Requests made with a revoked key receive a 401.
One key for each user
Each user has one API key at a time. A key returns the data its owner can see in Nutritionist Pro, so two users on the same account can each hold their own key.
Keep your key private
An API key grants read access to your account data. Treat it like a password:
- Keep it on your server. Do not place it in web page source, a mobile app, or any code that runs in a customer's browser.
- Do not commit it to a shared code repository.
- If a key may have been exposed, regenerate it.
Trial accounts
Trial accounts cannot create an API key. On a trial account the API Key card shows "API keys are not available to trial users." and the Generate Key button is disabled.
When a subscription ends
A key does not expire by date. It stops working when the account no longer has an active subscription, and requests then receive a 403. The same key works again once the subscription is active.