skip to Main Content
< All Articles
Print

REST API Route

Rest Base

The REST base for the listings data is properties as follows

yoursite.com/wp-json/wp/v2/properties

To see this in action, the following route will return the data from our demo site.

https://rem.webcodingplace.com/wp-json/wp/v2/properties

Specific Fields

Listings data contains a large quantity of data: basic information such as content, title, and author ID, but also custom property fields, media information, and links to other resources. Your application may not need all of this information on every request. To let your API return only specific fields in a response, you may use the _fields query parameter.

If for example, you are building an archive view and only need the ID, title, permalink, agent and excerpt, you can restrict the response to only those fields with this fields query:

https://rem.webcodingplace.com/wp-json/wp/v2/properties?_fields=author,id,excerpt,title,link

Pagination Parameters

Any API response which contains multiple resources supports several common query parameters to handle paging through the response data:

  • ?page=: specify the page of results to return.
    • For example, /wp/v2/properties?page=2 is the second page of listings data
    • By retrieving /wp/v2/properties, then /wp/v2/properties?page=2, and so on, you may access every available listing through the API, one page at a time.
  • ?per_page=: specify the number of records to return in one request, specified as an integer from 1 to 100.
    • For example, /wp/v2/properties?per_page=1 will return only the first listing.
  • ?offset=: specify an arbitrary offset at which to start retrieving listings
    • For example, /wp/v2/properties?offset=6 will use the default number of per_page but start at the 6th listing in the collection
    • ?per_page=5&page=4 is equivalent to ?per_page=5&offset=15
Quick Navigation
Back To Top