Step 1:
Click on Create API in the navigation bar of the plugin for creating new Custom endpoints / REST Routes.
Step 2:
Configuring the Custom Endpoint:
- Enter the name of API endpoint and choose the HTTP method as GET.
- After that select the table from which you want to fetch data than select columns you want to fetch.
- Choose appropriate conditions according to your requirements or you can opt for no condition as well.
- In URL parameters dropdown select First parameter. After configuring click on Generate API button.
Step 3:
Preview configured Custom Endpoint / REST Route
- After you click on generate API , you’ll obtain your Custom API/endpoint as mentioned below.
- Use this API on any platform according to your requirements.
Step 4:
Custom API/endpoint response
- You will receive an API response in JSON format as shown below.
- For retrieving post with title “sample” , you can use following API ->
http://localhost/wptest/wp-json/mo/v1/demo/sample where HTTP method will be GET.