Skip to main content

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

Project description

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.

[!CAUTION] Pricing Alert for Startups: Radar offers a free tier, but pricing jumps from free to $20,000/year with no incremental options in between, even when working with their startup sales team. If you're building something that will scale beyond the free tier limits, consider whether this pricing structure fits your growth trajectory.

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}")

Place Search

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

Links

License

See LICENSE file for details.


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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

radar_mapping_api-0.2.0.tar.gz (7.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

radar_mapping_api-0.2.0-py3-none-any.whl (9.2 kB view details)

Uploaded Python 3

File details

Details for the file radar_mapping_api-0.2.0.tar.gz.

File metadata

  • Download URL: radar_mapping_api-0.2.0.tar.gz
  • Upload date:
  • Size: 7.5 kB
  • Tags: Source
  • Uploaded using 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}

File hashes

Hashes for radar_mapping_api-0.2.0.tar.gz
Algorithm Hash digest
SHA256 9d4d422d7c650557d4bef9fb33ecf9e6d3d71ee5e5badee8fb197d008db66000
MD5 c86d31ac8cedd3eae71c097c74af48d5
BLAKE2b-256 73c2c0acbdef714dbe5339a1520222181018357e7b216630b12b26a7fa4a28ab

See more details on using hashes here.

File details

Details for the file radar_mapping_api-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: radar_mapping_api-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 9.2 kB
  • Tags: Python 3
  • Uploaded using 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}

File hashes

Hashes for radar_mapping_api-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 775024068f4ea224eb8ddddeb3d85585ac619ecc0a0561c7e21f7bd928187879
MD5 8da7ac3e7dd5f9ef7864074634ddf032
BLAKE2b-256 67824350f84accaa5404809bb9584a9def42f0fb9c0f797a92e1ced6aade612b

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page