Contents
On this page

Toggle Favorite - Plugixa Recipe

POST /plugixa-recipe/v1/frontend/favorites/{recipe_id}

Add a published recipe to the caller’s favorites, or remove it when it is already there.

Needs any signed-in WordPress user, a subscriber included: a visitor with an account, signed in with the site cookie and nonce or an Application Password. The Favorites app must be on.

Request

POST https://your-site.example/wp-json/plugixa-recipe/v1/frontend/favorites/12

Path parameters

Name Type Description
recipe_id integer The recipe’s id

Responses

200 OK. data says where the recipe now stands.

{
  "success": true,
  "message": "Added to favorites.",
  "data": {
    "is_favorited": true
  }
}
Field Type Meaning
data.is_favorited boolean true when this call saved it, false when it removed it
message string Added to favorites. or Removed from favorites.

No body. The saved recipes are listed by List Saved Recipes.

Errors

Status Code When
404 rest_error No published recipe with that id.
401 rest_forbidden The request is not signed in.

Plus the errors every endpoint can return.

Examples

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

Quick Links

Share