---
title: "Search locations"
---

> Documentation Index
> Fetch the complete documentation index at: https://docs.npibase.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Search locations

Path: Weather API › Locations

`GET /locations`

URL: `https://api.weather.example/v1/locations`

Find places whose name matches a query, best match first.

## Authentication

- `bearer`, http bearer, header `Authorization`

## Query parameters

- `q` (`searchLocations.query.q`; string, required) — A place name, such as `Lisbon` or `Lisbon, PT`.
  - minLength: `2`
- `limit` (`searchLocations.query.limit`; integer, optional) — How many matches to return.
  - maximum: `20` · minimum: `1` · default: `5`

## Code samples

### cURL

```bash
curl --request GET \
  --url 'https://api.weather.example/v1/locations?q=string' \
  --header 'Authorization: Bearer <token>'
```

### TypeScript

```typescript
const url = 'https://api.weather.example/v1/locations?q=string';
const options = {method: 'GET', headers: {Authorization: 'Bearer <token>'}};

fetch(url, options)
  .then(res => res.json())
  .then(json => console.log(json))
  .catch(err => console.error(err));
```

### Python

```python
import requests

url = "https://api.weather.example/v1/locations?q=string"

headers = {"Authorization": "Bearer <token>"}

response = requests.get(url, headers=headers)

print(response.text)
```

## Responses

### 200

Matching places.

#### Example

```json
{
  "data": [
    {
      "id": "loc_lisbon",
      "name": "Lisbon",
      "country": "PT",
      "latitude": -90,
      "longitude": -180,
      "timezone": "Europe/Lisbon"
    }
  ]
}
```

- `data` (`searchLocations.response.200.data`; array of object, required)
  - `id` (`searchLocations.response.200.data.id`; string, required)
  - `name` (`searchLocations.response.200.data.name`; string, required)
  - `latitude` (`searchLocations.response.200.data.latitude`; number, required)
    - maximum: `90` · minimum: `-90`
  - `longitude` (`searchLocations.response.200.data.longitude`; number, required)
    - maximum: `180` · minimum: `-180`
  - `timezone` (`searchLocations.response.200.data.timezone`; string, required)
  - `country` (`searchLocations.response.200.data.country`; string, optional) — ISO 3166-1 alpha-2 code.

### 400

The request was malformed.

#### Example

```json
{
  "code": "not_found",
  "message": "string"
}
```

- `code` (`searchLocations.response.400.code`; string, required)
- `message` (`searchLocations.response.400.message`; string, required)


Source: https://docs.npibase.com/api/locations/list/index.md
