R SDK
closecity is an R client over the Close API, built on httr2. It returns
tabular results by default: an sf object where geometry applies (points,
isochrone and block polygons) and a plain data.frame otherwise.
# install.packages("remotes")remotes::install_github("henryspatialanalysis/closecity-r")Quickstart
Section titled “Quickstart”library(closecity)
# Your API key (ck_live_) is created at https://account.close.city.close <- 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 an sf of points, ready to map.groceries <- close$pois_search(lat = 41.82, lon = -71.41, radius_m = 1500)plot(sf::st_geometry(groceries))Choosing an output
Section titled “Choosing an output”Set output on the client, or per call:
output = "spatial"(the default) returns ansfobject where geometry applies and adata.frameotherwise.output = "tabular"returns adata.framefor every route and never downloads block boundaries. This is the cheap path when you only want numbers.output = "raw"returns the underlyingclose_reply, with$tokens_charged,$etag, and the parsed body on$data.
close$output <- "raw"summary <- close$block_summary("440070008001068", mode = "walk")cat(summary$tokens_charged, "charged;", summary$tokens_remaining, "left\n")Read every page of a paginated route with close$records("pois_search", ...).
Metering and envelope metadata are attached as attributes on the returned frame.
Full documentation
Section titled “Full documentation”The R SDK documentation has installation notes, a get-started vignette, worked tutorials, and the complete function reference. The API reference here documents every endpoint and response shape.