# Quickstart

> Five minutes from an empty form to an address field with suggestions. You need a key, one script line and one HTML element.

Source: https://findort.ch/en/docs/

## Base URL

All endpoints live under:

```text
```

The API has two endpoints: [`GET /v1/search`](https://findort.ch/en/docs/search/) searches by text, [`GET /v1/reverse`](https://findort.ch/en/docs/reverse/) finds what is at a coordinate.

## 1. Get a key

Create a [free account](https://api.findort.ch/app/login?plan=free&lang=en) and add a key in the dashboard. There are two kinds:

| Key | For | Check |
|---|---|---|
| `pk_…` public | Browser, HTML, Web Component | only works on the domains you list |
| `sk_…` secret | Servers, scripts, backends | no origin check, never in a browser |

More under [authentication](https://findort.ch/en/docs/authentication/).

## 2. First request

Try the API with curl and your secret key:

```bash
  -H "Authorization: Bearer sk_…"
```

The response is flat JSON with a ready-made `label`:

```json
  "results": [
    {
      "id": "N3797624451",
      "label": "Bundesplatz 3, 3011 Bern",
      "name": "Bundesplatz 3",
      "type": "address",
      "category": "place:house",
      "address": {
        "street": "Bundesplatz",
        "housenumber": "3",
        "postcode": "3011",
        "city": "Bern",
        "state": "Bern",
        "country": "Switzerland",
        "countryCode": "CH"
      },
      "location": { "lat": 46.94649, "lon": 7.44433 }
    }
  ],
  "attribution": "© OpenStreetMap contributors, ODbL"
}
```

Every field is explained in [response format](https://findort.ch/en/docs/response/).

## 3. Add the search field

Two lines of HTML are enough. The script loads the `<findort-search>` Web Component, which works with any framework or none:

```html

<findort-search key="pk_…" country="ch" lang="en" name="address"></findort-search>
```

When someone picks a suggestion, the element fires a `findort-select` event. It carries the whole place with address parts and coordinates:

```html
  document.querySelector('findort-search').addEventListener('findort-select', (e) => {
    const place = e.detail.place;
    console.log(place.label, place.location.lat, place.location.lon);
  });
</script>
```

Inside a `<form>` the element submits the chosen text under the name from `name`. Attributes, styling and keyboard support are covered in [Web Component](https://findort.ch/en/docs/web-component/).

> **Local development:** add your local address to the public key too, for example `http://localhost:5173`. Otherwise the API answers with `403 origin_not_allowed`.

## 4. On the server

For servers there are libraries with no dependencies. Use the secret key there.

```js
import { Findort } from 'findort';

const findort = new Findort(process.env.FINDORT_KEY, { lang: 'en', country: 'ch' });
const place = await findort.geocode('Bundesplatz 3, Bern');
```

```php
$place = $findort->geocode('Bundesplatz 3, Bern', ['country' => 'ch']);
```

```python
from findort import Findort

findort = Findort(os.environ["FINDORT_KEY"], lang="en")
place = findort.geocode("Bundesplatz 3, Bern", country="ch")
```

Details: [JavaScript](https://findort.ch/en/docs/javascript/), [PHP](https://findort.ch/en/docs/php/), [Python](https://findort.ch/en/docs/python/).

## Next steps

- [Search](https://findort.ch/en/docs/search/): every parameter to narrow down results
- [Errors](https://findort.ch/en/docs/errors/): every code and what to do about it
- [Limits](https://findort.ch/en/docs/limits/): quotas, rate limits and the OpenStreetMap attribution duty
