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.
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 ...
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!
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With