aportee
A Python client and command-line tool for the à portée access API for
Canada: walking, cycling and transit minutes to everyday amenities at any point, place and
amenity search, reference datasets, map images and embeds.
Every CLI command has a --json mode that prints the API payload, and an exit code that maps
to the HTTP status, so a script or coding agent can branch on it without parsing text.
Documentation: aportee.ca/dev/tools/cli and the
API reference.
Install
Needs Python 3.11 or later. It has no dependencies outside the standard library.
pipx install aportee # the aportee command
uvx aportee access 43.25085 -79.81809 # or run it without installing
pip install aportee # the Python client in a project
Keys
Most read calls work without a key (100 requests a day per IP address). A free key raises
the limit to 1,000 a day and unlocks batch lookups, map images, walking routes, the name search
near a point, and transit at other periods, at p90 (the worst case) or by bike + transit.
aportee login gets one: it prints a link and a code and opens your browser, where you sign
in and approve. It then prints export APORTEE_API_KEY=… (the key is shown once). --name
sets the name shown on the approval page. You can also sign in
and choose Create a key on your account page.
eval "$(aportee login)" # or copy the export line it prints
export APORTEE_API_KEY=ap_... # or pass --key <k>
export APORTEE_BASE=https://aportee.ca # another deployment (or --base)
Command line
| Command |
What it does |
aportee access <lat> <lon> |
Minutes to each amenity type from a point. --mode walk\|bike\|transit\|combo (default walk; combo is bike + transit), and for transit --period weekday_peak\|weekday_night\|saturday_midday\|sunday_midday and --statistic p50\|p90. --include minutes,population,place,narrative,walk_counts (or all), --types grocery,pharmacy, --lang en\|fr, --walk-minutes 5-55 for walk_counts. |
aportee describe <lat> <lon> |
Just the generated walkability narrative. --lang en\|fr. |
aportee where <lat> <lon> |
Nearest populated place. |
aportee find <name> |
Place search. Add --near <lat,lon> (keyed) to also search, by name, the POIs reached on foot from there; --walk-minutes sets how far (default 15). |
aportee compare <lat,lon> <lat,lon> |
Per-type minutes delta between two points. --types, --mode, --period, --statistic. |
aportee routes <lat> <lon> --types grocery,school |
The walked path to the nearest place of each of 1–5 types, routed live (keyed; each type routed counts as one request). |
aportee compass <lat> <lon> |
Each everyday trip's nearest place, its minutes and its direction, and the next places. --types. |
aportee batch <file.csv\|-> |
Batch lookups from lat,lon CSV rows (keyed). --format json\|geojson, --mode, --period, --statistic. |
aportee image <lat> <lon> |
Branded map PNG (keyed). --out FILE, --zoom --types --theme --lang -w -h, --markers-file FILE (your own points, up to 500: a CSV of lat,lon[,label] or a GeoJSON FeatureCollection). |
aportee embed <lat> <lon> |
iframe snippet. --zoom --types --theme --lang -w -h --dots 0, --markers-file FILE (up to 20 points, without labels). |
aportee amenities |
Every amenity type with English and French labels. |
aportee reference [canale\|sam] |
Can-ALE and Spatial Access Measures records. --id, --mode. |
aportee me |
The key's tier, today's limit and what is left. Not counted against the limit. |
aportee login |
Get a free API key by approving it in your browser. --name. |
access, describe, where, routes, compass, image, embed and reference also accept --place "<name>"
instead of <lat> <lon>. It takes the centre of the first town matching that name (no street
addresses). Global flags: --json, --key <k>, --base <url>, --help.
aportee access 43.25085 -79.81809 --include all
aportee access 45.5017 -73.5673 --mode transit --types grocery,pharmacy
aportee describe --place "Kitchener"
aportee find "Fickle Fig" --near 48.43,-123.37
aportee compare 43.25,-79.82 43.65,-79.38 --types grocery,pharmacy
aportee routes 43.25085 -79.81809 --types grocery,school
aportee compass 43.25085 -79.81809
aportee image --place Hamilton --out hamilton.png
aportee image 53.5465 -113.555 --zoom 15 --markers-file permits.csv --out permits.png
aportee reference sam 43.25 -79.82 --mode walking
Exit codes
| Code |
Meaning |
0 |
success |
2 |
bad input (400 / 422, or bad arguments) |
3 |
no data (204) |
4 |
outside coverage (404) |
5 |
rate limited (429) |
1 |
anything else: no key (401), network, 5xx |
Python
from aportee import Client
client = Client() # reads APORTEE_API_KEY; Client(key="ap_...") also works
# One point needs no key and returns a dict.
snapshot = client.access((43.25085, -79.81809), types=["grocery", "pharmacy"])
print(snapshot["minutes"]["grocery"]) # {'value': 6, 'reason': 'ok'}
# A list of points is sent 100 at a time (keyed) and returns a list in the same order.
results = client.access([(43.25, -79.82), (43.65, -79.38)], include="minutes")
client.amenities() # [{'type': 'grocery', 'label': {...}}, ...]
client.search("Hamilton") # {'places': [...]}
client.reference("canale", id="35250773")
client.routes((43.25085, -79.81809), ["grocery", "school"]) # GeoJSON, keyed
client.compass((43.25085, -79.81809)) # {'cell': ..., 'trips': [...], 'meta': ...}
client.me() # your tier and what is left of today's limit
# A map image with your own points on it (keyed): up to 20 pairs go in the query, more
# (up to 500), labels or a GeoJSON FeatureCollection are sent as a POST.
png = client.image(53.5465, -113.555, zoom=15, markers=[(53.5465, -113.555, "Permit 1")])
Results are plain dicts and lists. With pandas installed, to_frame flattens them into a
DataFrame with dotted columns such as minutes.grocery.value:
from aportee import to_frame
frame = to_frame(results)
A failed call raises aportee.ApiError with status, code and detail.
Client().login() runs the same browser sign-in as aportee login and keeps the new key on
the client.
Development
cli/ is its own uv project, separate from the repository's root Python project (the data
pipeline). Inside the root venv, the aportee command is the pipeline's; run the client with
uv run --project cli aportee. From the repository root:
uv sync --project cli
uv run --project cli aportee access 43.25 -79.82 --base http://localhost:4321
uv run --project cli pytest cli
uv run --project cli ruff check cli && uv run --project cli ruff format --check cli
uv run --project cli ty check --project cli
Releases are published to PyPI by .github/workflows/publish-python.yml when a py-v* tag
is pushed; the tag must match version in cli/pyproject.toml.