How to Find Bank Branch Name from IFSC Code in Python?

What is an IFSC Code?

The IFSC is an abbreviation for Indian Financial System Code is an 11-digit alpha-numeric code that is used to uniquely classify bank branches within the National Electronic Fund Transfer (NEFT) network by the Central Bank.

Let us now see how to retrieve bank information from an IFSC code.

Python, as you are aware, has a variety of modules and libraries that may be used to execute a variety of tasks. Here, we use Python’s requests module. The details are asked from Razorpay.

In Python, we may send HTTP requests by utilizing the requests module. The HTTP request returns data according to it.

Before we work with this module we use should first install it on our system as shown below.

Installation:

pip install requests

The IFSC codes for some of the states

State                           District                         Branch                                                   IFSC Code

KARNATAKA             BANGALORE                URBAN BANGALORE CITY                   SIBL0000008

TAMIL NADU            VELLORE                       ARKONAM                                                 SIBL0000004

KERALA                      ERNAKULAM                MATTANCHERRY                                   SIBL0000018

MAHARASHTRA      GREATER BOMBAY     MUMBAI BANDRA                                 SIBL0000157

TELANGANA            ADILABAD                       MANCHERIAL                                         SIBL0000867

Finding Bank Branch Name from IFSC Code in Python

Approach:

  • Import requests module using the import keyword
  • Give the URL of Razorpay to send HTTP request and store it in a variable.
  • Give the IFSC code as user input using the input() function and store it in a variable.
  • Add both the above-given Razorpay Url and IFSC code to request HTTP and store it in another variable.
  • Pass the above result URL to the get() function and apply json() function for the result of the get() function
  • Here, the.json() function is used to transmit data in webpages to json format allowing for well-structured output.
  • Print the bank, branch names using the above JSON data by passing the keys as BANK and BRANCH.
  • Here, all the details are stored as key-value pairs.
  • The Exit of the Program.

Below is the implementation:

# Import requests module using the import keyword
import requests 

# Give the URL of razorpay to send HTTP request and store it in a variable.
gvn_url = "https://ifsc.razorpay.com/"

# Give the IFSC code as user input using the input() function and
# store it in a variable.
gvn_IFSCcocde = input("Enter some random IFSC code: ")

# Add both the above given razorpay Url and IFSC code to request HTTP and 
# store it in another variable
rslt_url = gvn_url + gvn_IFSCcocde

# Pass the above result url to the get() function and apply json() function
# for the result of the get() function
# Here, the.json() function is used to transmit data in webpages to json format
# allowing for well-structured output.
retrivedata = requests.get(rslt_url).json()

# Print the bank, branch names using the above json data by passing the keys as BANK and BRANCH.
# Here, all the details are stored as key-value pairs.
bank_name = retrivedata['BANK']
branch_name = retrivedata['BRANCH']
print(bank_name, branch_name)

Output:

Enter some random IFSC code: SIBL0000008
South Indian Bank BANGALORE CITY