I have recently been exploring the REST API plugin for WordPress and how it works, and why it is such a big deal, as I’ve been hearing for a while that the WP Rest API is “a game changer” in the web development world. Of course, as a web developer, we hear this every month about some new technology, so I was a bit skeptical.
The nuts and bolts
HOW IT WORKS
Once the WP-API plugin is installed in your WordPress site if you type in yourblogURL followed by /wp-json/wp/v2/posts you will see all of the posts on your site formatted as JSON. You can also delimit the response by typing in ?per_page=2 on the end for example. Additionally, you can also display post with a certain category by adding on the parameter ?categories=2. Not only can you do this for posts. You can also do the same for pages, authors, media, users, taxonomy, tags, comments and any other built in WordPress endpoints. You can also use PHP to create your own custom JSON endpoints.
I am fairly new to the WP API and I am experimenting with ways I can leverage the power of the WP-API via turorials and my own experimenting. I found a cool plugin in the WordPress plugin directory called SearchWP Live Ajax Search which makes use of the WP API to retrieve an AJAX search feature that I am currently using on this blog.
I’m curious as to how other companies and individuals are using the WP-API (if you are). WordPress started out as just a blogging platform but has evolved into an extendable web platform where you can develop fully blown websites and applications.
Feel free to comment and let me know of creative ways to use this powerful feature in WordPress.
WP REST API resources
- Learn Web Code- REST API Examples
- WordPress REST API by example – a simple ToDo application
All content belongs to Bruce Gilbert