This project is a Python web API service built with Flask that supports GraphQL queries for retrieving bank branch data from a CSV file.
The purpose of this API is to provide access to information about bank branches. It allows users to query and retrieve data about various bank branches using GraphQL queries.
- The API is hosted on Flask, and the GraphQL endpoint is available at
/gql
. Users can send GraphQL queries to this endpoint.
- The API reads data from a CSV file named
bank_branches.csv
. This file contains information about bank branches, including IFSC codes, branch names, bank names, addresses, cities, districts, states, and more.
-
Users can use GraphQL queries to request specific data about bank branches. An example query is provided below:
query { branches { edges { node { branch bank { name } ifsc } } } }
This query requests information about bank branches, including the branch name, the name of the bank it belongs to, and the IFSC code.
- The implementation is based on Flask and Flask-GraphQL, which is a Flask extension for creating GraphQL APIs.
- Code snippets for loading data from the CSV file and returning it as a GraphQL response have been provided.
Before you begin, ensure you have met the following requirements:
- Python (version 3.6 or higher) installed on your system.
- Python virtual environment set up.
-
Clone this repository to your local machine:
git clone https://github.com/theakashshukla/bank-api.git
-
Navigate to the project folder:
cd bank-api
-
Create a virtual environment:
python -m venv venv
-
Activate the virtual environment:
-
On Windows:
venv\Scripts\activate
-
On macOS and Linux:
source venv/bin/activate
-
-
Install the required Python packages:
pip install -r requirements.txt
OR
pip install Flask Flask-GraphQL graphene
-
Start the Flask app:
python app.py
The app will run at
http://localhost:5000
. -
Open a web browser and navigate to
http://localhost:5000/gql
. This will open the GraphiQL interface. -
Use the GraphiQL interface to execute GraphQL queries to retrieve bank branch data.
Sample GraphQL Query:
query { branches { ifsc branch bank } }
Press the "Play" button to execute the query and view the results.
The data loading logic in app.py
reads data from the bank_branches.csv
file. Ensure that the CSV file is located in the same directory as app.py
and follows the correct format:
ifsc,bank_id,branch,address,city,district,state,bank_name
- Fork the repository.
- Create a new branch for your feature or bug fix.
- Make your changes and commit them.
- Push your changes to your fork.
- Submit a pull request to the original repository.
This project is licensed under the MIT License - see the LICENSE file for details.