REST API
Property Hive extends the standard WordPress REST API by allowing you to query, create, update and delete properties by making HTTP requests to WordPress.
To get started we recommend you get familiar with the core principles of the WordPress REST API, including authentication, pagination etc.
Retrieving Properties
To query properties in their most basic form you can make a HTTP GET request to the following URL:
https://{your-site.com}/wp-json/wp/v2/property
This will return all on market properties.
You can filter the properties returned by passing in the same parameters used on a standard property search on the website. For example:
https://{your-site.com}/wp-json/wp/v2/property?department=residential-lettings
or
https://{your-site.com}/wp-json/wp/v2/property?department=residential-sales&minimum_bedrooms=2
Don't forget that results returned will be paginated by default. Read more about pagination here in the WP REST API docs.
Creating and Updating Properties
You can also create and update properties using Property Hive and making HTTP POST requests to WordPress REST API.
You'll need to authenticate to perform such actions. Read more about authentication here in the WP REST API docs.
A simple example of a POST request to update an existing property would look something like so:
POST https://{your-site.com}/wp-json/wp/v2/property/243328 HTTP/1.1 Content-Type: application/json Authorization: Basic {application-password} {"title":"High Street, Birmingham","status":"publish","on_market":"yes","department":"residential-sales","address_country":"GB","price":123000,"features":["poolside","fireplace"],"virtual_tours":[{"url":"https:\/\/youtube.com","label":"VT1"},{"url":"https:\/\/vimeo.com","label":"VT2"}],"images":[{"url":"https:\/\/imageurl.com\/image1.jpg"},{"url":"https:\/\/imageurl.com\/image2.jpg"}]}