# Search typeahead

Return YouTube's public anonymous search suggestions for a partial query. Suggestions are surface strings, not popularity metrics.

- Platform: [YouTube](https://docs.upscrape.com/docs/platforms/youtube)
- Capability ID: `youtube.search.typeahead`
- Cost: 1 credit per request
- Maximum runtime: 30 seconds
- Execute endpoint: `POST https://data.upscrape.com/execute`

## Request

Use the exact public capability ID in the shared execute envelope.

```bash
curl --request POST \
  --url https://data.upscrape.com/execute \
  --header "Authorization: Bearer $UPSCRAPE_API_KEY" \
  --header "Content-Type: application/json" \
  --header "Prefer: wait=30" \
  --data '{
  "input": {
    "query": "golang"
  },
  "capability": "youtube.search.typeahead"
}'
```

## Input


| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `language` | `string` | No | Optional language code for the suggestion surface |
| `query` | `string` | Yes | Partial search query |

### Example input

```json
{
  "query": "golang"
}
```

## Response

Successful output is returned in `results[0].data`.

Raw platform output is intentionally open-ended and may evolve with the upstream source.

### Illustrative sample output

This example shows one response. Values and optional fields vary with the data available.

```json
{
  "count": 3,
  "query": "golang",
  "suggestions": [
    "golang tutorial",
    "golang vs rust",
    "golang course"
  ]
}
```
### Illustrative output fields

Derived from the sample above for orientation only. These fields are not a fixed response schema.

| Path | Observed type | Example |
| --- | --- | --- |
| `count` | `integer` | 3 |
| `query` | `string` | golang |
| `suggestions` | `array` | 3 items |
| `suggestions` | `array` | 3 items |

## Execution behavior

A `200` response completed inline. A `202` response was queued; poll `GET /jobs/{id}` until the job reaches `completed` or `failed`. Use an `Idempotency-Key` when retrying must not create a duplicate logical job.

## Related documentation

- [Authentication](https://docs.upscrape.com/docs/api/authentication)
- [Jobs and results](https://docs.upscrape.com/docs/api/jobs)
- [Errors and retries](https://docs.upscrape.com/docs/api/errors)
- [Idempotency](https://docs.upscrape.com/docs/api/idempotency)
