Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/robbertkl/bunq-session
Basic bunq API client
https://github.com/robbertkl/bunq-session
bunq bunq-api
Last synced: 22 days ago
JSON representation
Basic bunq API client
- Host: GitHub
- URL: https://github.com/robbertkl/bunq-session
- Owner: robbertkl
- License: mit
- Created: 2019-08-13T21:46:03.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2023-12-10T09:22:51.000Z (12 months ago)
- Last Synced: 2024-10-13T01:01:36.872Z (about 1 month ago)
- Topics: bunq, bunq-api
- Language: JavaScript
- Size: 188 KB
- Stars: 2
- Watchers: 3
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# bunq-session
[![npm version](https://badge.fury.io/js/bunq-session.svg)](https://www.npmjs.com/package/bunq-session)
Basic bunq API client. Uses [bunq-http](https://github.com/robbertkl/bunq-http) and extends it with:
- automatic session management (initial key generation, device installation, login, auto reauthenticate after expiry)
- preconfigured production and sandbox hosts, including matching rate limit throttling
- installation/session persistence (provides a `FileStore` and `MemoryStore`, but you can always plug in your own)
- promise-based (async) functions for managed calls to the API
- async iterator for paginated resource walkingThe async iterator allows you to use `for await...of` to loop over all (paginated) resources, automatically fetching new pages as you go. See the usage example below.
Please note this is not a full SDK; aside from the "login calls" (`installation`, `device-server`, `session-server`) the library does not know about any API endpoints or responses. In many cases, however, this is perfectly fine as you can just send/receive JSON following the documentation.
## Installation
```sh
npm install --save bunq-session
```## Usage example
```JavaScript
import { BunqSession, FileStore } from 'bunq-session';const bunq = new BunqSession('___my_bunq_sandbox_api_key___', {
sandbox: true,
store: new FileStore('./state.json'),
});(async () => {
try {
const userId = await bunq.getUserId();
for await (const account of bunq.list(`user/${userId}/monetary-account`)) {
if (account.status !== 'ACTIVE') continue;
console.log(`${account.description}: ${account.balance.currency} ${account.balance.value}`);
}
} catch (err) {
console.error(`ERROR: ${err.message}`);
}
})();
```## Authors
- Robbert Klarenbeek,
## License
This repo is published under the [MIT License](LICENSE).