Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

ifsc

razorpay9.1kMIT2.0.44

This is part of the IFSC toolset released by Razorpay. You can find more details about the entire release at ifsc.razorpay.com. Includes only a validation library as of now.

ifsc, IFSC codes, validator, razorpay, Indian Financial System Code

readme

ifsc

This is part of the IFSC toolset released by Razorpay. You can find more details about the entire release at ifsc.razorpay.com.

Docker Image Version (latest semver) License: MIT npm version Gem Version PHP version

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'); // Returns true
IFSC::validate('BOTM0XEEMRA'); // Returns false

IFSC::validateBankCode('PUNB'); // Returns true
IFSC::validateBankCode('ABCD'); // Returns false

IFSC::getBankName('PUNB'); // Returns 'Punjab National Bank'
IFSC::getBankName('ABCD'); // Returns null

IFSC::getBankName(Bank::PUNB); //Returns Punjab National Bank

Bank::getDetails(Bank::PUNB);
Bank::getDetails('PUNB');

// Returns an array:
// [
//    'code' => 'PUNB',
//    'type' => 'PSB',
//    'ifsc' => 'PUNB0244200',
//    'micr' => '110024001',
//    'iin' => '508568',
//    'apbs' => true,
//    'ach_credit' => true,
//    'ach_debit' => true,
//    'nach_debit' => true,
//    'name' => 'Punjab National Bank',
//    'bank_code' => '024',
//    'upi' => true
// ]

$client = new Client();
$res = $client->lookupIFSC('KKBK0000261');

echo $res->bank; // 'KOTAK MAHINDRA BANK LIMITED'
echo $res->branch; // 'GURGAON'
echo $res->address; // 'KOTAK MAHINDRA BANK LTD. UNIT NO. 8&9, SEWA CORPORATE PARK, MG ROAD, REVENUE STATE OF SARHAUL TEHSIL, DISTT,- GURGAON- 122001'
echo $res->contact; // '4131000'
echo $res->city; // 'GURGAON'
echo $res->district; // 'GURGAON'
echo $res->state; // 'HARYANA'
echo $res->centre; // 'GURGAON'
echo $res->getBankCode(); // KKBK
echo $res->getBankName(); // 'Kotak Mahindra Bank'
echo $res->micr; // '110485003'
// Boolean fields: $res->upi, $res->rtgs, $res->neft, res->imps

// You will get a SWIFT code where possible:

echo $client->lookupIFSC('https://ifsc.razorpay.com/HDFC0CAGSBK')->swift; // 'HDFCINBB'

// lookupIFSC may throw `Razorpay\IFSC\Exception\ServerError`
// in case of server not responding in time
// or Razorpay\IFSC\Exception\InvalidCode in case
// the IFSC code is invalid

Node.js

var ifsc = require('ifsc');

ifsc.validate('KKBK0000261'); // returns true
ifsc.validate('BOTM0XEEMRA'); // returns false

ifsc.fetchDetails('KKBK0000261').then(function(res) {
   console.log(res);
    // {
    //   MICR: '560226263',
    //   BRANCH: 'THE AGS EMPLOYEES COOP BANK LTD',
    //   ADDRESS: 'SANGMESH BIRADAR BANGALORE',
    //   STATE: 'KARNATAKA',
    //   CONTACT: '+91802265658',
    //   UPI: true,
    //   RTGS: true,
    //   CITY: 'BANGALORE',
    //   CENTRE: 'BANGALORE URBAN',
    //   DISTRICT: 'BANGALORE URBAN',
    //   NEFT: true,
    //   IMPS: true,
    //   SWIFT: 'HDFCINBB',
    //   BANK: 'HDFC Bank',
    //   BANKCODE: 'HDFC',
    //   IFSC: 'HDFC0CAGSBK'
    // }
});

console.log(ifsc.bank.PUNB); // prints PUNB
// Prints the entire JSON from https://ifsc.razorpay.com/KKBK0000261
// res is an object, not string

