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

zonky-api-handler

v2.35.46

Published

Unofficial handler for Zonky API

Downloads

8

Readme

Zonky API handler

npm version renovate-app Known Vulnerabilities codecov travis

Unofficial API handler for Zonky. You can see full documentation on apiary.

How to use

Install package:

npm install zonky-api-handler

You must include polyfill for browser fetch to use it with Node.

require('cross-fetch/polyfill');
const { DateTime } = require('luxon');
const { ZonkyApi } = require('zonky-api-handler');

(async () => {
    const api = new ZonkyApi();
    await api.login(USERNAME, PASSWORD);

    const { transactions } = await api.getTransactions(DateTime.fromISO('2018-01-01'));
    console.log(transactions);
})()

You can also request export token and download xlsx reports:

require('cross-fetch/polyfill');
const fs = require('fs');
const { ZonkyApi } = require('zonky-api-handler');

(async () => {
    const api = new ZonkyApi();
    await api.login(USERNAME, PASSWORD);
    
    const investments = await api.downloadInvestments();
    fs.writeFileSync('investments.xlsx', investments);
    
})()

Downloading of transactions.

To download transactions you need to authorize through the SMS code. Example with Vorpal CLI:

require('cross-fetch/polyfill');
const vorpal = require('vorpal')();
const { ZonkyApi, EXCEPTION } = require('zonky-api-handler');

const USERNAME = 'XXX';
const PASSWORD = 'XXX';

const api = new ZonkyApi();

vorpal.command('download', 'Download transaction report.')
    .action(async function (args, cb) {
        // login user
        await api.login(USERNAME, PASSWORD);

        // send request to download transaction
        try {
            await api.downloadTransactions();
        } catch (exception) {
            // if the error is SMS required, continue, otherwise show an error
            if (!(exception instanceof EXCEPTION.ZonkyApiSMSException)) {
                throw exception;
            }

            console.log('SMS code was sent to your phone.');
        }

        // request SMS code from user
        const { sms } = await this.prompt([
            {
                type: 'input',
                name: 'sms',
                message: 'SMS code: ',
            },
        ]);

        // download file with the SMS code
        const data = await api.downloadTransactions(sms);

        // print output
        console.log(data);
        cb();
    });

vorpal
    .show()
    .parse(process.argv);

CLI to download Zonky reports

usage: zonky-report-download [email protected] password-zonky transactions.xlsx investments.xlsx

require('cross-fetch/polyfill');
const fs = require('fs');
const { ZonkyApi } = require('zonky-api-handler');

(async () => {

   if (process.argv.length!=6) {
        console.log("zonky-report-download <login-email> <zonky-password> <transaction filename> <investments filename>");
        console.log("zonky-report-download [email protected] password-zonky transactions.xlsx investments.xlsx");
        process.exit(-1);
   }

    const api = new ZonkyApi();
    console.log(`Login to Zonky: ${process.argv[2]}`);
    await api.login(process.argv[2], process.argv[3]);

    console.log(`Download transactions: ${process.argv[4]}`);
    const transactions = await api.downloadTransactions();
    fs.writeFileSync(process.argv[4], transactions);

    console.log(`Download investments: ${process.argv[5]}`);
    const people = await api.downloadInvestments();
    fs.writeFileSync(process.argv[5], people);

    console.log("Done");
})()