Skip to content

Python SDK

closecity is a typed Python client over the Close API. By default it returns a geopandas.GeoDataFrame where geometry applies (points, isochrones, and block polygons) and a plain pandas.DataFrame otherwise.

Terminal window
pip install closecity
from closecity import Client
# Your API key (ck_live_) is created at https://account.close.city.
close = Client("ck_live_your_key_here")
# Catalog routes are free and come back as data frames.
types = close.destination_types()
# A radius search returns a GeoDataFrame of points, ready to map.
groceries = close.pois_search(lat = 41.82, lon = -71.41, radius_m = 1500)
groceries.plot()

Set output on the client, or per call:

  • output = "spatial" (the default) returns a GeoDataFrame where geometry applies and a DataFrame otherwise.
  • output = "tabular" returns a plain DataFrame for every route and never downloads block boundaries. This is the cheap path when you only want numbers.
  • output = "raw" returns the underlying Reply / Paginator, with .tokens_charged, .etag, and the parsed body on .data.
close.output = "raw"
summary = close.block_summary("440070008001068", mode = "walk")
print(summary.tokens_charged, "charged;", summary.tokens_remaining, "left")

Metering and envelope metadata ride on df.attrs in the frame modes.

The Python SDK documentation has installation notes, a guided tour, worked tutorials, and the complete API reference. The API reference here documents every endpoint and response shape.