| Crates.io | zipcodestack |
| lib.rs | zipcodestack |
| version | 0.1.2 |
| created_at | 2025-09-30 11:31:43.422156+00 |
| updated_at | 2025-10-02 09:14:03.421188+00 |
| description | Idiomatic Rust client for the zipcodestack.com API (status, search, distance) |
| homepage | https://zipcodestack.com/ |
| repository | https://github.com/everapihq/zipcodestack-rs |
| max_upload_size | |
| id | 1860993 |
| size | 64,767 |
Idiomatic Rust client for the zipcodestack.com API. Website: zipcodestack
Add to your Cargo.toml:
[dependencies]
zipcodestack = { path = "." }
tokio = { version = "1", features = ["full"] }
use zipcodestack::{ZipCodeStackClient, AuthMethod, DistanceUnit};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = ZipCodeStackClient::builder("YOUR_API_KEY")
.with_auth_method(AuthMethod::Header)
.build();
// API Status
let status = client.status().await?;
println!("API up? {:?}", status.up);
// Search zip code
let info = client.search_zip("90210", Some("US")).await?;
println!("{} {:?} {:?}", info.zip_code.unwrap_or_default(), info.city, info.state_code);
// Distance
let d = client.distance_between("90210", "10001", Some(DistanceUnit::Miles)).await?;
println!("Distance (mi): {:?}", d.distance_miles);
Ok(())
}
According to the official docs, you can authenticate via HTTP headers or GET parameters. This client supports both:
apikey: <API_KEY> (default)?apikey=<API_KEY>You can switch using the builder:
let client = ZipCodeStackClient::builder("YOUR_API_KEY")
.with_auth_method(AuthMethod::QueryParam)
.build();
GET /statusGET /search?zip_code=90210&country=USGET /distance?from=90210&to=10001&unit=milesMIT