WordPress REST API
Recipes in the REST API
Recipes are accessible through the WordPress REST API at the /wprm_recipe/ endpoint.
To read, send a GET request to the /wprm_recipe/<id> endpoint:
https://demo.wprecipemaker.com/wp-json/wp/v2/wprm_recipe/41
For creating a recipe, send a POST request to the /wprm_recipe/ endpoint and include that same kind of recipe array in the JSON body:
{ "recipe": { "name": "My New REST API Recipe", "summary": "Delicious and not created in a traditional way." } }
For updating you’d do the same, but send a PUT request to the correct /wprm_recipe/<id> endpoint.
Recipe Ratings in the REST API
Ratings are accessible through the WordPress REST API at the /wp-recipe-maker/v1/rating/ endpoint by any user with the moderate_comments capability.
To read a rating, send a GET request to the /rating/<id> endpoint:
https://bootstrapped.ventures/wp-json/wp-recipe-maker/v1/rating/123
For creating a rating, send a POST request to the /rating/ endpoint and include the rating array in the JSON body.
A user rating:
{ "rating": { "recipe_id": "640", "user_id": "0", "ip": "123.321.123.321", "rating": "4" } }
A comment rating:
{ "rating": { "date": "2018-04-17 12:57:39", "comment_id": "22", "user_id": "0", "ip": "123.321.123.321", "rating": "3" } }
The system will automatically update ratings if a particular IP/user/comment has already rated a particular recipe.
/rating/recipe/<id> and /rating/comment/<id> endpoints are available as well.