mizuho_bank

A library for accessing Mizuho Direct (Mizuho Bank's internet banking) from Ruby. It automates the login page flow (customer number โ†’ security questions โ†’ password) with Mechanize, letting you pull account balances and transaction statements out as Ruby objects.

It was published as a gem at the time. In an era with no API, it was a scraper for handling your own account data programmatically.

gem install mizuho_bank

Usage looks like this (from the README). It is designed to load credentials from Pit, an account-information manager, rather than hard-coding them.

require 'mizuho_bank'
require 'pit'

pit = Pit.get("MizuhoBank", :require => {
  "keiyaku_no" => "keiyaku_no",
  "password" => "password",
  # register the question/answer for all three aikotoba (secret questions) the same way
})

aikotoba_dict = {
  pit['aikotoba1_question'] => pit['aikotoba1_answer'],
  pit['aikotoba2_question'] => pit['aikotoba2_answer'],
  pit['aikotoba3_question'] => pit['aikotoba3_answer']
}

MizuhoBank.new(pit['keiyaku_no'].to_s, pit['password'].to_s, aikotoba_dict){ |bank|
  p bank.info.main_account.money        # account balance
  p bank.info.main_account.cache_flows  # recent transaction history
}

Internals

Component layout. The core MizuhoBank class ties together the login handling and page parsing, and results are returned packed into plain data classes: MizuhoDirectInfo / MizuhoAccount / MizuhoCacheFlow.

Component diagram of mizuho_bank

The flow from login through fetching statements.

Sequence diagram of mizuho_bank's login and statement retrieval

As a known issue, the image CAPTCHA demanded after repeated security-question failures is not supported (noted in the README). Also, since the parsing is tightly coupled to the page wording and table structure, this is the kind of code that breaks whenever the site is redesigned.

๐Ÿค– This English version is machine-translated by AI.