# Locations

> The places the location filter accepts (every country, region and city, searched by the start of a name), so a typeahead can be filled without shipping our list around. Costs no jobs.

Source: https://hyperjobs.io/docs/api-reference/locations

<EndpointHeader method="GET" path="/v1/locations" />

The values [`location=`](/docs/api-reference/jobs-list#query-parameters) accepts on
`/v1/jobs`: every country, first-level region and city in the
[GeoNames](https://www.geonames.org) gazetteer (about 240,000 places) composed
as `city, region, country`, `region, country`, or `country`, so a filter built
from this list can never be a typo. A place is listed whether or not a job is
there today; a search there returns no jobs. The list changes only when the
gazetteer does, a few times a year.

Ask it as the user types: `q` matches the start of a place's label, its own
name or another name it goes by, biggest place first. Without `q` the biggest
places come back.

The list also offers **groups of countries** (continents and common regions):
`Europe`, `European Union`, `Latin America`, `DACH`, `Nordics` and more. A group
matches every job in any of its countries, so `location=Europe` returns a job in
Paris, a job open to anyone in Europe and an EU-only job alike, while
`location=European Union` leaves out a job open only in the UK. A group is a way to
search, never a job's location: a posting open to a whole region lists that
region's countries as places in `locations`.

<CodeGroup>
```bash title="cURL"
curl -H "Authorization: Bearer $HYPERJOBS_KEY" \
  "https://api.hyperjobs.io/v1/locations?q=milan&limit=10"
```

```js title="Node"
const res = await fetch("https://api.hyperjobs.io/v1/locations?q=milan&limit=10", {
  headers: { Authorization: `Bearer ${process.env.HYPERJOBS_KEY}` },
});
const { data, total } = await res.json(); // data is an array of label strings
```

```python title="Python"
import os, requests

res = requests.get(
    "https://api.hyperjobs.io/v1/locations",
    params={"q": "milan", "limit": 10},
    headers={"Authorization": f"Bearer {os.environ['HYPERJOBS_KEY']}"},
    timeout=30,
)
res.raise_for_status()
labels = res.json()["data"]
```
</CodeGroup>

## Query parameters

<Fields>
  <ParamField query="q" type="string">
    The start of a place's name, in any case and with or without accents: the
    typeahead case. `q=mil` returns Milan, Milwaukee and the rest, biggest first;
    `q=munc` finds Munich through its German name, München. Other names count in
    English, German, French, Spanish, Portuguese, Dutch and Italian.
  </ParamField>
  <ParamField query="limit" type="integer" default="100">
    Labels to return (default 100, max 1000, min 1). Without `q` the biggest
    places come back, so the default is a picker's first page. An out-of-range or non-numeric value is a [`400`](/docs/errors).
  </ParamField>
</Fields>

Unknown parameters are rejected with a `400` that names the parameter, like
every other endpoint.

## Response

`{ total, limit, data }`. `data` is an array of plain strings, not objects, and
`total` is how many it holds (at most `limit`).

```json title="Response"
{
  "total": 3,
  "limit": 3,
  "data": [
    "Milan, Lombardy, Italy",
    "Milwaukee, Wisconsin, United States",
    "Milpitas, California, United States"
  ]
}
```

(Illustrative.)

A `q` that matches nothing is a `200` with `total: 0` and an empty `data`,
not a `404`.

## Using a label

Pass it back verbatim as `location=` on
[`/v1/jobs`](/docs/api-reference/jobs-list): the full string when you want
exactly one place, or just the leading name when you want every place with
that name:

```bash
# Exactly one place.
curl -G https://api.hyperjobs.io/v1/jobs \
  -H "Authorization: Bearer $HYPERJOBS_KEY" \
  --data-urlencode 'location=Berlin, Berlin, Germany'

# Every Berlin we have: a bare name is answered for all of them, never guessed at.
curl -G https://api.hyperjobs.io/v1/jobs \
  -H "Authorization: Bearer $HYPERJOBS_KEY" \
  --data-urlencode 'location=Berlin'
```

`location=` also takes a place's **other names**: another language's
(`München`, `Deutschland`) or a short form (`TX`, `NSW`). `q` finds a place
through them, but the list always answers with the place's own label, so a
picker shows each place once. A name several places share matches any of them
(`Frankfurt` is Frankfurt am Main and Frankfurt (Oder)).

Labels contain commas, so to send several, **quote each one**:
`location="Berlin, Berlin, Germany","Munich, Bavaria, Germany"` is OR; an
unquoted value is a single location. A value that isn't in this list is a
`400` on `/v1/jobs`, with the nearest labels in the hint, never a silently
ignored filter.

<Note>
  Place data from [GeoNames](https://www.geonames.org), licensed under
  [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/).
</Note>

## Cost

Requires a key, and counts one request against your
[per-minute rate](/docs/rate-limits), but bills **no jobs**, whatever the
`limit`. It sells no job rows, so it doesn't touch the monthly quota.

## Errors

| Status | Cause |
| --- | --- |
| `400` | Unknown parameter or invalid `limit`. The body names the `param` and carries a `hint`. |
| `401` | Missing, unknown, revoked, or expired key. |
| `402` | Monthly [quota](/docs/rate-limits) already exhausted: the gate runs before every endpoint, including free ones. |
| `429` | [Rate limit](/docs/rate-limits) exceeded. |
| `500` | Server error. Retry with backoff. |

## Related

<CardGroup cols={2}>
  <Card title="List jobs" icon="Search" href="/docs/api-reference/jobs-list">
    The `location` filter, with its quoting rule.
  </Card>
  <Card title="Filtering jobs" icon="Funnel" href="/docs/guides/filtering">
    The whole filter vocabulary, and the semantics that surprise people.
  </Card>
  <Card title="Dataset metadata" icon="ChartBar" href="/docs/api-reference/meta">
    The other vocabulary endpoint: `?source=` values and live coverage.
  </Card>
  <Card title="Rate limits & quotas" icon="Gauge" href="/docs/rate-limits">
    What costs jobs and what doesn't.
  </Card>
</CardGroup>
