Skip to content

Latest commit

 

History

History
123 lines (76 loc) · 6.26 KB

API.md

File metadata and controls

123 lines (76 loc) · 6.26 KB

Table of Contents

Nordnet

Extends EventEmitter

A simple-to-use Node.js wrapper around the Nordnet nExt API.

Parameters

  • config

call

Call one of the API endpoints.

Parameters

  • method string HTTP method to use when calling.
  • endpoint string The endpoint to call.
  • data Object JSON data to send with the request.

Returns (Object | boolean) Returns an object upon success or error, or a simple boolean false if this method is called without the client being authenticated.

authenticate

Authenticate the client and receive a session key. The function also keeps track of when the session key expires and reauthenticates automatically just before it does.

Parameters

  • credentials Object Nordnet nExt API credentials.
    • credentials.username string Nordnet nExt API username
    • credentials.password string Nordnet nExt API password

Returns boolean True if the authentication went OK, false otherwise.

subscribe

Subscribe the public feed to a specific type of events.

Parameters

  • type string The type of events to start listening to.
  • args Object Arguments to pass together with the subscription command.

Returns Promise Resolves when the feed is subscribed.

authenticateFeeds

Authenticate all feeds and start listening for input.

Parameters

  • config Object The configuration object for all feeds.
    • config.FEED_HANDLE Object Configurations for the feed.
      • config.FEED_HANDLE.host string Host address for the feed.
      • config.FEED_HANDLE.port string Port for the feed.

Returns Promise Resolves all authenticated feeds.

authenticateFeed

Authenticate a single feed.

Parameters

  • FEED_HANDLE string
  • config Object Configuration for this feed.
    • config.host string Host address for the feed.
    • config.port string Port for the feed.
  • sessionKey string The session key received at login.

Returns Promise Description

base64

Convert a value to base64.

Parameters

Returns string A base64 encoded version of the value.

formatFeedCommand

Builder to be used when sending commands to the sockets.

Parameters

  • cmd string A valid feed command. One of login, subscribe or unsibscribe.
  • args Object Arguments to pass conjointly with the command.

Returns string A stringified verson of the data, with a line break at the end.

encryptLogin

Base64 encodes the username, password and a timestamp, joins the strings with colons, encrypts the joined string using Nordnet's public RSA key, and finally base64 encodes the encrypted string. Phew.

Parameters

  • username string Your Nordnet nExt username.
  • password string Your Nordnet nExt password.

Returns string The encrypted, base64 encoded authentication string.