Return a list of zip codes within a search radius of another zip code.
  • Go 92.2%
  • Dockerfile 7.8%
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
2026-09-30 21:03:12 -04:00
.env.example Standardize the naming of things 2026-09-30 18:00:07 -04:00
.gitignore Add gitignore to ignore db and env 2026-09-29 16:17:59 -04:00
compose.yml Add docker items 2026-09-30 18:04:33 -04:00
conv.go Move unit conversions out of the handler 2026-09-30 18:02:30 -04:00
db.go Initial commit 2026-09-29 15:27:40 -04:00
Dockerfile Add docker items 2026-09-30 18:04:33 -04:00
go.mod Apply formatting and rename module 2026-09-29 17:11:38 -04:00
go.sum Initial commit 2026-09-29 15:27:40 -04:00
handler.go Allow unabbreviated units 2026-09-30 21:03:12 -04:00
main.go Standardize the naming of things 2026-09-30 18:00:07 -04:00
middleware.go Match things to the api we were modeling this after 2026-09-30 18:01:31 -04:00
README.md Match things to the api we were modeling this after 2026-09-30 18:01:31 -04:00

Introduction

zipcode_search is a very simple application (bootstrapped via prompt to DeepSeek v4 Pro 0813).

It provides an alternative implementation modeled after the '/radius' enpoint of the API documented at: https://app.zipcodebase.com/documentation

For example:

https://{your domain}/api/v1/radius?apikey=YOUR-APIKEY&code=02134&radius=1&country=us

Note the following potential differences:

  • country is ignored
  • only a single source zipcode may be specified
  • unit is supported (km|mi), default mi
  • apikey is supported as a query string, but if provided in a header (X-API-Key) it will be preferred.

Example usage

$ go mod download
$ export API_KEY=secret DUCKDB_PATH=zipsearch.duckdb
$ go run .
$ # Query within 10 miles:
$ curl -H "X-API-Key: secret" \
  "http://localhost:8080/api/v1/radius?code=10001&radius=10&unit=mi"

Database sources

https://www.nber.org/research/data/zip-code-distance-database

Using duckdb cli, you can load the database as follows (using the 50 mile db):

$ duckdb zipsearch.duckdb
zipsearch D create table zip_distance (zip1 varchar, zip2 varchar, distance float);
zipsearch D insert into zip_distance (zip1, zip2, distance) select zip1, zip2, miles_to_zcta5 from 'gaz2024zcta5distance50miles.csv';
zipsearch D .exit