Ruby

Make sure you have require 'ifsc' in your code. Validating a code offline. (Remember to keep the gem up to date!)

# valid?

Razorpay::IFSC::IFSC.valid? 'KKBK0000261' # => true
Razorpay::IFSC::IFSC.valid? 'BOTM0XEEMRA' # => false

# validate!

Razorpay::IFSC::IFSC.validate! 'KKBK0000261' # => true
Razorpay::IFSC::IFSC.validate! 'BOTM0XEEMRA' # => Razorpay::IFSC::InvalidCodeError

# bank_name_for(code) gets you the bank name offline
Razorpay::IFSC::IFSC.bank_name_for 'PUNB0026200' -> "Punjab National Bank"
Razorpay::IFSC::IFSC.bank_name_for 'KSCB0006001' -> "Tumkur District Central Bank"

# get_details gets you the bank details from `banks.json`
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
}

# constants

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.

# 1. using find
code = Razorpay::IFSC::IFSC.find 'KKBK0000261'

# 2. using new(...).get
code = Razorpay::IFSC::IFSC.new 'KKBK0000261'
code.get

# result
code.valid?
# => true
code.bank
# => "Kotak Mahindra Bank"
code.branch
# => "GURGAON"
code.address
# => "KOTAK MAHINDRA BANK LTD. UNIT NO. 8&9, SEWA CORPORATE PARK, MG ROAD, REVENUE STATE OF SARHAUL TEHSIL, DISTT,- GURGAON- 122001"
code.contact
# => "4131000"
code.city
# => "GURGAON"
code.district
# => "GURGAON"
code.state
# => "HARYANA"
code.centre
# => GURGAON
code.neft
# => true
code.upi
# => true
code.imps
# => true
code.rtgs
# => true
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:

  1. src/sublet.json - Autogenerated from the NPCI website
  2. src/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

# all these `Razorpay::IFSC::InvalidCodeError` for an invalid code
Razorpay::IFSC::IFSC.validate! '...'
Razorpay::IFSC::IFSC.find '...'
code = Razorpay::IFSC::IFSC.new '...'; code.get

# these raise `Razorpay::IFSC::ServerError` if there is an error
# communicating with the server
Razorpay::IFSC::IFSC.find '...'
code = Razorpay::IFSC::IFSC.new '...'; code.get

Go

package main

import (
    ifsc "github.com/razorpay/ifsc/v2/src/go"
)

// todo: change funcs not required to lower case.

func main() {

    ifsc.Validate("KKBK0000261") // Returns true
    ifsc.Validate("BOTM0XEEMRA") // Returns false

    ifsc.ValidateBankCode("PUNB") // Returns true
    ifsc.ValidateBankCode("ABCD") // Returns false

    ifsc.GetBankName("PUNB") // Returns "Punjab National Bank", nil
    ifsc.GetBankName("ABCD") // Returns "", errors.New(invalid bank code)
    ifsc.GetBankName(ifsc.HDFC) // Returns "HDFC Bank", nil


    ifsc.GetBankDetails("PUNB")
    // or
    ifsc.GetBankDetails(ifsc.PUNB)

    /* Returns
        (*ifsc.Bank){
        Name      : "Punjab National Bank",
        BankCode  : "024",
        Code      : "PUNB",
        Type      : "PSB",
        IFSC      : "PUNB0244200",
        MICR      : "110024001",
        IIN       : "508568",
        APBS      : true,
        AchCredit : true,
        AchDebit  : true,
        NachDebit : true,
        Upi       : true
    }), nil
    */

    ifsc.LookUP("KKBK0000261")

    /*
    Returns
    (*ifsc.IFSCResponse)({
     Bank      :  "Kotak Mahindra Bank",
     Branch      :  "GURGAON",
     Address  :  "KOTAK MAHINDRA BANK LTD. UNIT NO. 8&9, SEWA CORPORATE PARK, MG ROAD, REVENUE STATE OF SARHAUL TEHSIL, DISTT,- GURGAON- 122001",
     Contact  :  "4131000",
     City      :  "GURGAON",
     District :  "GURGAON",
     State      :  "HARYANA",
     IFSC      :  "KKBK0000261",
     BankCode :  "KKBK"
    }), nil
     */
}

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.

