# REST API

## Enabling the REST API

To use the Rest API, it has to be enabled first under the **Compatibility options** menu.

![](/files/p3I6xKgGnv0MomkRGeFq)

## REST API Endpoints

All endpoints can be accessed under the `ajax-search-pro/v0` namespace at this moment. Both **GET** and **POST** methods are supported.

All endpoints with examples can be found on [this Postman link](https://www.postman.com/interstellar-sunset-850998/ajax-search-pro/collection/1q5kn48/asp-rest-v0-endpint-examples)

### Generic Search Endpoint

`wp-json/ajax-search-pro/v0/search`

#### Query Parameters

* **s** (string)(Required) - search phrase
* **id** (int)(Optional) - Search instance

#### Examples

[Postman collection link](https://www.postman.com/ernestmarcinko/workspace/ajax-search-pro/request/20902664-1da97d6b-93af-48b9-ad50-1bc363de7154)

```
curl --location --request GET 'https://test.local/wp-json/ajax-search-pro/v0/search?s=test&id=1'
```

### WooCommerce only Search Endpoint

`wp-json/ajax-search-pro/v0/woo_search`

The main difference between this and the generic search endpoint is, that this will try to find the first search instance, which is configured for WooCommerce search (when the ID query parameter is not defined)

#### Query Parameters

* **s** (string)(Required) - search phrase
* **id** (int)(Optional) - Search instance. When not defined, the plugin will try to find the first search instance with the "product" custom post type selected. If not found, or no instances exist, then will trigger a search for the "product" custom post type with the default configuration.

#### Examples

[Postman collection link](https://www.postman.com/ernestmarcinko/workspace/ajax-search-pro/request/20902664-413dfe47-1b24-4ec0-9ad7-353b555ddf60)

```
curl --location --request GET 'https://test.local/wp-json/ajax-search-pro/v0/woo_search?s=test&id=1'
```

### WooCommerce only search specific endpoing


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://knowledgebase.ajaxsearchpro.com/api/rest-api.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
