Skip to main content

Crate nordnet_api

Crate nordnet_api 

Source
Expand description

§nordnet-api

crates.io docs.rs License

Typed REST bindings for the Nordnet External API v2.

HTTP-shaped surface only. Wire-typed inputs/outputs (request and response structs, ID newtypes, the Ed25519 login primitives) live in the sibling nordnet-model crate; this crate composes them with reqwest-backed HTTP plumbing.

Covers the full non-deprecated REST surface (~42 operations across 12 resource groups). Every operation has a wiremock integration test in-tree.

§Install

cargo add nordnet-api

§Usage

use nordnet_api::Client;
use nordnet_api::resources::accounts::ListAccountsQuery;
use nordnet_model::auth::Session;

let client = Client::new("https://public.nordnet.se/api/2")?
    .with_session(Session {
        session_key: std::env::var("NORDNET_SESSION_KEY").unwrap(),
        expires_in: 3600,
    });

let accounts = client.list_accounts(ListAccountsQuery::default()).await?;
for a in accounts {
    println!("{:?}", a);
}

Authentication is the v2 SSH-key flow: POST /login/start returns a challenge, the caller signs the raw UTF-8 bytes with an Ed25519 key, and POST /login/verify returns a session_key. The login primitives live in nordnet-model::auth.

§Resource groups

Each group is a module under resources; every operation hangs off Client and carries a #[doc(alias = "METHOD /path")] so rustdoc search resolves raw HTTP paths.

GroupOpsCoverage
accounts6accounts, info, ledgers, positions, returns, trades
countries2list + lookup by ISO code
instrument_search6attributes + stock/bullbear/minifuture/turbo/option searches
instruments9lookup, types, underlyings, leverages, suitability, trades
login4start, verify, refresh, logout
main_search1unified instruments/news/CMS search
markets2list + lookup by ID
news2article fetch + sources
orders5list, place, modify, activate, cancel
root1system status
tick_sizes2list + lookup by ID
tradables3info, trades, suitability

§Companion crates

§License

Dual-licensed under MIT OR Apache-2.0.

Re-exports§

pub use client::Client;
pub use error::Error;

Modules§

client
HTTP client for the Nordnet External API.
error
Error type for the Nordnet API client.
pagination
Offset/limit pagination helpers.
resources