# Suggestion

Search API v0.6.6 · 1 operation
Source: https://plasapi.com/search/v0.6.6/suggestion/

No description in the specification.

## Get Suggestions

`GET` `/suggestions` · `GetSuggestions`

Get search suggestions for `/work/search`.

The `query` parameter should be the same as for `/work/search`.  
and the `filter` parameter should be the same as for `/work/search`, but some search filter may not be working in suggestions, see which ones by calling configuration. 

The response will be an array of suggestions of the type specified in the `types` parameter, and will be ordered by relevance.

Filters:

These only affects the suggestions of the type `work`:
- plas.audience.literal
- plas.audience.ageRange 
- plas.audience.ageGroup
- plas.mediaTypes
- plas.language
- plas.subjects
- plas.genres
- plas.forms
- plas.agent


### Example request

**cURL**

```bash
curl -X GET "$PLAS_BASE_URL/suggestions?version=0.6.6" \
  -H 'Accept: application/json' \
  -H "Authorization: Bearer $PLAS_TOKEN"
```

**JavaScript**

```javascript
const response = await fetch(`${process.env.PLAS_BASE_URL}/suggestions?version=0.6.6`, {
  method: "GET",
  headers: {
    "Accept": "application/json",
    "Authorization": `Bearer ${process.env.PLAS_TOKEN}`,
  },
});
const data = await response.json();
```

**Python**

```python
import os
import requests

response = requests.get(
    f"{os.environ['PLAS_BASE_URL']}/suggestions",
    params={
        "version": "0.6.6",
    },
    headers={
        "Accept": "application/json",
        "Authorization": f"Bearer {os.environ['PLAS_TOKEN']}",
    },
)
data = response.json()
```

The host and token are environment variables: `PLAS_BASE_URL` the provider’s base URL · `PLAS_TOKEN` an access token.

### Parameters

- `query` (In `query`, `string`, optional) — The suggestion (search) query.
- `size` (In `query`, `integer`, optional) — Suggestion size (default 10).
- `types` (In `query`, [`array of SuggestionParameterTypeEnum`](https://plasapi.com/search/v0.6.6/schemas/#SuggestionParameterTypeEnum), optional) — List of suggestion types allowed in result.
- `filter` (In `query`, `object`, optional) — The suggestion (search) filter.

The possible keys in this map are the filters defined in the `/configuration(/search)` endpoint (field: (search->)suggestions->>available) and are a list of strings of the `SearchFilterType` type.


Shared across operations: `ui_language`, `version`. [See the shared contract on the version page.](https://plasapi.com/search/v0.6.6/)

### Responses

#### `200` Success

`GetSuggestionsResponseBody`

Example (Generated from the schema):

```json
{
  "suggestions": [
    {
      "query": "undset",
      "type": "query"
    }
  ]
}
```

#### `400` The list of errors.

`Errors`

Shared response, defined once for the whole API. [See the shared contract on the version page.](https://plasapi.com/search/v0.6.6/)

Example (Generated from the schema):

```json
{
  "errors": [
    {
      "code": 200103,
      "info": "200103: invalid/unsupported query parameter value"
    }
  ]
}
```

#### `401` Bearer token invalid, missing, or expired.

No response body.

Shared response, defined once for the whole API. [See the shared contract on the version page.](https://plasapi.com/search/v0.6.6/)

#### `404` Resource not found.

No response body.

Shared response, defined once for the whole API. [See the shared contract on the version page.](https://plasapi.com/search/v0.6.6/)
