# List locations

`GET https://app.pozyskajpacjenta.pl/api/v1/locations` · operationId `listLocations` · since 1.11.0 · tag Content

The clinic's active locations, the primary one first. A clinic with one location answers one, with the clinic profile's address, phone and hours. Use it for a locations page, a location picker or one JSON-LD entry per location. Responses are private to the key: `Cache-Control: private, max-age=60`, so cache them on your side for up to a minute.

## Request

Authorization: `Bearer <the clinic's key>`.

### cURL

```bash
curl "https://app.pozyskajpacjenta.pl/api/v1/locations" \
  -H "Authorization: Bearer $PP_API_KEY"
```

### TypeScript

```ts
import { PozyskajPacjentaClient } from "@pozyskajpacjenta/sdk";

const client = new PozyskajPacjentaClient({
  apiKey: process.env.PP_API_KEY ?? "",
  baseUrl: "https://app.pozyskajpacjenta.pl",
});

const { locations } = await client.listLocations();
```

### PHP

```php
<?php
$response = wp_remote_get(
    'https://app.pozyskajpacjenta.pl/api/v1/locations',
    array(
        'headers' => array( 'Authorization' => 'Bearer ' . getenv( 'PP_API_KEY' ) ),
        'timeout' => 10,
    )
);
if ( is_wp_error( $response ) ) {
    error_log( $response->get_error_message() );
    return;
}
$status = wp_remote_retrieve_response_code( $response );
$data   = json_decode( wp_remote_retrieve_body( $response ), true );
```

## Response

### 200: The clinic's locations.

- `locations` (`Location[]`, required): Active locations, the primary one first.
  - `id` (`string`, required): Location id.
  - `slug` (`string`, required): The location's address part, unique within the clinic.
  - `name` (`string`, required): Name of the location, e.g. the town or the district.
  - `primary` (`boolean`, required): true for the primary location (its values are the clinic profile's).
  - `phone` (`string`): Phone number for display. For a tel: link keep the digits and the +.
  - `email` (`string (email)`): The location's contact e-mail.
  - `address` (`SiteAddress`): The location's address.
    - `street` (`string`, required): Street and number.
    - `postalCode` (`string`, required): Postal code, 00-000.
    - `city` (`string`, required): City.
    - `district` (`string`): District, e.g. Mokotów.
    - `accessNote` (`string`): How to get in: entrance, floor, parking, lift.
  - `geo` (`object`): Map point of the location.
    - `lat` (`number`, required): Latitude.
    - `lng` (`number`, required): Longitude.
  - `openingHours` (`OpeningHours`): Opening hours per weekday.
    - `mon` (`OpeningInterval[]`): Monday's intervals.
      - `opens` (`string`, required): Opening time, HH:MM.
      - `closes` (`string`, required): Closing time, HH:MM, later than `opens`.
    - `tue` (`OpeningInterval[]`): Tuesday's intervals.
      - fields as in `OpeningInterval` above
    - `wed` (`OpeningInterval[]`): Wednesday's intervals.
      - fields as in `OpeningInterval` above
    - `thu` (`OpeningInterval[]`): Thursday's intervals.
      - fields as in `OpeningInterval` above
    - `fri` (`OpeningInterval[]`): Friday's intervals.
      - fields as in `OpeningInterval` above
    - `sat` (`OpeningInterval[]`): Saturday's intervals.
      - fields as in `OpeningInterval` above
    - `sun` (`OpeningInterval[]`): Sunday's intervals.
      - fields as in `OpeningInterval` above
  - `openingHoursNote` (`string`): Note shown next to the hours.
  - `nfz` (`object`): Contract with the National Health Fund (NFZ) at this location.
    - `contract` (`boolean`, required): true when the location has an NFZ contract.
    - `note` (`string`): Note about the NFZ contract.

Example (A clinic with two locations):

```json
{
  "locations": [
    {
      "id": "loc_krakow",
      "slug": "krakow",
      "name": "Kraków",
      "primary": true,
      "phone": "+48 12 100 20 30",
      "address": {
        "street": "ul. Długa 1",
        "postalCode": "30-001",
        "city": "Kraków"
      },
      "openingHours": {
        "mon": [
          {
            "opens": "08:00",
            "closes": "18:00"
          }
        ]
      },
      "nfz": {
        "contract": false
      }
    },
    {
      "id": "loc_wieliczka",
      "slug": "wieliczka",
      "name": "Wieliczka",
      "primary": false,
      "phone": "+48 12 555 44 33",
      "address": {
        "street": "Rynek Górny 2",
        "postalCode": "32-020",
        "city": "Wieliczka"
      },
      "openingHours": {
        "tue": [
          {
            "opens": "09:00",
            "closes": "17:00"
          }
        ]
      }
    }
  ]
}
```

## Errors

| Status | code | When |
| --- | --- | --- |
| 401 |  | No Authorization header |
| 401 |  | Unknown or rotated key |
| 429 |  | Over 120 requests in this minute |

401 (No Authorization header):

```json
{
  "error": "missing Authorization: Bearer <klucz z panelu Ustawienia>"
}
```

401 (Unknown or rotated key):

```json
{
  "error": "invalid key"
}
```

429 (Over 120 requests in this minute):

```json
{
  "error": "przekroczono limit 120 zapytań/min"
}
```

## Rate limit

- 120 requests per minute per key, shared by every endpoint.

## SDK method

`client.listLocations(): Promise<{ locations: Location[] }>`
