SearchWP API Queries

REST API Add-on For SearchWP

Our SearchWP API plugin adds an endpoint to the WordPress REST API to allow you to run advanced searches via a RESTful API, thanks to the awesome powers of SearchWP. This endpoint uses the class SWP_Query, which is documented here.

This add-on does not required SearchWP. It did intentionally, but now it will fallback to using WP_Query id SearchWP is not installed. But SearchWP queries are indexed, so it should be faster when SearchWP is installed.

Supported Queries

Basic Queries

Search By Keyword


Default is an empty string

Search Using A Supplemental Search Engine


Default is “default”
Note: Engine must exists. Expect a 400 error if it does not.
See: Setting Up A Supplemental Search Engine

Control Posts Per Page


Default is current setting for posts_per_page
Note: Posts per page is limited to 50 by default. Use “cwp_swp_api_max_posts_per_page” filter to change.

Disable Pagination Of Results


Default is false

Results Page


Default is 1

Limit Posts To Be Returned


Default is false

Exclude Posts From Results


Default is false

Meta Queries Based On Custom Posts

This plugin probably offers the most flexible meta queries via the REST API possible.

Basic Meta Query

Search by custom field value, key, with comparison.


Default is false
Note: All three parts of the meta_query are required. If any are omitted a 400 error will occur.

More Complex Meta Queries

Meta Relationships

Use variable meta_relation to change relationship been queries. Also, you can set compare, like with regular meta_queries. Make sure your compare argument is in the right order.

Example: Search where jedi field is “luke” or sith field is not “vader”.

Multiple Values In A Query Part

Put multiple fields into your query parts, by adding extra nesting levels in URL string. Order gets very tricky, numbers (remember to start at 0) help, as shown below.

Example: Search where jedi field is “luke” or “obi-wan” and sith field is not “vader”.


Nested meta queries added in version 1.1.0 and allow for querying by multiple meta fields. Be sure to see the relevant section of the WP_Query docs

Taxonomy Based Queries

This plugin probably also offers the ability to do complex queries bases on taxonomies.


Default is false
Note: All three parts of the tax_query are required. If any are omitted a 400 error will occur.
Note: At this time you may only query by a single term. There is an open issue for this, if you submit a patch for it, and that patch is merged, you will receive a prize.

Perform A Date Query


Default is false
Note: All three parts of the date_query are required. If any are omitted a 400 error will occur.