Rust client for the Sequence Platform API —
typed models, auto-pagination, client-side rate limiting, and retries with Retry-After.
Unofficial. A community project, not affiliated with or endorsed by Sequence.
[dependencies]
sequence-rs = { git = "https://github.com/myst3k/sequence-rs" }Requires a Tokio runtime and a recent stable Rust (uses async fn in traits, Rust ≥ 1.75).
cp .env.example .env # add your SEQUENCE_API_KEY
cargo run --example playground --features env-fileThe optional env-file feature loads a local .env into the environment (via dotenvy)
before Credentials::from_env() reads SEQUENCE_API_KEY. Without it, the real process
environment is used.
use sequence_rs::prelude::*;
use sequence_rs::{Credentials, ListAccountsParams, Sequence};
use futures::TryStreamExt;
let client = Sequence::new(Credentials::from_env().expect("SEQUENCE_API_KEY"));
let page = client.accounts(&ListAccountsParams::default()).await?; // one page
let all: Vec<_> = client.accounts_stream(&ListAccountsParams::default()) // every page, lazily
.try_collect().await?;Auth is a bearer token from SEQUENCE_API_KEY; permissions are the ApiKeyAuth scheme in
the API docs.
| Method | Endpoint | Returns |
|---|---|---|
accounts / accounts_stream |
GET /accounts |
AccountSummary |
account |
GET /accounts/{id} |
full Account |
account_transfers / account_transfers_stream |
GET /accounts/{id}/transfers |
Transfer |
rules / rules_stream |
GET /rules |
RuleSummary |
rule |
GET /rules/{id} |
full Rule |
trigger_rule |
POST /rules/{id}/trigger |
TriggerRuleResponse |
rule_executions / rule_executions_stream |
GET /rules/{id}/executions |
RuleExecutionSummary |
rule_execution |
GET /rules/{id}/executions/{id} |
full RuleExecution |
create_transfer |
POST /transfers |
Transfer |
transfer |
GET /transfers/{id} |
Transfer |
card_transactions / card_transactions_stream |
GET /card-transactions |
Transaction |
external_transactions / external_transactions_stream |
GET /external-transactions |
ExternalTransaction |
audit_logs / audit_logs_stream |
GET /audit-logs |
AuditLogEntry |
- Envelopes are unwrapped automatically; error bodies become
ClientError::Api, anything elseClientError::Http. - Idempotency —
trigger_rule/create_transfertakeOption<&str>; a supplied key rides every retry (24h server dedup). WithNonethe client auto-generates a one-off key for the call so its own retries can't double-apply — but that doesn't dedupe across separate calls, so pass your own stable key to make repeated calls retry-safe. - Rate limiting — token bucket, default 100 req/min (the server ceiling), burstable;
Config.rate_limit = Nonedisables. - Retries —
429/5xx/network blips with full-jitter backoff honouringRetry-After, bounded bymax_attemptsand an optionalmax_elapsed_timedeadline;Config::default().no_retries()turns them off. - Validation —
create_transferenforces the spec's input rules before sending. - Simulation —
trigger_ruletakessimulation: Some(true)for a dry run (no money moved); list executions byexecution_mode(LIVE/SIMULATION/ALL), and eachRuleExecutioncarries itsexecution_mode. - Pagination — the API has no
total, so*_streamstops on a short page.
use sequence_rs::{Config, Credentials, RateLimit, Sequence};
let client = Sequence::with_config(
Credentials::from_env().unwrap(),
Config {
called_reason: Some("my-service/nightly-sweep".into()), // x-called-reason
rate_limit: Some(RateLimit { requests_per_minute: 60 }),
..Default::default()
},
);Point api_base_url at the spec's dev/staging servers for non-prod testing.
Crates: sequence-rs (client, config, streams) · sequence-rs-http (reqwest wrapper, retries,
rate limiting) · sequence-rs-model (request/response types).
Fetch the spec (gitignored) with python3 scripts/fetch_openapi.py. To add an endpoint: extend
the model, add the BaseClient method, and cover it with a roundtrip + wiremock test. See
IMPLEMENTATION_PLAN.md for design notes.
Dual-licensed under MIT or Apache-2.0, at your option.