Giter Site home page Giter Site logo

fnb-api's Introduction

FNB API

Pull account balances and transactions from FNB online banking.

Support

Basic Balances

Basic balances are supported for cheque, credit, savings, eBucks and vehicle accounts.

Detailed Balances

Basic balances are supported for cheque, credit, savings and vehicle accounts.

Transactions

Currently only cheque, credit and savings account transactions are supported.

Note: Only the first page (150 entries) of successful transactions are scraped.

Security

When using this, it's recommended to create a read-only secondary user on FNBs online banking site. See this guide for instructions.

Installation

npm i -S fnb-api

Usage

const FnbApi = require('fnb-api').Api;

(async () => {
  const api = new FnbApi({
    username: 'xxx',
    password: 'xxx'
  });

  const accounts = await api.accounts.get();
  console.log(accounts);

  const detailedBalance = await accounts[0].detailedBalance();
  console.log(detailedBalance);

  const transactions = await accounts[0].transactions();
  console.log(transactions[0]);

  await api.close();
})();
// All monetary and percent values are multiplied by 100
// ie R100,23 will be represented as 10023 and 9.75% will be represented as 975
[ Account {
    name: 'FNB XXX Cheque Account',
    accountNumber: 'XXX',
    balance: 1000000,
    availableBalance: 1000000 },
  Account {
    name: 'FNB XXX Credit Card',
    accountNumber: 'XXX',
    balance: 1000000,
    availableBalance: 1000000 },
  Account {
    name: 'Savings Account',
    accountNumber: 'XXX',
    balance: 1000000,
    availableBalance: 1000000 } ]
	
DetailedBalanceCheque {
  balance: 1000000,
  availableBalance: 1000000,
  reservedFunds: 0,
  pendingCredits: 0,
  chargesAccrued: 0,
  minimumBalance: 0,
  pendingDebits: 0,
  outstandingDebitCardAuthorization: -58156 }

TransactionCheque {
  date: moment("2018-12-08T00:00:00.000"),
  description: 'CAPE TOWN SERVICE C 409283*1927 06 DEC',
  amount: -20264,
  status: 'Successful',
  reference: '7479059234715535760161',
  serviceFee: 0,
  balance: 1000000 }

Options

{
  /** The username to log in with. */
  username: string;

  /** The password to log in with. */
  password: string;

  /** Should scraped data be cached. Default = true */
  cache?: boolean;

  /** If scraped data should be cached, for how long? Default = 60 */
  cacheTimeInSeconds?: number;

  /** Puppeteer options */
  puppeteerOptions?: PuppeteerLaunchOptions;
}

License

See LICENSE

fnb-api's People

Contributors

bitshiftza avatar circlingthesun avatar dependabot[bot] avatar jpwienekus avatar rynomster avatar stroebs avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

fnb-api's Issues

Help installing

Firstly, thank you for the script.

But, could you please provide instructions to get it to work in a laravel project?

Looking forward to your reply.

Transactions

Would it be possable to scrape a list of transactions?

Error: No element found for selector: #user

fnb@ftp:~/api$ node main.js
Error: No element found for selector: #user
at assert (/home/fnb/api/node_modules/fnb-api/node_modules/puppeteer-core/lib/cjs/puppeteer/util/assert.js:28:15)
at IsolatedWorld.type (/home/fnb/api/node_modules/fnb-api/node_modules/puppeteer-core/lib/cjs/puppeteer/common/IsolatedWorld.js:221:32)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

fnb@ftp:~/api$ npm list fnb-api
[email protected] /home/fnb/api
└── [email protected]

fnb@ftp:~/api$ npm show puppeteer-core version
22.0.0

Stopped working after 04/07/2022

Hey guys,

Everything was running smooth, even with every second call being a timeout error. Asof Monday 04/07/2022 the api stopped working.
Error:
TimeoutError: waiting for function failed: timeout 30000ms exceeded

