REST API Endpoints

GravityView 2.0 features a new simple but powerful REST API that allows read-only access to Views and Entries.

There are four endpoints in the /wp-json/gravityview/v1/ namespace:

/views

Returns a list of all the views available to the current user along with the needed fields to render their layouts and some additional information. Form/View administrators can access the connected form, View settings, etc.

URL Parameter What it does Default Value
page Set the current page number 1
limit Set the number of results returned per page. Set to 0 for all Views. 10

/views/$id

Same as /views but for one specific View.

/views/$id/entries.json or (.html, .csv, or .tsv)

Returns all the entries under the select View. Available in .json.html , .csv, and  .tsv format (template used will be the current View template, but can be overridden as needed under a REST context). Only directory-mode entry fields will be included. Extra fields can be added via the gravityview/rest/entry/fields filter.

The structure returned is quite simple - a key-value object with ID -> value.

URL Parameter What it does Default Value
page Set the current page number 1
limit Set the number of results returned per page. Set to 0 for all entries. 10
post_id Set the "parent" Post or Page ID for the View, as if the View were embedded. NULL

/views/$id/entries/$id.json (or .html)

The same as entries.json, but only single-mode entry fields will be included. The same filter gravityview/rest/entry/fields can be used to alter this behavior.

.html format instead of .json will return HTML code instead. Useful for lazy-loading pagination, etc.

URL Parameter What it does Default Value
post_id Set the "parent" Post or Page ID for the View, as if the View were embedded. NULL

Authentication

For Views based on a user's login status ( filter entries created by logged in user , for example) WordPress REST API authentication is required, specifically the X-WP-Nonce header, in which all requests are considered unauthenticated. For more information, check out the official REST API documentation here.


Examples from our demo site

A list of Views of a site:

Here are some View endpoints:

And Single Entry endpoints:

Did this answer your question? Thanks for the feedback There was a problem submitting your feedback. Please try again later.

Still need help? Contact Us Contact Us