Skip to main content

langchain-gridpin — offline geocoding tools for LangChain

LangChain tools that turn addresses into coordinates and coordinates into addresses with GridPin: one memory-mapped file per country ("sheet"), read on your machine. No API key, no rate limit, and no query leaves the machine. The only network step is downloading a sheet once, verified against the signed GridPin release.

Covered countries and sheet sizes: gridpin.dev.

Install

$ pip install langchain-gridpin
$ gridpin-fetch us        # once: downloads and verifies the sheet, prints its path

gridpin-fetch comes with the gridpin-mcp dependency. Sheets go to $GRIDPIN_HOME, else $XDG_CACHE_HOME/gridpin, else ~/.cache/gridpin. From Python:

from langchain_gridpin import download_sheet

download_sheet("us")   # no network when the sheet is already there

Use the tools

from langchain_gridpin import GridPinGeocode, GridPinReverse

geocode = GridPinGeocode(country="us")
geocode.invoke({"query": "1600 Pennsylvania Ave NW, Washington, DC 20500"})
# '{"country": "us", "query": "1600 Pennsylvania Ave NW, Washington, DC 20500",
#   "results": [{"lat": 38.8976751, "lon": -77.036547, "precision": "house", ...}]}'

reverse = GridPinReverse(country="us")
reverse.invoke({"lat": 38.8977, "lon": -77.0365})
# '{"country": "us", "lat": 38.8977, "lon": -77.0365,
#   "results": [{"housenumber": "1600", "street": "PENNSYLVANIA Avenue Northwest", "distance_m": 4.9, ...}]}'

Both tools for one country, for an agent (pip install langchain langchain-anthropic, or any other chat model with tool calling):

from langchain.agents import create_agent
from langchain_gridpin import GridPinToolkit

agent = create_agent("anthropic:claude-sonnet-5-5", tools=GridPinToolkit(country="us").get_tools())
agent.invoke({"messages": [{"role": "user", "content": "Where is 350 5th Ave, New York?"}]})
Tool Arguments Returns
GridPinGeocode (name gridpin_geocode_<country>) query, k (1-10, default 1) ranked candidates with lat, lon, precision, confidence, street, housenumber, commune, postcode
GridPinReverse (name gridpin_reverse_<country>) lat, lon, k (1-10, default 1) nearest indexed addresses, each with distance_m

Constructor parameters of both tools and of GridPinToolkit:

  • country — country code or English name of the sheet, e.g. "us". An unknown country fails at construction and the error lists the available ones.
  • sheet — optional path to a sheet file, instead of the downloaded one.

The tools use response_format="content_and_artifact": called by an agent, the ToolMessage carries the answer as JSON text in content and as a dict in artifact. Called directly with a dict, as above, they return the JSON text. Tools reading the same sheet share one open file.

A missing sheet or an empty query comes back to the model as an error message it can act on (for example "run gridpin-fetch us"); set handle_tool_error=False to get an exception instead. An address that is not found is not an error: results is an empty list.

Results are the same as the GridPin CLI, Python, DuckDB and MCP server return. Treat street or city precision as approximate.

If GridPin is useful to you, a star on GitHub helps other people find it.

License: Apache-2.0.

Metadata

Release files for langchain-gridpin 0.1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for langchain-gridpin 0.1.2
File Size Uploaded Provenance Actions
langchain_gridpin-0.1.2.tar.gz 9.7 kB With provenance Details for langchain_gridpin-0.1.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for langchain-gridpin 0.1.2
File Interpreter ABI Platform Actions
langchain_gridpin-0.1.2-py3-none-any.whl Python 3 none any Details for langchain_gridpin-0.1.2-py3-none-any.whl

Total release size: 20.0 kB

Release files / langchain_gridpin-0.1.2.tar.gz

Download URL langchain_gridpin-0.1.2.tar.gz
Size 9.7 kB
Tags Source
SHA-256 checksum
How to use checksums
d6b9e00d403d48d4953a4d9137d49132775911ca6c35a3ed5981600b7a8773ca
BLAKE2b-256 checksum
How to use checksums
d1b98c5c3f0ea72853c9a0b21e2af26b05f203c3eb5b503c3f50e1bfa5c03b8a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.13

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 2, 2026.

Transparency log

Release files / langchain_gridpin-0.1.2-py3-none-any.whl

Download URL langchain_gridpin-0.1.2-py3-none-any.whl
Size 10.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
30bc466fe3a86050966826115363aeb7cd6b9ad51f00f0b410f8c5cdfbd1e679
BLAKE2b-256 checksum
How to use checksums
ac20ae1da2c0a504e0ca86455f0b497b38037ce6bc9bf5b26be3144b87dd30a8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.13

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 2, 2026.

Transparency log

Security for langchain-gridpin 0.1.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for langchain_gridpin-0.1.2.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 2, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page