Code Monkey home page Code Monkey logo

nubank-api's Introduction

Nubank API npm version

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

import { v4 as uuidv4 } from "uuid"; // Browser/Node.js
import { v4 as uuidv4 } from "react-native-uuid"; // ReactNative

import { createInterface } from "readline";
import { writeFile } from "fs/promises";

const CPF: string = "your-cpf";
const PASSWORD: string = "your-password";
const AUTH_CODE: string = uuidv4();

const api = new NubankApi();

const rl = createInterface({
  input: process.stdin,
  output: process.stdout,
});

rl.question(
  `Generate a QRcode and read with the app: ${AUTH_CODE}`,
  async () => {
    try {
      await api.auth.authenticateWithQrCode(CPF, PASSWORD, AUTH_CODE);
      console.log("You are authenticated!");
      console.log(api.authState);
      await writeFile("./auth-state.json", JSON.stringify(api.authState)); // Saves the auth data to use later
      process.exit(0);
    } catch (e) {
      console.error(e.stack);
    }
  }
);

For more examples, check the examples folder.

API

new NubankApi(params?: NubankApiConstructor)

The constructor takes an object containing the authentication details, 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.

Key Type Description
cert Buffer (Optional) the SSL certificate. Mandatory in case of authentication via p12 certificate.
clientName string (Optional) name of your client. Used to identify the origin of the requests in your account.
privateUrls Routes (Optional) private routes received after authentication.
publicUrls Record<string, string> (Optional) public routes received after authentication.

Class properties

All the operations available are methods nested within the object properties.

Property Description
auth Authentication operations
account Contains methods to access the user account details and the checking account transactions and bills
card Contains methods to retrieve the feed of transactions from the credit card
payment Contains methods to create payment requests
http Wrapper for the API access used by the other modules. Don't use it unless you need to make custom requests not supported by this lib

LICENSE

GNU GPL v3

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.