The Recipe API Plugin is a custom WordPress plugin designed to handle food recipe data through a RESTful API. This plugin allows you to create, read, update, and delete recipes, making it easy to manage and share your favorite culinary creations on your WordPress website.
To install the Recipe API Plugin on your WordPress site, follow these steps:
-
Download the plugin ZIP file from GitHub.
-
Log in to your WordPress admin panel.
-
Navigate to Plugins > Add New.
-
Click the Upload Plugin button at the top of the page.
-
Choose the ZIP file you downloaded in Step 1 and click Install Now.
-
Activate the plugin by clicking the Activate button.
Once the Recipe API Plugin is installed and activated, you can use it to manage food recipes through the API. The plugin provides the following API endpoints:
Manage Recipe:
-
GET /wp-json/recipe-api/v1/recipes: Get a list of all recipes.
-
GET /wp-json/recipe-api/v1/recipe/{slug}: Get a specific recipe by slug/name.
-
POST /wp-json/recipe-api/v1/recipe: Create a new recipe.
-
PUT /wp-json/recipe-api/v1/recipe/{slug}: Update an existing recipe by slug/name.
-
DELETE /wp-json/recipe-api/v1/recipe/{id}: Delete a recipe by slug/name.
Manage User:
- POST /wp-json/recipe-api/v1/user/signup: Create a new user.
- POST /wp-json/recipe-api/v1/user/login: validate a user with email & password.
The Recipe API Plugin requires authentication for certain actions. By default, it uses WordPress user authentication. Ensure that you have the necessary permissions to perform actions like creating or updating recipes.
Here are some examples of how to interact with the Recipe API using curl
:
Get a list of all recipes:
curl -X GET https://yourwebsite.com/wp-json/recipe-api/v1/recipes
Create a new recipe:
curl -X POST -H "Content-Type: application/json" -H "Authorization: logintoken" -d '{"title": "Delicious Pasta", "ingredients": "Pasta, Sauce, Cheese", "instructions": "Cook pasta, add sauce, sprinkle cheese, and enjoy!" "image":"image.url/base64 image", "image_src_type":"url/file"}' https://yourwebsite.com/wp-json/recipe-api/v1/recipe
Update an existing recipe:
curl -X PUT -H "Content-Type: application/json" -H "Authorization: logintoken" -d '{"id":"recipeID","title": "Amazing Pasta", "ingredients": "Pasta, Tomato Sauce, Parmesan Cheese", "instructions": "Boil pasta, mix with tomato sauce, and sprinkle Parmesan cheese.""image":"image.url/base64 image", "image_src_type":"url/file"}' https://yourwebsite.com/wp-json/recipe-api/v1/recipe/slug
Delete a recipe:
curl -X DELETE -H "Content-Type: application/json" -H "Authorization: logintoken" -d ' https://yourwebsite.com/wp-json/recipe-api/v1/recipe/123
Create a new user:
curl -X POST -H "Content-Type: application/json" -d '{"first_name": "Jakaria", "last_name": "Istauk", "email": "user@mail.domain" "password":"password"}' https://yourwebsite.com/wp-json/recipe-api/v1/user/signup
Validate a user:
curl -X POST -H "Content-Type: application/json" -d '{"email": "user@mail.domain" "password":"password"}' https://yourwebsite.com/wp-json/recipe-api/v1/user/login
If you encounter any issues or have suggestions for improving the Recipe API Plugin, please open an issue on GitHub.
Contributions to this project are welcome! Feel free to fork the repository, make changes, and create a pull request.
This plugin is licensed under the MIT License. You can find the full license text in the LICENSE file.
This Recipe API Plugin for WordPress was developed by Jakaria Istauk.