changelog

Changelog

All notable changes to this project will be documented in this file. The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.

UNRELEASED

[2.0.44][2.0.44]

Changed

  • Metadata updates

[2.0.43][2.0.43]

Changed

  • Metadata updates

[2.0.42][2.0.42]

Changed

  • Metadata updates

[2.0.41][2.0.41]

Changed

  • Metadata updates
  • Ruby Version Update to 3.1

[2.0.40][2.0.40]

Changed

  • Metadata updates

[2.0.39][2.0.39]

Changed

  • Metadata updates

[2.0.38][2.0.38]

Changed

  • Metadata updates

[2.0.37][2.0.37]

Changed

  • Metadata updates

[2.0.36][2.0.36]

Changed

  • Metadata updates
  • Support for XNSE (NSE Clearing Limited) added. XNSE0000001 is the branch.

[2.0.35][2.0.35]

Changed

  • Metadata updates

[2.0.34][2.0.34]

Changed

  • Metadata updates

[2.0.33][2.0.33]

Changed

  • Metadata updates

[2.0.32][2.0.32]

Changed

  • Metadata updates

[2.0.31][2.0.31]

Changed

  • Metadata updates

[2.0.30][2.0.30]

Changed

  • Metadata updates

[2.0.29][2.0.29]

Changed

  • Metadata updates

[2.0.28][2.0.28]

Changed

  • Metadata updates

[2.0.27][2.0.27]

Changed

  • Metadata updates

[2.0.26][2.0.26]

Changed

  • Metadata updates

[2.0.25][2.0.25]

Changed

  • Metadata updates

[2.0.24][2.0.24]

Changed

  • Metadata updates

[2.0.23][2.0.23]

Changed

  • Metadata updates

[2.0.22][2.0.22]

Changed

  • Metadata updates

[2.0.21][2.0.21]

Changed

  • Metadata updates

[2.0.20][2.0.20]

Changed

  • Metadata updates

[2.0.19][2.0.19]

Changed

  • Metadata updates

[2.0.18][2.0.18]

Changed

  • Metadata updates

[2.0.17][2.0.17]

Changed

  • Metadata updates

[2.0.16][2.0.16]

Changed

  • Metadata updates
  • Automated SDK Releases
  • Added Documentation

[2.0.14][2.0.14]

Changed

  • Metadata updates

[2.0.13][2.0.13]

Changed

  • Metadata updates

[2.0.12][2.0.12]

Changed

  • Metadata updates

[2.0.11][2.0.11]

Changed

  • Metadata updates

2.0.10

Changed

  • Metadata Updates

2.0.9

Changed

  • Updates on list of UPI enabled banks
    +ABSB Abhinav Sahakari Bank
    +AJKB Akola Janata Commercial Co-operative Bank
    +APRR A.P. Raja Rajeswari Mahila Co-operative Urban Bank
    +BDBX Bellary District Co-operative Central Bank
    +BHCX Bhuj Commercial Co-operative Bank
    +BMCB Bombay Mercantile Co-operative Bank
    -CGBX Chhattisgarh Rajya Gramin Bank
    +CRGB Chhattisgarh Rajya Gramin Bank
    +FINX Financial Co-operative Bank
    +GUNX Guntur Co-operative Urban Bank
    +JONX Jodhpur Nagrik Sahakari Bank
    +MCUX Mahaveer Co-operative Urban Bank
    -MMMX Mahila Nagrik Sahakari Bank Maryadit Mahasamund
    -MSOX Manorama Co-operative Bank Solapur
    +MSSX Merchants Souharda Sahakara Bank Niyamitha
    +SWSX Shree Warana Sahakari Bank
    +TKTX Kottakkal Co-operative Urban Bank
    +UCBX Urban Co-operative Bank Bareilly
    +VADX Valsad District Central Co-operative Bank
    +VASJ Vasai Janata Sahakari Bank
    -VJSX Vasai Janata Sahakari Bank
    +COMX Co-operative Bank of Mehsana
  • Metadata Updates
  • Dependency Updates