Tried to reinstall/update to lates version:
npm uninstall fnb-api && sudo npm i -S fnb-api --unsafe-perm=true --allow-root; resulted in error:
Failed to launch the browser process!
/home/fnb/api/node_modules/fnb-api/node_modules/puppeteer/.local-chromium/linux-982053/chrome-linux/chrome: error while loading shared libraries: libgbm.so.1: cannot open shared object file: No such file or directory

After replacing old .local-chromium I recieve error:
Error: net::ERR_CONNECTION_RESET at https://fnb.co.za and
TimeoutError: waiting for function failed: timeout 30000ms exceeded

npm view fnb-api version
1.0.10
node -v
v18.4.0

Any idea how to resolve these problems?

Business profiles require an OTP

We have an enterprise profile, and while we tested your code to be working well for a private or business profile, it fails with enterprise because it neets a manual input from a user, to enter the OTP. Do you have any solution suggestions to this?

Help Installing

Thank you and to all the contrabuters for this scipt.
I have been struggling for quite some time getting with this and I'm not sure how to get results.
If I run node-ts I get this:

ajhart@ubuntuvm:/var/www/html/fnb-api-master$ ts-node --project tsconfig.test.json ./test/index.ts
(node:31925) UnhandledPromiseRejectionWarning: TypeError: moment_1.default is not a function
    at Scraper.<anonymous> (/var/www/html/fnb-api-master/src/scrapers/scraper.js:231:62)
    at step (/var/www/html/fnb-api-master/src/scrapers/scraper.js:33:23)
    at Object.next (/var/www/html/fnb-api-master/src/scrapers/scraper.js:14:53)
    at fulfilled (/var/www/html/fnb-api-master/src/scrapers/scraper.js:5:58)
    at process._tickCallback (internal/process/next_tick.js:68:7)
(node:31925) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:31925) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

When done compiling with tsc and add js to index.html to root directory:

<!DOCTYPE html>
<html>
<body>
<script>
const FnbApi = require('fnb-api').Api;
(async () => {
  const api = new FnbApi({
    username: 'xxxxx',
    password: 'xxxxx'
  });
  const accounts = await api.accounts.get();
  console.log(accounts);
  const detailedBalance = await accounts[0].detailedBalance();
  console.log(detailedBalance);
  const transactions = await accounts[0].transactions();
  console.log(transactions[0]);
  await api.close();
})();
</script>
</body>
</html>

I get console error in browser:

index.html:9 Uncaught ReferenceError: require is not defined
    at index.html:9

If I add <script src="dist/index.js"></script> to my index.html, I get Uncaught ReferenceError: exports is not defined
at index.js:12

I'm not sure what to do here. Could you please provide instructions to get json results in console log.
Looking forward to your reply.

Not All 150 rows on Transaction History page

Hi Dev's

I have recently discovered that not all 150 rows are shown when puppeteer navigates to Transaction History page. I noticed that on some occasions transactions would disappear and later re-appear. Only 61 rows are available on json. FNB has induced a "More" button on the bottom of page that will allow the full view of 150 row.

Elements found:

<div id="footerButtonsContainer" style="margin-left: 1173px;">
<div class="gridCol grid10 footerBtn ">
<a onclick="fnb.controls.controller.eventsObject.raiseEvent('loadUrlToWorkspace', {url: '/banking/Controller?nav=transactionhistory.navigator.TransactionHistoryRedirect&amp;productCode=DDA&amp;anrfn=*num*&amp;initial=false&amp;FARFN=*ref*&amp;pN=*key*==',preLoadingCallBack:''}); return false;" href="#">More</a>
</div>
<div class="gridCol grid10 footerBtn ">
<a onclick="fnb.controls.controller.eventsObject.raiseEvent('loadUrlToWorkspace', {url: '/banking/Controller?nav=accounts.summaryofaccountbalances.navigator.SummaryOfAccountBalances',preLoadingCallBack:''}); return false;" href="#">Close</a>
</div></div>

Any suggestions on how we can incorporate this more button, if exist?
Kind Regards.

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.