npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

node-sbanken

v2.9.5

Published

A module wrapping the Sbanken REST APIs, and a command line tool to do banking from the terminal.

Downloads

22

Readme

SBanken API Wrapper (SDK) and a command line tool

npm version

API Wrapper (SDK)

This is intended as a simple object oriented wrapper for the Sbanken banking REST API's. It removes the hassle of implementing the rest calls directly. It provides a fairly straight forward promise and async/await based library. All functions will return a promise that can be processed further.

The module supports typescript and has all types from the SBanken API included.

Installing

If you use npm

npm install node-sbanken --save

If you use yarn

yarn add node-sbanken

If you want to use command line tool globally

npm install -g node-sbanken

Using the library

To use the library you first of all need to sign up for beta bank features at Sbanken: Utviklerportalen

Javascript

const Sbanken = require('./node-sbanken');

const credentials = {
  clientId: 'real clientid removed',
  secret: 'real secret removed',
  customerId: 'real customerId removed',
};

const sbanken = new Sbanken(credentials);

// Promise syntax
sbanken.accounts().then((data) => {
  // Do something with the account data
  console.table(data.items);
});

// async/await syntax
(async () => {
  const data = await sbanken.accounts();
  console.table(data.items);
})();

Typescript

import * as sb from './node-sbanken';

const credentials: sb.Credentials = {
  clientId: 'real clientid removed',
  secret: 'real secret removed',
  customerId: 'real customerid removed',
};

const client = new sb.Sbanken(credentials);

async function getAccounts(sbanken: sb.Sbanken): sb.AccountListResult {
  return await sbanken.accounts():
}

const data: sb.AccountListResult = getAccounts(client);
console.table(data.items);

Command line tool

The module also contains a fairly complete command line client for doing simple banking operations. It can

  • List your accounts and filter by name (case insensitive regex)
  • List transactions for an account by name
  • Transfer funds between your accounts

Usage

Help text

$ sbanken
Usage: sbanken [options][command]

A module wrapping the Sbanken APIs, and a command line tool to do banking with sbanken.

Options:
  -V, --version output the version number
  -v, --verbose Tell the program to be verbose
  -h, --help output usage information

Commands:
  accounts List all accounts
  account|ac [name] List accounts with a given name
  customers|cu [options] Fetch the customers associated with the current userId.
  transactions|tr [options] <name> Fetch the transactions for the account with name.
  transfer [options] <amount> Transfer money between two accounts.

Listing account information

$ sbanken ac --help
Usage: account|ac [options] [name]

List accounts with a given name

Options:
  -h, --help  output usage information

Listing transactions

$ sbanken tr --help
Usage: transactions|tr [options] <name>

Print out transactions for the account matching the provided name.

Options:
  -f --from <yyyy-mm-dd>  From date
  -t --to <yyyy-mm-dd>    To date
  -h, --help              output usage information

Security

The command line tool expects you to provide the credentials through the following environment variables:

  • SBANKEN_SECRET
  • SBANKEN_CLIENTID
  • SBANKEN_CUSTOMERID
SBANKEN_CLIENTID="add clientid" SBANKEN_SECRET="add secret" SBANKEN_CUSTOMERID="add userid" npx sbanken

To use the SDK you need to provide the credentials to the constructor.

By making the credentials accessible through code or in your terminal you expose yourself to the risk of a third party getting hold of your banking details. Only use the library or tool if you understand the risk and how to deal with them properly.