Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Wordpress Plugin - Expose REST API

Tags:

wordpress

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?

like image 796
YarGnawh Avatar asked Feb 15 '26 23:02

YarGnawh


2 Answers

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

like image 71
Unex Avatar answered Feb 19 '26 10:02

Unex


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.

like image 37
Jenis Patel Avatar answered Feb 19 '26 10:02

Jenis Patel