Security News
GitHub Removes Malicious Pull Requests Targeting Open Source Repositories
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
nordnet-next-api
Advanced tools
Isomorphic JS client for Nordnet nExt API. Client can be used both on the client and server side. Client should be used for making HTTP requests towards nExt API. See nExt API documentation for a list of possible requests.
npm install --save nordnet-next-api
Library can be used on the client and server side.
import api from 'nordnet-next-api';
api
.get('https://api.test.nordnet.se/next/2')
.then(({ status, data }) => console.log(status, data));
var api = require('nordnet-next-api');
var express = require('express');
var app = express();
app.get('/', function (req, res) {
api.get('https://api.test.nordnet.se/next/2')
.then(function(response) {
res.send(response);
})
});
Authentication is required to be able to use nExt API. Authorization
header can be used to pass session token when communicating to the API.
See nExt API documentation for more details on how to get test account and authenticate against nExt API.
api.get(url, params = {}, headers = {})
api.post(url, params = {}, headers = {})
api.postJson(url, params = {}, headers = {})
— api.post
with { 'Content-type': 'application/json;' }
in headersapi.put(url, params = {}, headers = {})
api.del(url, params = {}, headers = {})
Each method returns a Promise, which resolves or rejects with Object { response, data, status }
where
response
, Type Object
, Fetch API Responsedata
, Type Object || String || (undefined if HTTP status === 204)
status
, Type Number
, HTTP status codePromise is rejected when HTTP status code is greater or equal 400.
Required
Type: String
Example:
/api/2/login
/api/2/accounts/{accno}
/api/2/instruments/{instrument_id}?positions={positions}
Note:
interpolated url params are taken from params
argument. If url
contains a key,
which doesn't exist in params
, promise will be rejected with Error
.
Required
Type: Object
Default: {}
Object params
is used to
url
params.headers
contains "Content-type": "application/json"
for constructing request payload
.Required
Type: Object
Default: {}
import api from 'nordnet-next-api';
api
.get('https://api.test.nordnet.se/next/2/accounts/{accno}', { accno: 123456789 })
.then(({ status, data, response }) => console.log(status, data, response));
Returned response contains
status
(HTTP response status)data
(either JSON or plain string depending on Content-type
header)response
(Response interface of Fetch API)import api from 'nordnet-next-api';
api.setConfig({ root: 'https://api.test.nordnet.se/next/2' });
api.get('/accounts/{accno}', { accno: 123456789 })
.then(response => console.log(response));
The following config keys are supported:
root
sets base root URLnTag
set initial nTag valueimport { get } from 'nordnet-next-api';
get('https://api.test.nordnet.se/next/2/accounts/{accno}', { accno: 123456789 })
.then(({ status, data }) => console.log(status, data));
import { get } from 'nordnet-next-api';
get('https://api.test.nordnet.se/next/2/news?days={days}', { days: 0 })
.then(({ status, data }) => console.log(status, data));
import { post } from 'nordnet-next-api';
post('https://api.test.nordnet.se/next/2/user/{key}', { key: 'foo', value: { bar: 'bar' }})
.then(({ status, data }) => console.log(status, data));
import { get } from 'nordnet-next-api';
get('https://api.test.nordnet.se/next/2/markets/{market_id}', { market_id: 11 }, { 'Accept-Language': 'sv' })
.then(({ status, data }) => console.log(status, data));
See tests under src/__tests__
for more examples.
nordnet-next-api is distributed with a two simple example projects.
Before proceeding, install dependencies and build the project:
npm install
npm run build
Run the client side example:
cd examples/client
npm install
npm start
Run the server side example:
cd examples/server
npm install
npm start
This Open Source project released by Nordnet is licensed under the MIT license.
FAQs
Nordnet nExt API Javascript client
The npm package nordnet-next-api receives a total of 11 weekly downloads. As such, nordnet-next-api popularity was classified as not popular.
We found that nordnet-next-api demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 4 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
Security News
Node.js will be enforcing stricter semver-major PR policies a month before major releases to enhance stability and ensure reliable release candidates.