The Basic Banking API is a simple API that allows users to perform basic banking operations such as creating accounts, depositing and withdrawing money, checking balances, and transferring funds between accounts. This project is built using Python and the Flask framework, providing a RESTful interface to interact with bank accounts.
- Create a new account: Users can create a new account with an initial deposit.
- Deposit money: Users can deposit money into their account.
- Withdraw money: Users can withdraw money from their account (subject to balance).
- Check balance: Users can check the balance of their account.
- Transfer money: Users can transfer funds between two accounts.
Make sure you have Python 3.x installed. You will also need pip
to install dependencies.
-
Install Python (if not already installed):
-
Install dependencies:
- Flask is required for creating the API.
- You can install Flask using
pip
:
pip install flask
Clone the repository Clone the project repository to your local machine.
bash Copy code git clone https://github.com/your-username/banking-api.git cd banking-api Run the Application To start the API, navigate to the project directory and run the Flask application.
The following endpoints are available:
- Create Account (POST /accounts) Request Body:
{
"name": "John Doe",
"initial_deposit": 1000
}
Response:
{
"account_number": "123456789",
"name": "John Doe",
"balance": 1000
}
- Deposit Money (POST /accounts/{account_number}/deposit) Request Body:
{
"amount": 500
}
Response:
{
"message": "Deposit successful.",
"new_balance": 1500
}
- Withdraw Money (POST /accounts/{account_number}/withdraw) Request Body:
{
"amount": 200
}
Response:
{
"message": "Withdrawal successful.",
"new_balance": 1300
}
- Check Balance (GET /accounts/{account_number}/balance) Response:
{
"balance": 1300
}
- Transfer Money (POST /accounts/{sender_account_number}/transfer) Request Body:
{
"receiver_account_number": "987654321",
"amount": 300
}
Response:
{
"message": "Transfer successful.",
"sender_balance": 1000,
"receiver_balance": 1200
}