Expand description
§nordnet-model
Pure data types and crypto for the Nordnet External API v2.
Zero I/O dependencies (no reqwest, no tokio, no tokio-rustls). Hosts:
auth— Ed25519 SSH-key login flow primitives plus theauth::Sessionnewtype.models— serde structs for every documented request and response shape, organised per resource group.ids— newtype wrappers for resource identifiers.error::AuthError— error type covering only whatauthcan fail at.
Both nordnet-api (REST client) and
nordnet-feed (streaming client)
depend on this crate for shared wire-typed inputs and outputs. The crate is
I/O-free and may be embedded in non-CLI consumers.
§Install
cargo add nordnet-model§Usage
use nordnet_model::auth::Session;
use nordnet_model::ids::AccountId;
let session = Session {
session_key: "abc123".to_owned(),
expires_in: 3600,
};
let acc = AccountId::from(12345_i64);Sign a login challenge with an OpenSSH-format Ed25519 private key:
use nordnet_model::auth;
let pem = std::fs::read_to_string("/home/me/.ssh/nordnet_ed25519")?;
let signing_key = auth::parse_private_key_openssh(&pem)?;
let signature_b64 = auth::sign_challenge(&signing_key, "challenge-bytes")?;§Type strictness
- Numeric IDs use newtypes — passing an
OrderIdwhere anAccountIdis expected is a compile error. - Money is
Money { amount: Decimal, currency }— neverf64. - Timestamps are
time::OffsetDateTimewith ISO-8601 serde. - Decimal JSON form is bare numbers (
arbitrary_precision), preserved byte-equivalent across roundtrip. - Response structs do not carry
#[serde(deny_unknown_fields)]— undocumented server fields are silently ignored. Request structs keepdeny_unknown_fieldsto catch local bugs in tests.
§License
Dual-licensed under MIT OR Apache-2.0.
Re-exports§
pub use error::AuthError;
Modules§
- auth
- Ed25519 SSH-key login flow per Nordnet’s official External API v2
examples (
nordnet/next-api-v2-examples, Sep 2025) and the “Getting Started” guide at https://www.nordnet.se/externalapi/docs/getting_started. - error
- Errors raised by
crate::auth. - ids
- Newtype wrappers for resource identifiers used by the Nordnet API.
- models