qrz-xml
A safe, async Rust client library for the QRZ.com XML API.
Installation
Add this to your Cargo.toml:
[]
= "0.1"
= { = "1.0", = ["full"] }
Example Usage
use ;
async
Authentication
You need a valid QRZ.com username and password. While any QRZ user can authenticate, most features require an active QRZ Logbook Data subscription.
Visit QRZ.com subscriptions for more information about subscription plans.
API Coverage
Callsign Lookups
let callsign_info = client.lookup_callsign.await?;
// Access comprehensive information
println!;
println!;
println!;
// Geographic coordinates
if let Some = callsign_info.coordinates
// QSL preferences
if callsign_info.accepts_eqsl == Some
DXCC Entity Lookups
// Look up by entity number
let usa = client.lookup_dxcc_entity.await?;
println!;
// Look up by callsign prefix
let dxcc = client.lookup_dxcc_by_callsign.await?;
println!;
Biography Data
let bio = client.lookup_biography.await?;
println!;
// The biography contains raw HTML as it appears on QRZ.com
if !bio.is_empty
Error Handling
The library provides comprehensive error handling with specific error types:
use QrzXmlError;
match client.lookup_callsign.await
Configuration
Customize the client behavior with QrzXmlClientConfig:
use ;
use QrzXmlClientConfig
let config = QrzXmlClientConfig ;
let client = with_config?;
API Versions
QRZ.com provides a versioned XML interface. You can specify which version to use:
// Use the latest version (recommended)
let client = new?;
// Use a specific version
let client = new?;
// Use legacy version (1.24)
let client = new?;
Session Management
The client automatically handles session management:
- Automatic Login: Sessions are established automatically on first request
- Session Caching: Session keys are cached and reused efficiently
- Auto Re-authentication: Expired sessions are detected and renewed automatically
- Session Info: Access lookup counts and subscription status
// Check authentication status
if client.is_authenticated.await
// Get session information
if let Some = client.session_info.await
// Force re-authentication if needed
client.reauthenticate.await?;
Rate Limiting
The library respects QRZ.com's usage guidelines:
- Session keys are cached and reused to minimize server load
- Failed requests are not automatically retried (except for session expiration)
- The library tracks lookup counts returned by the API
You should implement your own rate limiting if making many requests:
use ;
for callsign in callsigns
Examples
The crate includes several examples in the examples/ directory:
# Basic callsign lookup
QRZ_USERNAME=xxx QRZ_PASSWORD=yyy
# DXCC entity lookup
QRZ_USERNAME=xxx QRZ_PASSWORD=yyy
Testing
Run the test suite:
The tests include both unit tests and integration tests with mocked API responses, so they don't require QRZ.com credentials.
TLS Support
The library supports both native TLS and rustls:
# Use native TLS (default)
= "0.1"
# Use rustls instead
= { = "0.1", = false, = ["rustls-tls"] }
Contributing
Contributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.
License
This project is licensed under either of
- Apache License, Version 2.0, (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.
Disclaimer
This library is not affiliated with or endorsed by QRZ.com. QRZ.com is a trademark of QRZ LLC.
Users of this library must comply with QRZ.com's Terms of Service and API usage guidelines.