up-bank-api

The Up Bank API TypeScript wrapper

Usage no npm install needed!

<script type="module">
  import upBankApi from 'https://cdn.skypack.dev/up-bank-api';
</script>

README

up-bank-api

npm version npm downloads download size Publish

A TypeScript wrapper around the UpBank API.

Usage

$ npm install up-bank-api

Simply instantiate the API with your API Key and you should be able to start using it.

import { UpApi, isUpApiError } from 'up-bank-api';

const up = new UpApi('api-key-in-here');

const validateApiKey = async () => {
  try {
    await up.util.ping();
  } catch (e) {
    if (isUpApiError(e)) {
      if (401 === e.response.status) {
        console.log('Invalid API key');

        return false;
      }
    }

    // Unexpected error
    throw e;
  }

  return true;
};

const validApiKey = await validateApiKey();

if (validApiKey) {
  try {
    const accounts = await up.accounts.list({ pageSize: 30 });
  } catch (e) {
    if (isUpApiError(e)) {
      // Handle error returned from Up API
      console.log(e.response.data.errors);
    }

    // Unexpected error
    throw e;
  }
}

Supported modules

The following modules of the Up API are fully supported:

Publishing

To publish a new version we use the yarn release command, which is configured to run the np command as detailed here. This command will update the package.json version number, and open a GitHub page in your browser ready to tag a release.

Publishing to npm is handled by the publish GitHub action.

Special thanks

Special thanks to LifeBac/intakeq-api for API architecture inspiration.