Skip to main content

Modern Python Client for Radar.io Geocoding API

Release Notes Downloads GitHub CI Status License: MIT

A Python client for the Radar.io geocoding, mapping, and geolocation APIs.

Why This Library?

Radar's official Python SDK hasn't been updated in several years and doesn't include support for newer API endpoints.

I built this to solve a practical problem: I needed a way to interact with Radar's geocoding APIs with type hints and support for their current endpoints. This library provides that.

Installation

uv add radar-mapping-api

For optional Sentry integration:

uv add radar-mapping-api[sentry]

Usage

Basic Setup

from radar_mapping_api import RadarClient

client = RadarClient(api_key="your_radar_api_key")

Forward Geocoding

Convert an address to coordinates:

result = client.forward_geocode(
    query="841 Broadway, New York, NY",
    country="US"
)

if result.addresses:
    address = result.addresses[0]
    print(f"Latitude: {address.latitude}")
    print(f"Longitude: {address.longitude}")
    print(f"Formatted: {address.formattedAddress}")

Reverse Geocoding

Convert coordinates to an address:

result = client.reverse_geocode(
    coordinates="40.7128,-74.0060",
    layers="postalCode,locality,state"
)

if result.addresses:
    address = result.addresses[0]
    print(f"City: {address.city}")
    print(f"State: {address.stateCode}")
    print(f"Postal Code: {address.postalCode}")

Search for places near a location:

result = client.search_places(
    near="40.7128,-74.0060",
    categories="coffee-shop",
    radius=1000,
    limit=10
)

for place in result.places:
    print(f"{place.name} - {', '.join(place.categories)}")

Address Autocomplete

Get autocomplete suggestions for partial addresses:

result = client.autocomplete(
    query="841 Broad",
    country_code="US",
    limit=5
)

for address in result.addresses:
    print(address.formattedAddress)

Address Validation

Validate and normalize a structured address:

result = client.validate_address(
    address_label="841 Broadway",
    city="New York",
    state_code="NY",
    postal_code="10003",
    country_code="US"
)

if result.address:
    print(f"Validated: {result.address.formattedAddress}")

Helper Functions

The library includes helper functions for common operations:

from radar_mapping_api import geocode_postal_code, geocode_coordinates

# Geocode a postal code
result = geocode_postal_code(
    client,
    postal_code="10007",
    country="US"
)

if result:
    print(f"Coordinates: {result.lat}, {result.lon}")
    print(f"City: {result.city}")

# Reverse geocode coordinates
result = geocode_coordinates(
    client,
    lat=40.7128,
    lon=-74.0060
)

if result:
    print(f"Postal Code: {result.postal_code}")
    print(f"State: {result.state_code}")

Features

  • Type-safe with Pydantic models
  • Automatic retry logic with exponential backoff (up to 6 attempts)
  • Does not retry on HTTP 402 (payment required) errors
  • Optional Sentry integration for logging warnings
  • Uses httpx for async-capable HTTP requests
  • Comprehensive test suite

Error Handling

The client includes retry logic for failed requests:

import httpx

try:
    result = client.forward_geocode(query="invalid address")
except httpx.HTTPError as e:
    print(f"Request failed: {e}")

API Reference

RadarClient Methods

  • forward_geocode(query, layers=None, country=None, lang=None) - Convert address to coordinates
  • reverse_geocode(coordinates, layers=None, lang=None) - Convert coordinates to address
  • search_places(near=None, chains=None, categories=None, iata_code=None, ...) - Search for places
  • autocomplete(query, near=None, layers=None, limit=None, ...) - Autocomplete addresses
  • validate_address(address_label, city=None, state_code=None, ...) - Validate addresses

Models

All API responses are returned as Pydantic models:

  • GeocodeResponse - Forward/reverse geocoding response
  • SearchPlacesResponse - Place search response
  • ValidateAddressResponse - Address validation response
  • GeocodeResult - Simplified geocoding result
  • Address - Address information
  • Place - Place information

Development

# Install with development dependencies
uv sync

# Run tests
uv run pytest

# Run linting
uv run ruff check

# Type checking
uv run pyright

License

See LICENSE file for details.


This project was created from iloveitaly/python-package-template

Metadata

Release files for radar-mapping-api 0.2.0

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

Source distribution (sdist)

Source distribution for radar-mapping-api 0.2.0
File Size Uploaded Provenance
radar_mapping_api-0.2.0.tar.gz 7.5 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for radar-mapping-api 0.2.0
File Interpreter ABI Platform
radar_mapping_api-0.2.0-py3-none-any.whl Python 3 none any Details

Total release size: 16.7 kB

Release files / radar_mapping_api-0.2.0.tar.gz

Download URL radar_mapping_api-0.2.0.tar.gz
Size 7.5 kB
Tags Source
SHA-256 checksum
How to use checksums
9d4d422d7c650557d4bef9fb33ecf9e6d3d71ee5e5badee8fb197d008db66000
BLAKE2b-256 checksum
How to use checksums
73c2c0acbdef714dbe5339a1520222181018357e7b216630b12b26a7fa4a28ab
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.10.2 {"installer":{"name":"uv","version":"0.10.2","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / radar_mapping_api-0.2.0-py3-none-any.whl

Download URL radar_mapping_api-0.2.0-py3-none-any.whl
Size 9.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
775024068f4ea224eb8ddddeb3d85585ac619ecc0a0561c7e21f7bd928187879
BLAKE2b-256 checksum
How to use checksums
67824350f84accaa5404809bb9584a9def42f0fb9c0f797a92e1ced6aade612b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.10.2 {"installer":{"name":"uv","version":"0.10.2","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Security for radar-mapping-api 0.2.0

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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

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.

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 release files No provenance

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