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.1

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.1
File Size Uploaded Provenance Actions
langchain_gridpin-0.1.1.tar.gz 9.7 kB With provenance Details for langchain_gridpin-0.1.1.tar.gz

Built distribution (wheel)

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

Total release size: 19.9 kB

Release files / langchain_gridpin-0.1.1.tar.gz

Download URL langchain_gridpin-0.1.1.tar.gz
Size 9.7 kB
Tags Source
SHA-256 checksum
How to use checksums
2b69ce350fd0c48dcc968cc3e30da8a9ada0e1ea5f12852d3e4e1e68509c0699
BLAKE2b-256 checksum
How to use checksums
5a435e793c4a7d16aa5db789044c8ac22bc79158cd00b2f6f91170a587a290ef
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 Oct 31, 2026.

Transparency log

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

Download URL langchain_gridpin-0.1.1-py3-none-any.whl
Size 10.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9c7223d2d26cf5a1878cb2a6dc4671b5991e5e6423bb958d94421ce04e7282e7
BLAKE2b-256 checksum
How to use checksums
5bb67ea8adad25aabcb7212134a38cbcd742aafe29f8ed89828427e57456e99c
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 Oct 31, 2026.

Transparency log

Security for langchain-gridpin 0.1.1

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.1.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 Oct 31, 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