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

# Python

> Integrate the Baato API into Python projects with the official PyPI package.

The Python client is a thin synchronous wrapper over the Baato API, returning parsed JSON
dictionaries. It suits backend workloads — batch geocoding, enrichment jobs, and serving
Baato results through your own API.

<Columns cols={2}>
  <Card title="PyPI" icon="python" href="https://pypi.org/project/baato/" horizontal>
    `baato`
  </Card>

  <Card title="Authentication" icon="key" href="/about/authentication" horizontal>
    Read the token from the environment, not source.
  </Card>
</Columns>

## Installation

<CodeGroup>
  ```bash pip theme={null}
  pip install baato
  ```

  ```bash uv theme={null}
  uv add baato
  ```

  ```bash poetry theme={null}
  poetry add baato
  ```
</CodeGroup>

## Creating a client

Construct the client once and reuse it. All six services hang off the same instance.

```python theme={null}
import os

from baato import BaatoClient

client = BaatoClient(
    access_token=os.environ["BAATO_ACCESS_TOKEN"],
    endpoint="https://api.baato.io/api",  # default
    version="v1",                          # default
)
```

Every method returns the raw [response envelope](/about/concepts#the-response-envelope), so
results are under `response["data"]`.

## Usage

<AccordionGroup>
  <Accordion title="Search — place suggestions" icon="magnifying-glass" defaultOpen>
    ```python theme={null}
    response = client.search(q="kathmandu")
    print(response["data"])
    print(response["status"])
    ```
  </Accordion>

  <Accordion title="Reverse Search — coordinates to an address" icon="location-crosshairs">
    ```python theme={null}
    response = client.reverse(lat=27.70446921370009,lon=85.32051086425783)
    print(response["data"])
    print(response["status"])
    ```
  </Accordion>

  <Accordion title="Places — full detail for a place ID" icon="location-dot">
    ```python theme={null}
    response = client.places(place_id=100006)
    print(response["data"])
    print(response["status"])
    ```
  </Accordion>

  <Accordion title="Nearby Places — places around a point" icon="compass">
    ```python theme={null}
    response = client.near_by(lat=27.717245, lon=85.323959, type="school")
    print(response["data"])
    print(response["status"])
    ```
  </Accordion>

  <Accordion title="Directions — routes between points" icon="route">
    ```python theme={null}
    response = client.direction(points=["27.71772,85.32784", "27.73449,85.33714"], mode="car")
    print(response["data"])
    print(response["status"])
    ```
  </Accordion>

  <Accordion title="Map Styles — fetch a style document" icon="layer-group">
    ```python theme={null}
    response = client.map_style(style_name="monochrome")
    print(response["data"])
    print(response["status"])
    ```
  </Accordion>
</AccordionGroup>

## Next

<Columns cols={2}>
  <Card title="API reference" icon="code" href="/services/overview">
    Every parameter, with a live playground.
  </Card>

  <Card title="Errors and status codes" icon="triangle-exclamation" href="/services/errors">
    What to retry, and what to fix.
  </Card>
</Columns>
