Metadata-Version: 2.4
Name: mapmap-client
Version: 0.1.1
Summary: Generated Python client for the MapMap gateway API (routing, geocoding, matrix, isochrones, optimisation, truck/ADR, tiles and styles), from the live https://api.mapmap.ai/openapi.json.
Home-page: https://github.com/Mapmapai/mapmap
Author: Mapmap AI Ltd
Author-email: Mapmap AI Ltd <hello@mapmap.ai>
License: MIT
Project-URL: Homepage, https://mapmap.ai/docs/api-reference
Project-URL: Documentation, https://mapmap.ai/docs/api-reference
Project-URL: Repository, https://github.com/Mapmapai/mapmap
Keywords: mapmap,openapi,routing,geocoding,maps,adr,truck-routing
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: urllib3<3.0.0,>=2.8.0
Requires-Dist: python-dateutil>=2.9.0.post0
Requires-Dist: pydantic>=2
Requires-Dist: typing-extensions>=4.16.0
Dynamic: author
Dynamic: home-page
Dynamic: license-file

# mapmap-client (Python)

A generated Python client for the full MapMap gateway API: routing, ADR
truck compliance, geocoding, matrices, isochrones, optimisation, tiles and
styles. Generated directly from the live OpenAPI document at
[`https://api.mapmap.ai/openapi.json`](https://api.mapmap.ai/openapi.json)
with [OpenAPI Generator](https://openapi-generator.tech) 7.16.0 (the
`python` generator). Full generated method-by-method reference:
[`API.md`](./API.md).

Regenerated on **25 November 2026** against the 0.3.0 document, which
declared **181 operations**; this client carries a typed method for all 181.
That is a measurement with a date on it rather than a standing promise: the
API moves and a generated client does not move with it, so before relying on
an endpoint, check it is in [`mapmap_client/api`](./mapmap_client/api) and
regenerate if it is not. It sat at 69 of 128 for seven weeks under wording
that said "every endpoint".

For an agent framework instead of a raw HTTP client, see
[`langchain-mapmap`](../langchain-mapmap) or
[`crewai-mapmap`](../crewai-mapmap), which wrap the MCP server's tools
directly.

## 60-second quickstart

```bash
pip install mapmap-client
```

Get a card-free key in one call, then make your first request:

```bash
curl -fsS -X POST "https://api.mapmap.ai/v1/keys" \
  -H "Content-Type: application/json" \
  -d '{"email": "you@example.com", "accept_tos": true}'
```

```python
import mapmap_client

config = mapmap_client.Configuration(
    host="https://api.mapmap.ai",
    access_token="snk_...",  # the "key" field from the response above
)

with mapmap_client.ApiClient(config) as api_client:
    routing = mapmap_client.RoutingApi(api_client)

    # OSRM-compatible route: Dover to Birmingham, 44 t artic, 4.0 m tall,
    # ADR tunnel restriction code C/E. The answer is an OsrmRouteResponse
    # model; each entry of its `routes` is a plain dict.
    result = routing.get_route(
        profile="truck",
        coordinates="1.3134,51.1279;-1.8904,52.4862",
        height=4.0,
        weight=44.0,
        hazmat=True,
        tunnel_code="C/E",
    )
    print(result.routes[0]["distance"], result.routes[0]["duration"])
```

No key yet and just want to check connectivity? `mapmap_client.MetaApi(api_client).health()`
hits the unauthenticated `/health` endpoint.

## Place entrances

A place's entrances are the doors OpenStreetMap maps on it, tied to the place
on evidence (its own building outline, a station's stop area, a matching
address, or being the building's only occupant). None is estimated today:
every door served has `source: "osm"`. An empty list means no door is tied to
the place, not that it has none.

The door data is on api.mapmap.ai (checked on 23 November 2026). On a
deployment without it, `get_place_entrances` raises a `ServiceException` with
status 501 and problem type `entrances-not-enabled`, and the `include` answers
below carry
`entrances_index: "not-configured"` with `entrances: None` on each place.

- `GeocodingApi.get_place_entrances(id=...)` calls
  `GET /v1/places/{id}/entrances` (operationId `get_place_entrances`) with a
  place id exactly as a place result reports it (`properties.id`, such as
  `osm:w119438298:poi`). The answer is a `PlaceEntrancesResponse`:
  `id, name, lat, lon, entrances, entrances_index, note`, where each entrance
  is a dict `{lon, lat, kind, wheelchair, access, door, level, ref, name,
  osm_id, source, confidence, basis}`. `confidence` (`high`, `medium`, `low`)
  grades how sure the tie between door and place is, and `basis` says what
  tied them (`own_outline`, `stop_area`, `address_match`, `sole_occupant`).
  An unknown place raises `NotFoundException` (404).
- `include="entrances"` on `GeocodingApi.get_geocode`, `get_geocode_reverse`,
  `get_geocode_retrieve` and `DirectionalApi.get_places_in_view` adds the same
  entrance list to every place: `features[i]["properties"]["entrances"]` on
  the geocoding answers, `results[i]["entrances"]` (with the place's `id`) on
  in-view. Off by default, so answers without it are unchanged; any other
  value is a 400. A feature with no place id to look up gets `entrances: None`.
- `entrances_index` on `GeocodeFeatureCollection` and `PlacesInViewResponse`
  (`loaded`, `not-configured` or `failed`) says whether there was door data
  to read.
- `RoutingApi.post_route` (`POST /route`) ends at a place's door when its
  free-form body sends `place_id` on the last location, or top-level
  `arrive_at` (`"entrance"` or `{place_id, entrance_kind, wheelchair}`).
  `RouteResponse.arrival` then says which door and why (`applied`,
  `place_id`, `entrance`, `reason`, `moved_m`, `original_destination`), or
  `applied: False` with the reason; the route is never refused for it.

```python
import mapmap_client
from mapmap_client.exceptions import ServiceException

config = mapmap_client.Configuration(host="https://api.mapmap.ai", access_token="snk_...")

with mapmap_client.ApiClient(config) as api_client:
    geocoding = mapmap_client.GeocodingApi(api_client)

    # Find the place, asking for its doors on the same call.
    found = geocoding.get_geocode(q="Waitrose, Liverpool Road, London", include="entrances")
    print("door data:", found.entrances_index)  # "loaded" when the deployment has it
    features = found.features or [{}]
    place_id = features[0].get("properties", {}).get("id") or "osm:w119438298:poi"

    # Or ask for one place's doors by its id.
    try:
        doors = geocoding.get_place_entrances(id=place_id)
    except ServiceException as error:
        if error.status != 501:
            raise
        print("no door data on this deployment:", error.data.detail)
    else:
        if not doors.entrances:
            print(doors.note)  # no door is tied to this place, which is not the same as none
        for door in doors.entrances or []:
            print(door["kind"], door["confidence"], door["lat"], door["lon"])
```

## Navigation sessions

A navigation session is turn-by-turn guidance held by the gateway, for
clients that cannot run guidance themselves (voice assistants, wearables,
agents). Open one with an origin and a destination, post each position fix,
and every answer gives the `state` (`on_route`, `off_route`, `rerouted`,
`arrived` or `lost_position`), the next instruction and what is left to go.
Phone and in-car apps should use the mobile SDKs instead, which run guidance
on the device.

What a session keeps, and for how long:

- **Gateway memory only.** Sessions do not survive a gateway restart or a
  deploy. A session that has gone raises `NotFoundException` (404): open a new
  one from where the traveller is now.
- **Two hours idle.** A session with no progress and no read for two hours
  expires; every progress request and every read resets the clock
  (`expires_at`, `idle_ttl_s` on the answers).
- **The route and the last accepted fix only.** No trail of earlier
  positions is kept.

The four methods are on `RoutingApi`:

| Method | Route | operationId |
|---|---|---|
| `create_navigation_session(create_session_request)` | `POST /v1/navigation/sessions` (201) | `create_navigation_session` |
| `send_navigation_progress(id, progress_request)` | `POST /v1/navigation/sessions/{id}/progress` | `send_navigation_progress` |
| `get_navigation_session(id)` | `GET /v1/navigation/sessions/{id}` | `get_navigation_session` |
| `delete_navigation_session(id)` | `DELETE /v1/navigation/sessions/{id}` (204) | `delete_navigation_session` |

- `CreateSessionRequest` takes `origin` and `destination` (`{lat, lon}` or
  `{place_id}`), `costing` (as on `POST /route`), `costing_options`, `truck`,
  `adr` and `options` (`landmarks`, `language`, `units`). The answer, a
  `CreateSessionResponse`, carries `session_id`, `route`, `first_instruction`,
  `expires_at`, `idle_ttl_s` and `privacy`.
- `arrive_at` is `"point"` (the default, the destination's own coordinates),
  `"entrance"` (the best mapped door of the place at the destination), or
  `{place_id?, entrance_kind?, wheelchair?}`. When a door was asked for, the
  answer's `arrival` says which one and why, or `applied: False` with the
  reason; the session still opens. See "Place entrances" above.
- `ProgressRequest` takes `lat`, `lon` and `timestamp` (an RFC 3339 string or
  milliseconds since the Unix epoch), and optionally `heading_deg`,
  `speed_mps` and `accuracy_m`. The answer, a `ProgressResponse`, has
  `state`, `fix` (`accepted`, and `reason` when the fix was not used),
  `next_instruction`, `instruction_changed`, `distance_to_next_m`,
  `remaining_m`, `remaining_s`, `eta`, `off_route` (in `off_route`) and
  `route` (the new route, in `rerouted`).
- `arrive_at` and `timestamp` are oneOf fields, so the generated models wrap
  them: `from_dict` takes the plain values (as in the example below), and
  keyword construction takes the wrappers, `arrive_at=SessionArriveAt("entrance")`,
  `arrive_at=SessionArriveAt(SessionArriveAtDoor(entrance_kind="main", wheelchair=True))`
  and `timestamp=FixTime("2026-11-20T16:04:05Z")` or `FixTime(1763654645000)`.
- On routes in Great Britain, `route.duration_s`, `remaining_s` and `eta`
  include the typical-delay calibration that `route.eta_calibration`
  describes.
- Opening a session and posting progress are metered; reading and ending
  are free. See <https://mapmap.ai/pricing>.

```python
from datetime import datetime, timezone

import mapmap_client
from mapmap_client.exceptions import NotFoundException

config = mapmap_client.Configuration(host="https://api.mapmap.ai", access_token="snk_...")

with mapmap_client.ApiClient(config) as api_client:
    routing = mapmap_client.RoutingApi(api_client)

    session = routing.create_navigation_session(mapmap_client.CreateSessionRequest.from_dict({
        "origin": {"lat": 52.2, "lon": 0.13},
        "destination": {"lat": 52.204, "lon": 0.142},
        "costing": "pedestrian",
        "options": {"landmarks": True, "language": "en-GB"},
    }))
    print(session.first_instruction.text, "expires", session.expires_at)

    try:
        # One fix per update from the device's location source.
        answer = routing.send_navigation_progress(session.session_id, mapmap_client.ProgressRequest.from_dict({
            "lat": 52.2001, "lon": 0.1342, "heading_deg": 91,
            "timestamp": datetime.now(timezone.utc).isoformat(timespec="seconds"),
        }))
    except NotFoundException:
        print("the session has gone (expired or the gateway restarted): open a new one")
    else:
        if answer.next_instruction and (answer.instruction_changed or answer.state == "rerouted"):
            print(answer.next_instruction.text)  # read it out
        print(answer.state, answer.remaining_m, "m to go, arriving", answer.eta)

    routing.delete_navigation_session(session.session_id)
```

## Self-hosted

Point `host` at your own gateway instead:

```python
config = mapmap_client.Configuration(host="https://maps.internal.example")
```

## Regenerating this client

The client is generated, not hand-written. To refresh it against a newer
API version:

```bash
curl -fsS https://api.mapmap.ai/openapi.json -o openapi.json
docker run --rm -v "$(pwd)/..:/local" openapitools/openapi-generator-cli:v7.16.0 generate \
  -i /local/openapi.json \
  -g python \
  -o /local/mapmap-client-python \
  --package-name mapmap_client \
  --skip-validate-spec \
  --additional-properties=packageVersion=0.1.1,projectName=mapmap-client,licenseInfo=MIT
```

If Docker cannot bind-mount this directory (Colima without a home-directory
mount, for example), generate inside the container instead: `docker create`
the same command with `-i /tmp/openapi.json -o /tmp/out`, `docker cp` the
spec into `/tmp`, `docker start -a` it, and `docker cp` `/tmp/out` back.
Copy the result over this package without the files listed below, and keep
the existing generated tests. The generated `README.md` is the method-by-method
reference: copy it to `API.md`.

`--skip-validate-spec` is needed because openapi-generator's 3.1 validator
currently flags a missing `info.license.identifier` on the live spec as an
error; that is a spec metadata nit worth fixing upstream, not a real
incompatibility, and it does not affect the generated code. Re-apply the
metadata fixes and the security floors (Python 3.10 or newer, `urllib3>=2.8.0`,
`python-dateutil>=2.9.0.post0`) in `pyproject.toml`, `setup.py`, `requirements.txt`,
`README.md` and `LICENSE` after regenerating, since the generator overwrites them with its own
defaults. Keep `test-requirements.txt` too: the generator rewrites it with old floors
(`pytest>=7.2.1`, `tox>=3.9.0`, `mypy>=1.5`) and drops the `filelock` and `virtualenv` pins.

## Publishing (maintainers)

Never from a laptop. `.github/workflows/publish-python-packages.yml` builds,
tests and `twine check`s this package on every pull request that touches it,
and publishes it to PyPI through trusted publishing (no stored token) when
dispatched on main with the version typed in full:

```bash
# Dry run: build, test and twine check only
gh workflow run publish-python-packages.yml -R Mapmapai/mapmap --ref main \
  -f package=mapmap-client

# Publish: confirm_version must equal the version in pyproject.toml
gh workflow run publish-python-packages.yml -R Mapmapai/mapmap --ref main \
  -f package=mapmap-client -f confirm_version=0.1.1
```

For a later release, bump `version` in `pyproject.toml` and `setup.py` (and
the CHANGELOG) first: PyPI never accepts the same version twice.

## Licence

MIT for this generated client. The MapMap service itself is governed by
<https://mapmap.ai/terms>.
