Access your WordPress site's data through an easy-to-use HTTP REST API.
The "develop" branch is undergoing substantial changes and is NOT COMPLETE OR STABLE.
The "master" branch represents a BETA of our next version release.
The latest stable version is available from the WordPress Plugin Directory.
WordPress is moving towards becoming a fully-fledged application framework, and we need new APIs. This project was born to create an easy-to-use, easy-to-understand and well-tested framework for creating these APIs, plus creating APIs for core.
This plugin provides an easy to use REST API, available via HTTP. Grab your site's data in simple JSON format, including users, posts, taxonomies and more. Retrieving or updating data is as simple as sending a HTTP request.
Want to get your site's posts? Simply send a GET
request to /wp-json/posts
.
Update user with ID 4? Send a POST
request to /wp-json/users/4
. Get all
posts with the search term "awesome"? GET /wp-json/posts?filter[s]=awesome
.
It's that easy.
WP API exposes a simple yet easy interface to WP Query, the posts API, post meta API, users API, revisions API and many more. Chances are, if you can do it with WordPress, WP API will let you do it.
WP API also includes an easy-to-use JavaScript API based on Backbone models, allowing plugin and theme developers to get up and running without needing to know anything about the details of getting connected.
Check out our documentation for information on what's available in the API and how to use it. We've also got documentation on extending the API with extra data for plugin and theme developers!
There's no fixed timeline for integration into core at this time, but getting closer!
Drop this directory in and activate it. You need to be using pretty permalinks to use the plugin, as it uses custom rewrite rules to power the API.
Want to test out WP-API and work on it? Here's how you can set up your own testing environment in a few easy steps:
-
Install Vagrant and VirtualBox.
-
Clone Chassis:
git clone --recursive [email protected]:Chassis/Chassis.git api-tester
-
Grab a copy of WP API:
cd api-tester mkdir -p content/plugins content/themes cp -r wp/wp-content/themes/* content/themes git clone [email protected]:WP-API/WP-API.git content/plugins/json-rest-api
-
Start the virtual machine:
vagrant up
-
Activate the plugin:
vagrant ssh -c 'cd /vagrant && wp plugin activate json-rest-api'
-
Set the permalink structure to something other than the default, in order to enable the https://vagrant.local/wp-json/ endpoint URL (if you skip this step, it can be accessed at https://vagrant.local/?json_route=/):
vagrant ssh -c "cd /vagrant && wp rewrite structure '/%postname%/'"
You're done! You should now have a WordPress site available at https://vagrant.local; you can access the API via https://vagrant.local/wp-json/
To access the admin interface, visit https://vagrant.local/wp/wp-admin and log in with the credentials below:
Username: admin
Password: password
For testing, you'll need a little bit more:
-
Clone the Tester extension for Chassis:
# From your base directory, api-tester if following the steps from before git clone --recursive https://github.com/Chassis/Tester.git extensions/tester
-
Run the provisioner:
vagrant provision
-
Log in to the virtual machine and run the testing suite:
vagrant ssh cd /vagrant/content/plugins/json-rest-api phpunit
You can also execute the tests in the context of the VM without SSHing into the virtual machine (this is equivalent to the above):
vagrant ssh -c 'cd /vagrant/content/plugins/json-rest-api && phpunit'
All tickets for the project are being tracked on GitHub. You can also take a look at the recent updates for the project.
Previous issues can be found on the GSOC Trac issue tracker, however new issues should not be filed there.