2017 © Pedro Pelรกez
 

library ifsc

Razorpay IFSC Codes Library

image

razorpay/ifsc

Razorpay IFSC Codes Library

  • Friday, July 27, 2018
  • by captn3m0
  • Repository
  • 67 Watchers
  • 106 Stars
  • 29,164 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 26 Forks
  • 10 Open issues
  • 80 Versions
  • 17 % Grown

The README.md

ifsc

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

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

Dataset

If you are just looking for the dataset, go to the releases section and download the latest release., (*3)

The latest scraper workflow on GitHub should publish a release-artifact as well., (*4)

Source

Various official sources are linked below, with the ones currently used marked with a โ€ , (*5)

SWIFT

SWIFT/BIC codes are supported for a few banks., (*6)

SBI
  • https://sbi.co.in/web/nri/quick-links/swift-codes โ€ 
  • https://sbi.co.in/documents/16012/263663/sbinri_merged_bran_swfcodet.xlsx โ€ 
  • Branch codes from above are checked against the SBI Branch Locator to get the IFSC.
PNB
  • https://pnbindia.com/downloadprocess.aspx?fid=Zb7ImdUNlz9Ge73qn1nXQg== โ€ 
  • https://www.pnbindia.in/document/PNB-helpdesk/bic_code.pdf โ€ 
HDFC
  • https://www.hdfcbank.com/nri-banking/correspondent-banks โ€ 

Installation

Ruby

Add this line to your application's Gemfile:, (*7)

gem "ifsc"

And then execute:, (*8)

$ bundle

Or install it yourself as:, (*9)

$ gem install ifsc

Inside of your Ruby program do:, (*10)

require "ifsc"

...to pull it in as a dependency., (*11)

PHP

composer require php-http/curl-client razorpay/ifsc, (*12)

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., (*13)

The minimum PHP version supported is 7.3. The package can be installed on PHP>=7.1 however., (*14)

Node.js

$ npm install ifsc, (*15)

Go

This package is compatible with modern Go releases in module mode, with Go installed:, (*16)

go get github.com/razorpay/ifsc/v2, (*17)

will resolve and add the package to the current development module, along with its dependencies., (*18)

Alternatively the same can be achieved if you use import in a package:, (*19)

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

and run go get without parameters., (*21)

Finally, to use the top-of-trunk version of this repo, use the following command:, (*22)

go get github.com/razorpay/ifsc/v2@master, (*23)

Support Matrix

Only the latest version of each SDK is considered., (*24)

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:, (*25)

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!), (*26)

# 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, (*27)

If you call code.valid? before calling code.get, the validation will be performed offline., (*28)

# 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., (*29)

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:, (*30)

  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., (*31)

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., (*32)

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., (*33)

API Development

The IFSC API is maintained in a separate repository at https://github.com/razorpay/ifsc-api., (*34)

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., (*35)

The Versions

27/07 2018
27/07 2018

dev-ex-httpoison-update

dev-ex-httpoison-update

Razorpay IFSC Codes Library

  Sources   Download

MIT

The Requires

 

The Development Requires

27/07 2018

dev-sublet-update-27-july

dev-sublet-update-27-july

Razorpay IFSC Codes Library

  Sources   Download

MIT

The Requires

 

The Development Requires

31/05 2018

dev-release/1.1.4

dev-release/1.1.4

Razorpay IFSC Codes Library

  Sources   Download

MIT

The Requires

 

The Development Requires

14/05 2018

1.1.4.x-dev

1.1.4.9999999-dev

Razorpay IFSC Codes Library

  Sources   Download

MIT

The Requires

 

The Development Requires

09/05 2018

dev-release/1.1.3

dev-release/1.1.3

Razorpay IFSC Codes Library

  Sources   Download

MIT

The Requires

 

The Development Requires

03/05 2018

dev-fix-datatype-string

dev-fix-datatype-string

Razorpay IFSC Codes Library

  Sources   Download

MIT

The Requires

 

The Development Requires

12/04 2018

dev-release/1.1.2

dev-release/1.1.2

Razorpay IFSC Codes Library

  Sources   Download

MIT

The Requires

 

The Development Requires

12/04 2018

dev-releases/1.1.2

dev-releases/1.1.2

Razorpay IFSC Codes Library

  Sources   Download

MIT

The Requires

 

The Development Requires

10/04 2018

dev-hex-wercker-dummy

dev-hex-wercker-dummy

Razorpay IFSC Codes Library

  Sources   Download

MIT

The Requires

 

The Development Requires

02/04 2018

dev-hex-wercker

dev-hex-wercker

Razorpay IFSC Codes Library

  Sources   Download

MIT

The Requires

 

The Development Requires

02/04 2018

dev-release/1.1.1

dev-release/1.1.1

Razorpay IFSC Codes Library

  Sources   Download

MIT

The Requires

 

The Development Requires

18/03 2018

dev-cleanup-extra-spaces

dev-cleanup-extra-spaces

Razorpay IFSC Codes Library

  Sources   Download

MIT

The Requires

 

The Development Requires

18/03 2018

dev-no-numeric-lookups

