3

I'm trying to write a plugin that would add these endpoints GET, POST, DELETE /api/checked to access the plugin's custom table.

Is it possible for a Wordpress plugin to expose a RESTful API? I can't seem to find any examples or documentation.

The closest thing I found was add_rewrite_rule. I was able to create http://www.blog.com/api, but how do I determine the HTTP verb?

2 Answers 2

2

You can use WP REST API. Just install it and then go to settings -> permalink and add /%postname%/ on the last field.

then you'll have everything you need at [url]/json-api/

Here is the doc

Sign up to request clarification or add additional context in comments.

1 Comment

thanks for the link. i'm trying the sample code in "Extending the API" but the routes I create all show up as "Post Not Found". Any suggestions?
1

You can use JSON-API WordPress plugin for creating the web-services that can be used for fetching the data from Wordpress.

And the plugin will provide the webservice url something like that :

www.mysite.com/api/servicename

Plugin link : https://wordpress.org/plugins/json-api/

Hope it helps you some extent.

3 Comments

thanks for the suggestions. I considered using this plugin but it doesn't seem possible to extend it for custom tables
you can extend this plugin very easily and this plugin also allows to create custom controller / service too.
Check it out here for more clarification : bitsandbabble.com/2013/10/…

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.