Expand description
Idiomatic Rust client for the zipcodestack.com API.
This crate provides a small, async wrapper around the public API at https://zipcodestack.com/. It includes helpers for API status, zip code search, and computing distances between two zip codes.
The client supports authenticating either via apikey: <API_KEY> header
or by passing the API key as an apikey query parameter, to match the docs’ guidance
that authentication can be done using headers or GET parameters.
Example:
use zipcodestack::{ZipCodeStackClient, AuthMethod, DistanceUnit};
let client = ZipCodeStackClient::builder("YOUR_API_KEY")
.with_auth_method(AuthMethod::Header)
.build();
let status = client.status().await?;
println!("API up? {}", status.up.unwrap_or(true));
let search = client.search_zip("90210", Some("US")).await?;
println!("Found: {} {}", search.city.unwrap_or_default(), search.state_code.unwrap_or_default());
let distance = client.distance_between("90210", "10001", Some(DistanceUnit::Miles)).await?;
println!("Distance (mi): {}", distance.distance_miles.unwrap_or_default());Structs§
- ApiError
Payload - API error payload (if server returns structured error).
- Distance
Response - Distance response between two zip codes.
- Quota
- Quota details for the authenticated account.
- Status
Response - API status and quota usage response.
- ZipCode
Stack Client - Async client for the zipcodestack.com API.
- ZipCode
Stack Client Builder - Builder to configure a
ZipCodeStackClient. - ZipSearch
Response - Zip code search response.
Enums§
- Auth
Method - Strategy for authenticating requests.
- Distance
Unit - Unit for distance calculations.
- ZipCode
Stack Error - Error type for this crate.