# WG-Gesucht Locations

Resolve a German city to the city_id that search requires. Pass query to search by name, or city_id to look a city up directly. Name search is a substring match and returns every matching city in one page, so a single Berlin lookup returns all cities whose name contains the term. Send one or the other: when both are present city_id wins and query is ignored, because one billable request is one upstream lookup and the two are served by different endpoints.

- **Documentation:** [https://scrappa.co/docs/wg-gesucht-api/wg_gesucht_locations](https://scrappa.co/docs/wg-gesucht-api/wg_gesucht_locations)
- **API group:** WG-Gesucht API
- **Endpoint:** `GET https://scrappa.co/api/wg-gesucht/locations`

## 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 | No | City name to search for, matched as a substring. Either this or city_id is required. |
| `city_id` | integer | No | City id to look up directly. Either this or query is required. |

## Example request

```bash
#!/bin/bash

curl -X GET \
    -H "x-api-key: YOUR_API_KEY_HERE" \
    "https://scrappa.co/api/wg-gesucht/locations?query=Berlin"
```

## Example response

```json
{
    "success": true,
    "data": {
        "cities": [
            {
                "city_id": 8,
                "city_name": "Berlin",
                "country_code": "DE",
                "city_and_state": "Berlin"
            }
        ]
    },
    "meta": {
        "duration_ms": 121,
        "endpoint_family": "locations"
    }
}
```

## Errors

| Status | Error | Description |
| --- | --- | --- |
| 404 | Not Found | The requested query combination is not served. This response is not billable. |
| 422 | Validation Error | A public parameter is invalid, including a missing scope field or a category and rent type the platform does not serve. This response is not billable. |
| 503 | Service Unavailable | The service could not obtain a complete result. This response is not billable. |

## 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)
