Contents
On this page

Get Nutrition - Plugixa Recipe

GET /plugixa-recipe/v1/recipes/{id}/nutrition

Read the nutrition row of a recipe.

Needs a signed-in user who can open Plugixa Recipe: the plugixa_recipe_manage capability, or WordPress’s edit_posts (Contributor and up). The Nutrition app must be on.

Request

GET https://your-site.example/wp-json/plugixa-recipe/v1/recipes/12/nutrition

Path parameters

Name Type Description
id integer The recipe’s id

Responses

200 OK. data is the nutrition row, or null when the recipe has none.

{
  "success": true,
  "message": "",
  "data": {
    "id": "7",
    "recipe_id": "12",
    "serving_size": "1 pancake",
    "calories": 180.0,
    "total_fat": 6.5,
    "saturated_fat": 2.0,
    "trans_fat": null,
    "cholesterol": 45.0,
    "sodium": 210.0,
    "total_carbohydrate": 26.0,
    "dietary_fiber": 1.0,
    "total_sugars": 6.0,
    "protein": 5.0,
    "vitamin_a": null,
    "vitamin_c": null,
    "calcium": null,
    "iron": null,
    "potassium": null,
    "source": "manual"
  }
}
Field Type Meaning
data object|null null when the recipe has no nutrition
data.serving_size string What one serving is
data.calories … data.potassium number|null The fifteen values, null when not set
data.source string Where the values came from, manual by default

Errors

Status Code When
404 rest_error No recipe with that id.

Plus the errors every endpoint can return.

Examples

curl -s "https://your-site.example/wp-json/plugixa-recipe/v1/recipes/12/nutrition" \
  -u "admin:$WP_APP_PASSWORD"
<?php
$ch = curl_init('https://your-site.example/wp-json/plugixa-recipe/v1/recipes/12/nutrition');
curl_setopt_array($ch, [
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_USERPWD        => 'admin:' . getenv('WP_APP_PASSWORD'),
]);
$response = json_decode(curl_exec($ch), true);
curl_close($ch);
const auth = 'Basic ' + btoa(`admin:${process.env.WP_APP_PASSWORD}`);
const response = await fetch('https://your-site.example/wp-json/plugixa-recipe/v1/recipes/12/nutrition', {
  headers: {
    'Authorization': auth,
  },
});
const { data } = await response.json();

Quick Links

Share