# Hostelworld City Autocomplete API Documentation

<p><strong>Hostelworld City Autocomplete API Documentation</strong> Turn a name into Hostelworld ids. Returns cities, regions, popular places and properties that match the text, each with a numeric id, a display name and a type. Use the id of a city result as city_id in the search endpoint. A query without matches is a successful, billable response with an empty results list.</p>

- **Documentation:** [https://scrappa.co/docs/hostelworld-api/hostelworld_autocomplete](https://scrappa.co/docs/hostelworld-api/hostelworld_autocomplete)
- **API group:** Hostelworld API
- **Endpoint:** `GET https://scrappa.co/api/hostelworld/autocomplete`

## Authentication

Send your Scrappa API key in the `X-API-KEY` request header. Paid endpoints also support accountless x402 payments when called without an API key.

## Parameters

| Parameter | Type | Required | Description |
| --- | --- | --- | --- |
| `query` | string | Yes | Text to look up, 2 to 100 characters. Example: berlin. |

## Example response

```json
{
    "data": {
        "results": [
            {
                "id": 26,
                "name": "Berlin, Germany",
                "type": "city"
            },
            {
                "id": 11283,
                "name": "Berlin, New Hampshire, USA",
                "type": "city"
            },
            {
                "id": 11286,
                "city": {
                    "id": 26,
                    "name": "Berlin",
                    "country": "Germany"
                },
                "name": "EastSeven Berlin Hostel, Berlin, Germany",
                "type": "property"
            }
        ]
    },
    "meta": {
        "billable": true,
        "endpoint_family": "autocomplete"
    },
    "success": true
}
```

## Errors

| Status | Error | Description |
| --- | --- | --- |
| 422 | Validation Error | A required query parameter is missing or invalid. This response is not billable. |
| 503 | Invalid Source Response | Hostelworld answered with a shape that no longer matches the documented contract. This response is not billable. |
| 503 | Service Unavailable | The upstream service is temporarily unavailable. Please retry shortly. |

## More Scrappa resources

- [API documentation](https://scrappa.co/docs)
- [Full LLM-readable API reference](https://scrappa.co/llms-full.txt)
- [OpenAPI specification](https://scrappa.co/docs/api.json)
- [Pricing](https://scrappa.co/pricing)
