--- title: SearchAPIClient Apex class slug: '2988' canonical_url: https://docs.coveo.com/en/2988/ collection: coveo-for-salesforce source_format: adoc --- # SearchAPIClient Apex class You can use this Apex classes to call the Coveo Search API. > **Note** > > You should also consult the: > > * [SearchApiResponse Apex class](https://docs.coveo.com/en/3117/). > > * [SearchApiResult Apex class](https://docs.coveo.com/en/3119/). ## Methods ### `querySuggestResponse` Represents the structure of a response from the `QuerySuggestion` API. It contains the following attributes: * `expression`: The expression to complete the query. * `score`: The score associated to the query suggestion. * `executableConfidence`: The confidence ratio given by [Coveo Machine Learning (Coveo ML)](https://docs.coveo.com/en/188/). ### `querySuggest` Calls the API to request query suggestions (see [querySuggestPost](https://docs.coveo.com/en/13#operation/querySuggestPost)). You can use the following `params`: * `body`: The body of the `querySuggest` request. It should include at least `locale`, `q`, and `searchHub`. * `authorization`: The content of the Authorization header to send (for example, `Bearer TOKEN`). ```apex String token = CoveoV2.Globals.generateSearchToken(); List suggestions = CoveoV2.SearchApiClient.querySuggest( new Map{ 'locale' => 'en', 'q' => '', 'searchHub' => 'hub' }, 'Bearer ' + token); System.debug(suggestions); ``` ### `executeQuery` Executes a query to the organization currently linked to the package or any URI. ```apex String token = CoveoV2.Globals.generateSearchToken(); CoveoV2.SearchApiResponse response = CoveoV2.SearchApiClient.executeQuery( new Map{ 'q' => 'my query text' }, 'Bearer ' + token); System.debug(response); ```