ifsc
This is part of the IFSC toolset released by Razorpay.
You can find more details about the entire release at
ifsc.razorpay.com.
Dataset
If you are just looking for the dataset, go to the releases section and download the latest release.
The latest scraper
workflow on GitHub should publish a release-artifact
as well.
Source
Various official sources are linked below, with the ones currently used marked with a †
SWIFT
SWIFT/BIC codes are supported for a few banks.
SBI
PNB
HDFC
Installation
Ruby
Add this line to your application's Gemfile:
gem "ifsc"
And then execute:
$ bundle
Or install it yourself as:
$ gem install ifsc
Inside of your Ruby program do:
require "ifsc"
...to pull it in as a dependency.
PHP
composer require php-http/curl-client razorpay/ifsc
The PHP package has a dependency on the virtual package php-http/client-implementation
which requires you to install an adapter, but we do not care which one. That is an implementation detail in your application. You do not have to use the php-http/curl-client
if you do not want to. You may use the php-http/guzzle6-adapter
. Read more about the virtual packages, why this is a good idea and about the flexibility it brings at the HTTPlug docs. You can find a list of suported providers on packagist.
The minimum PHP version supported is 7.3. The package can be installed on PHP>=7.1 however.
Node.js
$ npm install ifsc
Go
This package is compatible with modern Go releases in module mode, with Go installed:
go get github.com/razorpay/ifsc/v2
will resolve and add the package to the current development module, along with its dependencies.
Alternatively the same can be achieved if you use import in a package:
import "github.com/razorpay/ifsc/v2/src/go"
and run go get without parameters.
Finally, to use the top-of-trunk version of this repo, use the following command:
go get github.com/razorpay/ifsc/v2@master
Support Matrix
Only the latest version of each SDK is considered.
Language | Validation | API Client | Sublet Support (Custom) | Bank Constants |
---|
PHP | ✅ | ✅ | ✅ (✅) | ✅ |
Ruby | ✅ | ✅ | ✅ (✅) | ✅ |
Node.js | ✅ | ✅ | ❎ (❎) | ✅ |
Go | ✅ | ✅ | ✅ (✅) | ✅ |
API Documentation
This repository also hosts the source code for 5 modules: PHP/Node.js/Ruby/Go as of now.
The API is documented below:
PHP
<?php
use Razorpay\IFSC\Bank;
use Razorpay\IFSC\IFSC;
use Razorpay\IFSC\Client;
IFSC::validate('KKBK0000261');
IFSC::validate('BOTM0XEEMRA');
IFSC::validateBankCode('PUNB');
IFSC::validateBankCode('ABCD');
IFSC::getBankName('PUNB');
IFSC::getBankName('ABCD');
IFSC::getBankName(Bank::PUNB);
Bank::getDetails(Bank::PUNB);
Bank::getDetails('PUNB');
$client = new Client();
$res = $client->lookupIFSC('KKBK0000261');
echo $res->bank;
echo $res->branch;
echo $res->address;
echo $res->contact;
echo $res->city;
echo $res->district;
echo $res->state;
echo $res->centre;
echo $res->getBankCode();
echo $res->getBankName();
echo $res->micr;
echo $client->lookupIFSC('https://ifsc.razorpay.com/HDFC0CAGSBK')->swift;
Node.js
var ifsc = require('ifsc');
ifsc.validate('KKBK0000261');
ifsc.validate('BOTM0XEEMRA');
ifsc.fetchDetails('KKBK0000261').then(function(res) {
console.log(res);
});
console.log(ifsc.bank.PUNB);
Ruby
Make sure you have require 'ifsc'
in your code.
Validating a code offline. (Remember to keep the gem up to date!)
Razorpay::IFSC::IFSC.valid? 'KKBK0000261'
Razorpay::IFSC::IFSC.valid? 'BOTM0XEEMRA'
Razorpay::IFSC::IFSC.validate! 'KKBK0000261'
Razorpay::IFSC::IFSC.validate! 'BOTM0XEEMRA'
Razorpay::IFSC::IFSC.bank_name_for 'PUNB0026200' -> "Punjab National Bank"
Razorpay::IFSC::IFSC.bank_name_for 'KSCB0006001' -> "Tumkur District Central Bank"
Razorpay::IFSC::Bank.get_details 'PUNB'
{
code: 'PUNB',
type: 'PSB',
ifsc: 'PUNB0244200',
micr: '110024001',
bank_code: '024',
iin: '508568',
apbs: true,
ach_credit: true,
ach_debit: true,
nach_debit: true
}
Razorpay::IFSC::Bank::PUNB
'PUNB'
Validate online and retrieve details from the server
If you call code.valid?
before calling code.get
, the validation will be performed offline.
code = Razorpay::IFSC::IFSC.find 'KKBK0000261'
code = Razorpay::IFSC::IFSC.new 'KKBK0000261'
code.get
code.valid?
code.bank
code.branch
code.address
code.contact
code.city
code.district
code.state
code.centre
code.neft
code.upi
code.imps
code.rtgs
code.swift
Sublet Branches
You can use the code.bank_name
method to get the bank name considering sublet branches.
code = Razorpay::IFSC::IFSC.find 'HDFC0CKUB01'
code.bank_name "Khamgaon Urban Co-operative Bank"
This works offline, and doesn't need a network call. This information is stored across 2 files:
src/sublet.json
- Autogenerated from the NPCI websitesrc/custom-sublets.json
- Maintained manually. Coverage is not 100%. PRs are welcome.
Sublet (or Sub-Member) branches are IFSC codes belonging to a large bank, but leased out to
smaller banks. In some cases, entire ranges are given to a specific bank.
For eg, all IFSCs starting with YESB0TSS
belong to Satara Shakari Bank
. These are
maintained manually in custom-sublets.json
.
Error handling
Razorpay::IFSC::IFSC.validate! '...'
Razorpay::IFSC::IFSC.find '...'
code = Razorpay::IFSC::IFSC.new '...'; code.get
Razorpay::IFSC::IFSC.find '...'
code = Razorpay::IFSC::IFSC.new '...'; code.get
Go
package main
import (
ifsc "github.com/razorpay/ifsc/v2/src/go"
)
func main() {
ifsc.Validate("KKBK0000261")
ifsc.Validate("BOTM0XEEMRA")
ifsc.ValidateBankCode("PUNB")
ifsc.ValidateBankCode("ABCD")
ifsc.GetBankName("PUNB")
ifsc.GetBankName("ABCD")
ifsc.GetBankName(ifsc.HDFC)
ifsc.GetBankDetails("PUNB")
ifsc.GetBankDetails(ifsc.PUNB)
ifsc.LookUP("KKBK0000261")
}
Code Notes
Both the packages ship with a 300kb JSON file, that
includes the entire list of IFSC codes, in a compressed,
but human-readable format.
The Bank Code and Names list is maintained manually, but verified
with tests to be accurate as per the latest RBI publications. This
lets us add older Bank codes to the name list, without worrying
about them getting deleted in newer builds.
API Development
The IFSC API is maintained in a separate repository at https://github.com/razorpay/ifsc-api.
License
The code in this repository is licensed under the MIT License. License
text is available in the LICENSE
file. The dataset itself
is under public domain.