BuddyPress REST API Feature Plugin Now in Development

Developers interested in contributing to the creation of a BuddyPress REST API met for the first time yesterday to discuss a path forward. Bronson Quick is leading the project with the help of Ryan Fugate. Quick works for Human Made and is a WordPress core contributor. He is also the lead contributor on Chassis, a lightweight WP Vagrant install that uses Puppet for provisioning.

John James Jacoby set up a GitHub repository where development for the BP REST API will take place. In summarizing the meeting’s discussion regarding planning and architecture, Quick said, “Planning how we tackle this is very important rather than diving straight into the code. As we’re ‘standing on the shoulders of giants’ we can use the lessons learned from the WP REST API project and put in time at the start to plan this properly.

“It makes sense to plan out the data we would like returned from endpoints and how they relate to each other with _links. For example, if we’re displaying the data for the activities endpoint rather than showing a user_id we should link this to a user endpoint.”

The team will be taking a “schema first” approach and plans to adhere to Test Driven Development – planning an endpoint, writing tests that fail then writing the code for the endpoint until the tests pass.

“This is something that’s often talked about as being an ideal development methodology but it’s rarely practiced in the WordPress space,” Quick said. “Tackling a project this way should mean less bugs although I do realize this could be a blocker for new contributors.”

The BP REST API team plans to tackle read-only endpoints first for the activity stream and xprofile components via the _links method Quick outlined. Ryan Fugate opened a GitHub issue regarding the plugin’s folder structure/loader, and the plan is to design it as a feature plugin that will one day land in BuddyPress core.

What is the Purpose of a BP REST API?

During the meeting contributors discussed the primary problems that a BP REST API should solve, which Quick summarized in the meeting notes.

The team agreed that the main purpose for building the API is to expose BuddyPress data in a RESTful way so that developers and site owners can use it to create plugins, mobile apps, or anything else they want.

“The other main purpose for the BP REST API is that we can use the endpoints going forward to alter some things internally in BuddyPress, as in the past ‘the functions throughout BuddyPress are very purpose built to solve one specific theme-side problem,'” Quick said.

If you want to get involved in building a REST API for BuddyPress make sure to follow the project on GitHub and jump into the discussion happening in the #buddypress Slack channel.