An open API service indexing awesome lists of open source software.

https://github.com/assafmo/ordernetapi

Query spark{nesua,meitav,psagot}.ordernet.co.il
https://github.com/assafmo/ordernetapi

cli command-line command-line-tool stock-data stock-market

Last synced: 8 months ago
JSON representation

Query spark{nesua,meitav,psagot}.ordernet.co.il

Awesome Lists containing this project

README

          

# OrdernetAPI

A simple tool for querying `https://spark{nesua,meitav,psagot}.ordernet.co.il/api`.
Right now only returns total balance for each account.

[![npm version](https://badge.fury.io/js/ordernet-api.svg)](https://badge.fury.io/js/ordernet-api)

# CLI

```bash
npm install -g ordernet-api
```

## Options

```console
$ ordernet-api -h
Options:
-u, --user, --username Username for login into Spark. [string] [required]
-p, --pass, --password Password for login into Spark. [string] [required]
-b, --broker Broker name.
[string] [required] [choices: "nesua", "meitav", "psagot"]
-a, --account-key Print balance only for these account keys. This is
usually much faster. An account key has the form
"ACC_XXX-YYYYYY". You can find it out using the
--verbose flag. [array]
-v, --verbose Print log messages [boolean]
-h, --help Show help [boolean]
-V, --version Show version number [boolean]

Examples:
cli.js -u 1234 -p abcd -b nesua Print the balance for each account
associated with this Spark user.
cli.js -u 1234 -p abcd -a ACC_000-111111 Print the balance only for the
-b nesua account key ACC_000-111111.
cli.js -u 1234 -p abcd -a ACC_000-111111 Print the balance only for the
-a ACC_000-222222 -b nesua account keys ACC_000-111111 and
ACC_000-222222.

For more info visit https://github.com/assafmo/OrdernetAPI
```

# Library API

```bash
npm install ordernet-api
```

or

```bash
yarn add ordernet-api
```

## Constants



config : Config


The internal config object.



## Functions



authenticate(username, password, broker)Void


Authenticate against the Spark system of the broker. This function must be called first as it initializes the apiUrl and authorization fields in the internal config. That way we won't need to authenticate again for each API call. Uses /api/Auth/Authenticate.




getAccounts()Array.<Account>


Get all the accounts listed under this Spark user. Uses /api/DataProvider/GetStaticData.




getAccountBalance(account)number


Get total balance of an account. Uses /api/Account/GetAccountSecurities.




accountKeyToNumber(key)string


Convert account key to account number.



## Typedefs



Config : Object



Account : Object


## config : [Config](#Config)

The internal config object.

**Kind**: global constant

## authenticate(username, password, broker) ⇒ Void

Authenticate against the Spark system of the broker. This function must be called first as it initializes the `apiUrl` and `authorization` fields in the internal config. That way we won't need to authenticate again for each API call. Uses `/api/Auth/Authenticate`.

**Kind**: global function

| Param | Type | Description |
| -------- | ------------------- | ---------------------------------------------------------------------------------------------------------------- |
| username | string | The Spark username |
| password | string | The Spark password |
| broker | string | Used to get the API URL like this: `https://spark${broker}.ordernet.co.il/api`. E.g. `nesua`, `meitav`, `psagot` |

## getAccounts() ⇒ [Array.<Account>](#Account)

Get all the accounts listed under this Spark user. Uses `/api/DataProvider/GetStaticData`.

**Kind**: global function
**Returns**: [Array.<Account>](#Account) - - All accounts listed under this Spark user

## getAccountBalance(account) ⇒ number

Get total balance of an account. Uses `/api/Account/GetAccountSecurities`.

**Kind**: global function
**Returns**: number - - Total balance of the account

| Param | Type | Description |
| ------- | -------------------------------- | -------------------------- |
| account | [Account](#Account) | Account to get balance for |

## accountKeyToNumber(key) ⇒ string

Convert account key to account number.

**Kind**: global function
**Returns**: string - - The account number

| Param | Type | Description |
| ----- | ------------------- | ------------------------------------------------ |
| key | string | The account key for API usage (`ACC_XXX-YYYYYY`) |

## Config : Object

**Kind**: global typedef
**Properties**

| Name | Type | Description |
| ------------- | ------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| apiUrl | string | The API URL to send requests to. Probably one of `https://sparknesua.ordernet.co.il/api`, `https://sparkmeitav.ordernet.co.il/api` or `https://sparkpsagot.ordernet.co.il/api`. |
| authorization | string | The bearer token to pass for authentication in each API call |

## Account : Object

**Kind**: global typedef
**Properties**

| Name | Type | Description |
| ------ | ------------------- | ------------------------------------------------ |
| key | string | The account key for API usage (`ACC_XXX-YYYYYY`) |
| name | string | The name listed on the account |
| number | number | The account number (`YYYYYY`) |

# Refs

- https://github.com/danielbraun/ordernet-scraper