Articles, Misc|Rants

Single page application built on WP REST API

In the upcoming weeks I’ll be working on a single page application built on WP REST API. If you don’t know what that is, read Brian Krogsgard’s awesome article on it. Anyways, what will be this project about?

Helping People With Their Housing Needs

The project will be a web application helping tenants and real estate owners match each other comfortably and inexpensively. Flat owners can create a simple yet apt web pages detailing their flats with pictures, location, number of rooms, price and more. The web pages are then shared throughout the flat owner’s social network and groups related to renting and finding flats. On the other side, people looking for a suitable living space stumble upon these offers with links pointing to the web pages describing them. They navigate to the offer details, seeing beautiful pictures and most importantly the list of other people who are interested in renting the property too. Flat owner can see the email addresses of the candidates so he or she can contact them about the offer.

How will the project utilize WP REST API?

I’ll be building the web application on top of WordPress. However, I wanted to try using WP REST API on a real project, so I’ve decided the application will be single page. It means that it will be getting all the data with JavaScript AJAX requests. Ideally all of them. I’ll be using Facebook’s ReactJS library for building the user interface.

Flats will be stored in the posts table with a custom post type. Their properties (e.g. price, area) will be stored as post meta data with custom meta keys in the postmeta table. WP REST API is good at creating a new post or retrieving it. Same can be said about working with WordPress users and taxonomies. On the other hand, WP REST API (v1.2) falls short when you want to do an advanced database query. You can’t query the posts by meta keys and values like you would do with WP_Query WordPress built-in class. I will have to extend the WP REST API or use WordPress AJAX functionality to allow querying by meta keys and values. Hopefully, the REST API seems to be designed with the ability for extensions in mind.

Additional information

The project will be developed on GitHub in the open source. I’ll write more about the development progress and insights from using the WP REST API in the near future. Stay tuned!

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s