Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Is there some REST API that Wordpress supports, out of the box or through any plugin that exposes the same information exposed through the normal pages? (I.e. latest posts, filtering by categories etc.)

There seems to be a JSON API plugin but it seems to be very old and not maintained.

There also seems to be some plugin called Jetpack but not sure if it provides what I am looking for (seems more dedicated to content management rather than exposing it publicly).

I am trying to integrate a Mobile App with a Wordpress Blog, and I need to find the best way to transfer the information to the application in terms of performance and also displaying it right. (Any ideas appreciated)

share|improve this question

4 Answers 4

up vote 2 down vote accepted

The REST API can be used for straight-up retrieval on any blog that has enabled it. Self-hosteds require an active choice to turn the JSON interface on in Jetpack but once it's up it's wide open.

This is not necessarily appreciated by everyone, and that's somewhat understandable. I picked a blog ID at random here for the /posts/ call:

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

That's the full output. If you were trying to make life marginally harder for scrapers by only providing excerpts in your RSS feed then this pretty much undoes that. It's a pretty false sense of security - if your blog is public then it's scrapeable - but not everyone loves this fact.

For your purposes you can absolutely just use the API to pull individual posts and display them in an alternate manner.

share|improve this answer
    
Thanks for the pointer. Maybe it could be authenticated in some way to avoid direct scraping? Although as you are saying its not seriously protecting against anything. (Search engines scrape anyway to index your blog). –  jbx Apr 22 '13 at 14:46

For the record, I'm not sure why anyone would use the JetPack JSON API as it currently works for a self hosted site. If you're doing AJAX and JSON, the whole point is to get back some JSON data FAST. Using jetpack involves an unnecessary call to wordpress.com, which then does a call to your own self hosted blog. Using the wonderful JSON API plugin, you make a call directly back to your self hosted site, avoiding the call to wordpress.com.

Doing some speed tests comparing loading a page (in JSON format) via the JSON API plugin and via Jetpack shows that the Jetpack JSON API takes roughly 3 times the time of using the JSON API plugin. It might be an older plugin, but it works absolutely perfectly for me!

For anyone who wants to duplicate the tests using the two methods, install both the JSON API plugin and the Jetpack plugin, then compare (obviously replacing example.com and some-page-slug):

  • http://example.com/api/get_page/?slug=some-page-slug (this uses the JSON API plugin)
  • https://public-api.wordpress.com/rest/v1/sites/example.com/posts/slug:some-page-slug?type=page (this uses the Jetpack JSON API)

I used webpagetest.org to run the speed tests on both the URLS.

share|improve this answer
    
Thanks for your insight. Yes a system which just uses the self hosted site is much better in all cases. –  jbx Sep 30 '13 at 13:50

Just for the record, I have used the JSON API plugin a couple months ago and it still works like a charm.

Actually, now that I check they have updated the plugin in June 2013, and works very well. I like it better than JetPack because is more extensible.

Also, I came across this very recently, might be worth checking out: http://thermal-api.com/.

share|improve this answer

You have a few options.

The Jetpack plugin allows you to use the WordPress REST API on self-hosted blogs (previously, it was only available to WordPress.com blogs). This is probably exactly what you are looking for.

Documentation: WordPress REST API Documentation

Alternatively, all self-hosted WordPress installs also have a built-in XML-RPC API that can be used for mobile app integration.

Documentation: WordPress XML-RPC API Documentation

share|improve this answer
1  
I don't know if I am incorrect, but both seem to be targeted for posting/managing blog posts rather than plain retrieving information. Am I missing something? For instance, in the XML-RPC version simple operations like wp.getPost() require a username/password. I just want to develop a small app which displays pretty much the same articles on the blog, but formatted properly for it. –  jbx Mar 1 '13 at 21:59

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.