dev-no-numeric-lookups

Razorpay IFSC Codes Library

  Sources   Download

MIT

The Requires

 

The Development Requires

22/01 2018

dev-release/1.0.14

dev-release/1.0.14

Razorpay IFSC Codes Library

  Sources   Download

MIT

The Requires

 

The Development Requires

22/01 2018

dev-releases/1.0.14

dev-releases/1.0.14

Razorpay IFSC Codes Library

  Sources   Download

MIT

The Requires

 

The Development Requires

08/01 2018

dev-version-bump-1.0.13

dev-version-bump-1.0.13

Razorpay IFSC Codes Library

  Sources   Download

MIT

The Requires

 

The Development Requires

22/12 2017

dev-release/1.0.12

dev-release/1.0.12

Razorpay IFSC Codes Library

  Sources   Download

MIT

The Requires

 

The Development Requires

20/11 2017

dev-1.0.11-sbi-test

dev-1.0.11-sbi-test

Razorpay IFSC Codes Library

  Sources   Download

MIT

The Requires

 

The Development Requires

20/11 2017

dev-releases/1.0.10

dev-releases/1.0.10

Razorpay IFSC Codes Library

  Sources   Download

MIT

The Requires

 

The Development Requires

06/11 2017

dev-sbi-merger

dev-sbi-merger

Razorpay IFSC Codes Library

  Sources   Download

MIT

The Requires

 

The Development Requires

10/10 2017

dev-release/1.0.10

dev-release/1.0.10

Razorpay IFSC Codes Library

  Sources   Download

MIT

The Requires

 

The Development Requires

08/09 2017
19/06 2017

dev-release-1.0.3

dev-release-1.0.3

Razorpay IFSC Codes Library

  Sources   Download

MIT

The Requires

 

The Development Requires

30/05 2017

dev-release-1.0.2

dev-release-1.0.2

Razorpay IFSC Codes Library

  Sources   Download

MIT

The Requires

 

The Development Requires

27/03 2017

dev-release-0.2.12

dev-release-0.2.12

Razorpay IFSC Codes Library

  Sources   Download

MIT

The Requires

 

The Development Requires

21/03 2017
08/03 2017
28/02 2017

dev-api-client

dev-api-client

Razorpay IFSC Codes Library

  Sources   Download

MIT

The Requires

 

The Development Requires

27/02 2017

0.2.9

0.2.9.0

Razorpay IFSC Codes Library

  Sources   Download

MIT

10/02 2017

0.2.8

0.2.8.0

Razorpay IFSC Codes Library

  Sources   Download

MIT

26/01 2017

0.2.7

0.2.7.0

Razorpay IFSC Codes Library

  Sources   Download

MIT

16/01 2017

0.2.6

0.2.6.0

Razorpay IFSC Codes Library

  Sources   Download

MIT

02/01 2017

0.2.5

0.2.5.0

Razorpay IFSC Codes Library

  Sources   Download

MIT

16/12 2016

0.2.4

0.2.4.0

Razorpay IFSC Codes Library

  Sources   Download

MIT

14/12 2016

0.2.3

0.2.3.0

Razorpay IFSC Codes Library

  Sources   Download

MIT

05/12 2016

0.2.2

0.2.2.0

Razorpay IFSC Codes Library

  Sources   Download

MIT

30/11 2016

0.2.1

0.2.1.0

Razorpay IFSC Codes Library

  Sources   Download

MIT

15/11 2016

0.2.0

0.2.0.0

Razorpay IFSC Codes Library

  Sources   Download

MIT

14/11 2016

0.1.8

0.1.8.0

Razorpay IFSC Codes Library

  Sources   Download

MIT

03/11 2016

dev-npm

dev-npm

Razorpay IFSC Codes Library

  Sources   Download

MIT

03/11 2016

0.1.7

0.1.7.0

Razorpay IFSC Codes Library

  Sources   Download

MIT

12/10 2016

0.1.6

0.1.6.0

Razorpay IFSC Codes Library

  Sources   Download

MIT

29/08 2016

0.1.5

0.1.5.0

Razorpay IFSC Codes Library

  Sources   Download

MIT

01/08 2016

dev-regex

dev-regex

Razorpay IFSC Codes Library

  Sources   Download

MIT

01/08 2016

0.1.4

0.1.4.0

Razorpay IFSC Codes Library

  Sources   Download

MIT

21/07 2016

0.1.3

0.1.3.0

Razorpay IFSC Codes Library

  Sources   Download

MIT

27/06 2016

0.1.2

0.1.2.0

Razorpay IFSC Codes Library

  Sources   Download

MIT

25/05 2016

dev-ruby

dev-ruby

Razorpay IFSC Codes Library

  Sources   Download

MIT

25/05 2016

0.1.1

0.1.1.0

Razorpay IFSC Codes Library

  Sources   Download

MIT

29/04 2016

0.1.0

0.1.0.0

Razorpay IFSC Codes Library

  Sources   Download

MIT

29/04 2016

dev-php-validator

dev-php-validator

Razorpay IFSC Codes Library

  Sources   Download

MIT