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

nubank-connector

v0.4.0

Published

Yet another Nubank API connector

Downloads

4

Readme

Nubank API

A high level API to connect to Nubank service and download your purchase records.

This project was created because the API changed over time, and the JavaScript projects weren't updated to communicate to the new version. The Python library is updated by the time of this writing, so I used that as reference to build this library.

Installation Node.js/Browser

npm i nubank-api uuid

Installation React Native

npm i nubank-api react-native-uuid

Usage

const NubankApi = require("nubank-api"); // CommonJS syntax
import NubankApi from "nubank-api"; // ES Modules syntax

const CPF = "<your-cpf-number>";
const PASSWORD = "your-password";

(async function main() {
  const api = new NubankApi();

  const authCode = await api.login(CPF, PASSWORD);
  await renderQrCode(authCode);
  await waitForUserInput("Press any key to continue after reading the QR code");
  const { accessToken, privateUrls, publicUrls } = await api.validateLogin(authCode);

  saveToCache({ accessToken, privateUrls, publicUrls }); // Better cache that, because making too many login requests results in a 429 error
  
  // ------------------ OR ------------------------

  // or add the accessToken and the privateUrls in case you already have them
  const { accessToken, privateUrls, publicUrls } = readCache();
  const api = new NubankApi({ accessToken, privateUrls, publicUrls });

  // Now you are ready to access your account :)
})();

Or if you are using React Native, you need to configure the UUID generator function as well

  import uuid from 'react-native-uuid';

  // ...

  const api = new NubankApi();

  // or add the accessToken and the privateUrls in case you already have them
  const { accessToken, privateUrls } = readCache();
  const options = {
    uuidAdapter: uuid.v4
  };
  const api = new NubankApi({ accessToken, privateUrls, options });
})();

API

new NubankApi(accessToken: string, routes: Routes)

The constructor takes an access token and an object containing some routes, which are received after the login operation. This avoids extra requests for login to be executed because it can cause your account to be blocked from logging in for up to 72h in this IP.

login(cpf: string, password: string): Promise

Executes the login procedure and generates an authentication code, which needs to be used to generate a QR code and be read by the user's phone, so the access token attached to the requests can be activated.

validateLogin(authCode: string): Promise

You'll only need to call this method if you omit validateCallback on the login method. This method takes the authentication code used in the QR code scan to complete the login procedure asynchronously.

getCardFeed(): Promise<Transaction[]>

Retrieves the list of credit card operations.

getCardTransactions(): Promise<Transaction[]>

Retrieves the entire history of credit card transactions since the first use of the cards.

getBills(): Promise<Bill[]>

Retrieves a list with all the bills created with the user's transactions since the first use, until the future charges.

getAccountBalance(): Promise

Retrieves the NuConta balance.

getAccountFeed(): Promise<AccountTransaction[]>

Retrieves the list of debit card and account operations.

getAccountTransactions(): Promise<AccountTransaction[]>

Retrieves the entire history of debit card and transfer transactions since the first use of the NuConta.