enablebanking

Async Rust client for the Enable Banking API, generated from its OpenAPI description. Unofficial.
use enablebanking::types::{Access, Aspsp, AuthorizeSessionRequest, StartAuthorizationRequest};
use enablebanking::{API_URL, Client, Signer};
# include!(concat!(env!("CARGO_MANIFEST_DIR"), "/tests/support/readme_mock.rs"));
# #[tokio::main(flavor = "current_thread")]
# async fn main() -> Result<(), Box<dyn std::error::Error>> {
let key = std::fs::read("tests/fixtures/test-key.pem")?;
let client = Client::new(API_URL, Signer::new(APPLICATION_ID, &key)?);
# let bank = mock_bank().await;
# let client = Client::new(&bank.uri(), Signer::new(APPLICATION_ID, &key)?);
let url = link(&client).await?;
println!("approve access at {url}");
# let code = "redirect code";
transactions(&client, code).await?;
# Ok(())
# }
async fn link(client: &Client) -> Result<String, Box<dyn std::error::Error>> {
let valid_until = jiff::Timestamp::now() + jiff::SignedDuration::from_hours(90 * 24);
let started = client
.start_authorization()
.body(
StartAuthorizationRequest::builder()
.access(Access::builder().valid_until(valid_until))
.aspsp(Aspsp::builder().name("CrediFriuli").country("IT"))
.redirect_url("https://example.com/callback")
.state("any opaque value"),
)
.send()
.await?;
Ok(started.url.to_string())
}
async fn transactions(client: &Client, code: &str) -> Result<(), Box<dyn std::error::Error>> {
let session = client
.authorize_session()
.body(AuthorizeSessionRequest::builder().code(code))
.send()
.await?;
for account in session.accounts.iter().filter_map(|account| account.uid) {
for transaction in client.all_transactions(account, |request| request).await? {
println!(
"{:?} {} {:?}",
transaction.booking_date,
transaction.transaction_amount,
transaction.remittance_information
);
}
}
Ok(())
}
Every endpoint is a method named after the API, with optional parameters as builder calls. Amounts are rust_decimal::Decimal, dates are jiff types, and enumerations keep codes the description does not list as Unknown. Client::new gives up on a request after 15 seconds, so slower banks need a reqwest::Client of your own through Client::new_with_client.
Weekly jobs regenerate the client from Enable Banking's description and check sandbox responses, accepting null for optional fields. Until 1.0, a release that follows a changed description is a new minor version. The release workflow publishes v* tags to crates.io and GitHub using Trusted Publishing (release.yml, environment crates-io), and accepts existing tags through manual dispatch.