---
title: "Retrieve a location"
---

> 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.

# Retrieve a location

Path: Weather API › Locations

`GET /locations/{location_id}`

URL: `https://api.weather.example/v1/locations/{location_id}`

## Authentication

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

## Path parameters

- `location_id` (`getLocation.path.location_id`; string, required)
  - example: `"loc_lisbon"`

## Code samples

### cURL

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

### TypeScript

```typescript
const url = 'https://api.weather.example/v1/locations/loc_lisbon';
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/loc_lisbon"

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

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

print(response.text)
```

## Responses

### 200

The location.

#### Example

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

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

### 404

Nothing exists at that id.

#### Example

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

- `code` (`getLocation.response.404.code`; string, required)
- `message` (`getLocation.response.404.message`; string, required)


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