Is there a wordpress plugin for creating an API fr

2019-03-29 18:39发布

I'd like to use the data from my wordpress site in an API form. Maybe REST with JSON output. I'm wondering if there's any plugins that automatically make the wordpress data accessible from outside the site its running on, similar to the way most web APIs work.

5条回答
淡お忘
2楼-- · 2019-03-29 19:06

Yes there is a way, and I just found it!

You can go here: http://developer.wordpress.com/docs/api/

all you have to do is fill in your website into a request like:

https://public-api.wordpress.com/rest/v1/sites/$yourSiteHere/posts/

and you'll get a beautiful JSON back.

You can post comments, get data, and add queries pretty easily.

If you want to do more that requires login, you can use oAuth.

查看更多
Evening l夕情丶
3楼-- · 2019-03-29 19:09

API Endpoints wordpress plugin lets you construct any API out of your WordPress site.

查看更多
4楼-- · 2019-03-29 19:12

WordPress is basically a REST-powered platform to begin with. You enter a URL with a particular query string (sometimes buried in a 'pretty permalink') and the system returns a semi-static resource based on the layout and structure defined in your theme.

To build it into an 'API' you'd need to first identify what information you're returning and how you want to structure it. Do you want people to access your data via a typical link (http://blog.url/?post=xxx&category=xxx&whatever=xxx)? Or do you want to keep running a typical blog but allow API access through another mechanism?

If you want the second route, you could always hook a plug-in into WordPress' built-in XMLRPC service. Then users will make a request of something like http://blog.url/xmlrpc.php?resource=xxx&variable=yyy&somethingelse=zzz and your site would return whatever information you want (though this would be SOAP, not REST ... so it's really up to you).

See my answer here for a specific example with WordPress code ...

查看更多
放我归山
5楼-- · 2019-03-29 19:23

If you are a Wordpress plugin developer and you need a RESTFul API maybe thermal-api.com can help you: Wordpress plugin to connect to a REST API?

But I think the best way is using WP-REST-API: http://v2.wp-api.org/extending/adding/

查看更多
Juvenile、少年°
6楼-- · 2019-03-29 19:28

I have used this REST/JSON API plugin with some success, so while not for creating an API, you could possibly pull it apart and change it to your needs? This plugin seems to only support output, and not input (comments etc). There also seems to be discussion regarding creating similar api plugs for both input and output, and that might be one way to go, also. Have fun!

查看更多
登录 后发表回答