28 releases
Uses new Rust 2024
| 0.2.0-alpha.3 | Sep 23, 2025 |
|---|---|
| 0.1.0 | Sep 20, 2025 |
| 0.1.0-alpha.15 | Jul 20, 2025 |
| 0.1.0-alpha.7 | Mar 27, 2025 |
| 0.0.1-alpha.2 | Jul 29, 2021 |
#48 in Finance
629 downloads per month
1MB
5K
SLoC
xero-rs
Description
A Xero API client library for Rust. This library is in very early days and the API is not stable, it may change without notice.
This was put together as part of the requirements for a private project so I will be implementing features as-needed, but all contributions are welcome.
Features
- Client credential & code flow authorization support
- Generic GET, PUT, and POST methods for custom requests
- Type-safe API endpoint construction via
XeroEndpointenum - Uses rust_decimal for storing prices/decimal values
- Rich error diagnostics via miette integration
- Well tested (that's the goal, at least)
Error Handling
xero-rs uses miette for rich error diagnostics. The Error type implements the Diagnostic trait, which means you get detailed error reports with context and help text.
// Example of handling errors with miette
use xero_rs::error::Result;
fn do_something() -> Result<()> {
// If this fails, you'll get a rich diagnostic error
let client = xero_rs::Client::from_client_credentials(...)?;
// No need to call .into_diagnostic() when using xero_rs::error::Result
Ok(())
}
When using with miette's own Result type, you'll need to use .into_diagnostic():
use miette::{Result, IntoDiagnostic};
fn do_something() -> Result<()> {
// Converting to miette's Result requires .into_diagnostic()
let client = xero_rs::Client::from_client_credentials(...).into_diagnostic()?;
Ok(())
}
Currently Implemented
This has been implemented so far:
- OAuth2 Authentication (Client Credentials, Authorization Code Flow)
- Type-safe API URL construction with
XeroEndpoint - List authorized connections (tennants)
- Quotes
- List
- Get by ID
- Invoices
- List
- Get by ID
- Purchase Orders
- List
- Get by ID
- Create
- Contacts
- List
- Items
- List (with filtering)
- Get by ID
- Create
- Update
- Delete
- Update or create
- History records
Dependencies
~12–27MB
~334K SLoC