qrz-logbook-api
A comprehensive, type-safe Rust client library for the QRZ Logbook API. This library provides an easy-to-use interface for amateur radio operators to interact with their QRZ logbooks programmatically.
Features
- Complete API Coverage: All QRZ Logbook API endpoints supported
- Insert QSO records
- Delete QSO records
- Fetch QSO records with advanced filtering
- Get logbook status and statistics
- Type Safety: Comprehensive error handling and type-safe operations
- ADIF Support: Full ADIF (Amateur Data Interchange Format) parsing and generation
- Async/Await: Built with modern async Rust using
tokioandreqwest - Automatic Paging: Built-in support for fetching large logbooks efficiently
- Builder Pattern: Intuitive QSO record creation with builder pattern
- Comprehensive Documentation: Extensive docs with examples
Requirements
- A valid QRZ.com account
- QRZ Logbook API access key (available from your QRZ account page)
- Note: Some operations require a QRZ subscription
Installation
Add this to your Cargo.toml:
[]
= "0.1"
= { = "1.0", = ["macros", "rt-multi-thread"] }
= "0.4"
Quick Start
use ;
use ;
async
API Operations
Insert QSO Records
use ;
use ;
let qso = builder
.call
.station_callsign
.date
.time_on
.time_off // Optional
.band
.mode
.freq
.rst_sent
.rst_rcvd
.additional_field // Custom ADIF fields
.build;
// Insert without replacing duplicates
let result = client.insert_qso.await?;
// Insert and replace any existing duplicates
let result = client.insert_qso.await?;
Fetch QSO Records
use FetchOptions;
use NaiveDate;
// Fetch all QSOs (with automatic paging)
let all_qsos = client.fetch_all_qsos.await?;
// Fetch specific QSOs with filtering
let filtered_qsos = client.fetch_qsos.await?;
// Paging through large result sets
let mut after_logid = 0;
loop
Delete QSO Records
// Delete specific QSOs by logid
let result = client.delete_qsos.await?;
println!;
if !result.not_found_logids.is_empty
Get Logbook Status
let status = client.get_status.await?;
for in &status.data
// Example output:
// total_qsos: 1234
// confirmed: 567
// dxcc_total: 89
// start_date: 2020-01-01
// end_date: 2030-12-31
Advanced Usage
Working with ADIF Data
use AdifParser;
// Parse ADIF from string
let adif_string = "<call:4>W1AW<band:3>20m<mode:3>SSB<qso_date:8>20240115<time_on:4>1430<station_callsign:5>K1ABC<eor>";
let qsos = parse_adif?;
// Generate ADIF from QSO record
let qso = builder
.call
.station_callsign
// ... other fields
.build;
let adif = to_adif;
Error Handling
use ;
match client.insert_qso.await
Custom ADIF Fields
let qso = builder
.call
.station_callsign
// ... required fields ...
.additional_field
.additional_field
.additional_field
.additional_field
.build;
Configuration
User Agent Requirements
The QRZ API requires an identifiable user agent. For personal scripts, include your callsign:
// Good examples:
let client = new?;
let client = new?;
// Bad examples (will be rejected):
let client = new?; // ❌
let client = new?; // ❌
TLS Configuration
By default, the library uses rustls. To use the system's native TLS:
[]
= { = "0.1", = false, = ["native-tls"] }
Error Types
QrzLogbookError::Http: Network and HTTP errorsQrzLogbookError::Api: API-specific errors (invalid data, etc.)QrzLogbookError::Auth: Authentication failuresQrzLogbookError::InvalidKey: Invalid API key formatQrzLogbookError::InvalidUserAgent: Invalid user agent stringQrzLogbookError::AdifParse: ADIF parsing errorsQrzLogbookError::InvalidParams: Invalid parameter combinations
Testing
Run the test suite:
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.
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Add tests for your changes
- Ensure all tests pass (
cargo test) - Commit your changes (
git commit -am 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
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.
Acknowledgments
- QRZ.com for providing the logbook API
- The amateur radio community for ADIF standardization
Disclaimer
This library is not officially associated with QRZ.com. QRZ is a trademark of QRZ LLC. Please respect QRZ's terms of service and API usage guidelines.
For support with the QRZ Logbook API itself, please contact QRZ.com directly.