2.0.8

Changed

  • Metadata updates

2.0.7

Changed

  • Dependency Updates
  • Updated metadata
  • All constant files are now automatically generated
  • IXXX as custom bank code for "Indrayani Co-operative Bank"
  • NPCI does not publish bank type any more, so these are now maintained in this repository as patches
  • Minor bank name updates
  • Support for Go 1.18
  • New field added: ISO3166 (IN-XX, as per the ISO-3166 specification).

2.0.6

Changed

  • Updated Metadata

2.0.5

Changed

  • Updated Metadata

2.0.4

Changed

  • Update IFSC.json for the below 20 IFSC codes

2.0.3

Changed

  • Adds back 20 IFSC codes removed due to a change on the RBI sheet structure in 2.0.2

2.0.2

Changed

  • Metadata changes

2.0.1

Changed

  • Metadata changes

2.0.0

Removed

  • Removed support for Elixir package

    Changed

  • Builds are now powered by GitHub Actions, instead of Wercker

    Added

  • There is a supported golang SDK. See the README for instructions on how to use it.
  • 1 New Bank: "AHDC": "Ahmednagar District Central Co-operative Bank"

1.6.1

Added

  • Only metadata changes in this release.
  • 2 new banks
    • RDCB: Rajnandgaon District Central Co Operative Bank
    • TMSB: The Malad Sahakari Bank Ltd

      [1.6.0][1.6.0]

  • Support PHP8
  • Fix for some invalid IFSCs being marked as valid. Ex: PUNB0000000 (#229)
  • Update list of UPI enabled banks
  • Fix all exported datasets to include correct bank name.
  • Only use validated MICR codes

1.5.13

  • [upi] Vijaya Bank and Dena Gujarat Gramin Bank are no more
  • [upi] 7 new banks now support UPI
  • Metadata update for new release
  • Sanitizes most text fields to remove special characters that show up from encoding errors. Fixes #29, #32
  • Start parsing contact numbers from NEFT sheet as well. Published in E.164 wherever possible
  • Changes some empty fields to null instead of "NA"

1.5.12

  • Only metadata changes in this release.
  • Data corrections to account for broken alignment in RBI's RTGS spreadsheet
  • Improved support for Contact details that are sourced from RTGS dataset. CONTACT details are returned in E.164 format

1.5.11

Changed

  • Metadata updates

1.5.10

Changed

  • 2 new banks:
    • ARBL: Arvind Sahakari Bank
    • TNCB: Nawanagar Co-operative Bank
  • Name for STCB changed from "State Bank of Mauritius" to "SBM Bank"
  • Temporary code added for "Sri Rama Co-operative Bank": SXXX
  • Support for ICLL (Indian Clearing Corporation) added. ICLL0000001 is the branch.

1.5.9

Added

  • Initial support for SWIFT mappings. Only SBI and PNB branches are currently supported, and accuracy is not guaranteed. Feedback is welcome.

Changed

  • Metadata changes

1.5.8

Changed

  • Only metadata changes in this release
  • New Banks:
    • AKKB: Akkamahadevi Mahila Sahakari Bank Niyamit
    • MUCG: Merchants Urban Coop Bank
    • SBCR: Shree Basaveshwar Urban Coop Bank
    • SBPS: Sri Basaveshwar Pattana Sahakari Bank

1.5.7

Changed

  • 1 new bank - TPSC ("Punjab State Cooperative Bank")
  • 15 new banks in UPI
  • Patches PUNB0641100 to give correct response.
  • [php] Returns the BANKCODE from the API instead of using the first 4 characters.
  • The large number of additions to Union Bank/Punjab National bank is due to the upcoming mergers. The existing IFSC for the merged banks are not impacted.

1.5.6

Changed

  • Metadata updates

1.5.5

Changed

  • Metadata updates
  • New Banks:
    • HUCH : Hanamasagar Urban Co-operative Bank
    • MDBK : Model Co-operative Bank
    • SDTC : Shri D T Patil Co-operative Bank

1.5.4

Changed

  • Metadata updates
  • Optimized memory consumption in php tests.
  • New Banks:
    • KBKB : Kookmin Bank
    • SUSB : Suco Souharda Sahakari Bank

1.5.3

Changed

  • Metadata updates

1.5.2

Changed

  • Metadata updates

1.5.1

Changed

  • Metadata updates
  • Madhya Bihar Gramin Bank and Bihar Gramin Bank merged to form Dakshin Bihar Gramin Bank.

Fixed

  • Fixes a critical bug in the node.js SDK which reported some valid IFSCs as invalid.
  • CENTRE and CITY fields should now be present across all rows. If we don't have a value, it will be set to NA.

Added

  • New DatasetTest to ensure fields don't get missed out in the future

1.5.0

Added

  • Adds bank constants in nodejs
  • Adds offline bank details fetch method in ruby.
  • Adds support for upi: true flag in banks.json
  • Adds UPI: true/false flag in IFSC.csv and by-banks JSON files

Changed

  • Improves coverage of bank constants in ruby.

1.4.10 - 2020-01-02

  • Metadata Updates
  • Support for patches that can override data for specific IFSC codes
  • NEFT Block for certain banks:
    • Bank Of Ceylon
    • Krung Thai Bank
    • Kaveri Grameena Bank
    • Kerala Gramin Bank
    • Pragathi Krishna Gramin Bank
    • Sbm Bank Mauritius Ltd

1.4.9 - 2019-11-07

  • Metadata Updates

1.4.7 - 2019-10-14

  • Minor Metadata updates

1.4.6 - 2019-09-05

  • Metadata updates
  • Catholic Syrian Bank is renamed to CSB Bank

1.4.5 - 2019-07-15

  • Regular Metadata Updates

1.4.4 - 2019-06-17

Changed

  • Regular Metadata Updates

Added

  • Adds support for custom sublets. (#114)

1.4.2 - 2019-05-16

Changed

  • Regular Metadata Updates

1.4.1 - 2019-04-25

Fixed

  • Parsing of empty/NA MICR/IINs/IFSCs in NPCI ACH List. #100

Changed

  • Updated list of sublets to remove all exceptions

[1.4.0][1.4.0] - 2019-04-19

Added

  • Regular Metadata Changes. See [Release Page][1.4.0] for a list.
  • One new Bank: AJAR
  • Adds NPCI-only IFSCs from https://www.npci.org.in/national-automated-clearing-live-members-1. See #100 and #109 for some more details.
  • A NEFT=true|false flag is added on all datasets, which will get added to the API with this release.
  • A IMPS=true|false flag is added, which is currently in alpha. There is not enough clarity around this yet (See #109), so please don't use this in production yet. This can be removed at any time. Feedback on the correctness of this flag is welcome.
  • A MICR is now available for all rows. This will also reflect on the API.

Changed

  • Parser speed and general improvements. Builds only take 3 minutes, and caching related stuff is removed.
  • The parser converts XLS/XLSX files to CSV before parsing, which results in cleaner data in some cases.

Removed

  • Removes some data formats (YAML/Large JSON) for cleaner code. If you were using them, please let create an issue.