Utilized as the framework for building this banking API, enabling RESTful endpoints and comprehensive documentation via Swagger UI and ReDoc.
Serves as the programming language for the API implementation, with specific version requirements (3.8+) noted for compatibility.
Provides the database backend with indexed CustomerOID fields, supporting all portfolio and customer data storage with proper referential integrity.
Offers interactive API documentation through a UI available at /docs, allowing developers to explore and test all available endpoints.
Dummy Bank API Documentation
A comprehensive FastAPI-based banking API designed for portfolio analysis and customer data management, optimized for CustomerOID-based operations and MCP (Model Context Protocol) server integration.
🚀 Quick Start
Prerequisites
Python 3.8+
Conda environment (recommended)
Installation & Setup
Set up environment:
Install dependencies:
Start the API server:
Access API documentation:
Swagger UI: http://127.0.0.1:3000/docs
ReDoc: http://127.0.0.1:3000/redoc
📋 API Overview
Base URL
Core Features
CustomerOID-centric design: All operations are based on unique Customer IDs (UUID format)
Comprehensive portfolio data: Assets, transactions, bank accounts, spending patterns, derivatives
Customer lifecycle management: Registration, deletion, and data retrieval
MCP server integration ready: Optimized responses for analysis agents
SQLite database: Local file-based storage with indexed CustomerOID fields
🔑 CustomerOID Format
The API uses UUID format for CustomerOIDs:
Format:
550e8400-e29b-41d4-a716-446655440000
Generation: Automatic UUID generation for new customers
Validation: Strict UUID format validation with backward compatibility
📊 Data Models
User
customer_oid
(UUID): Unique customer identifiername
(string): Customer name
Asset Holdings
Asset type, symbol, quantity, current value
Market data and performance metrics
Bank Accounts
Account details, balances, institution information
Multiple accounts per customer supported
Transactions
Transaction history with amounts, dates, descriptions
Categorized for analysis
Spending Patterns
Spending categories and amounts
Useful for financial behavior analysis
Derivative Transactions
Options, futures, and other derivative instruments
Advanced portfolio components
🛠 API Endpoints
Customer Management
GET /customers
List all registered customers.
Response:
POST /register-customer
Register a new customer in the system.
Request Body:
Response:
Features:
Auto-generates UUID if
customer_oid
not providedValidates name (minimum 2 characters)
Prevents duplicate registrations
Returns comprehensive error messages
DELETE /customer/{customer_oid}
Delete a customer and all associated data.
⚠️ WARNING: This permanently deletes all portfolio data for the customer.
Response:
GET /customer/{customer_oid}/exists
Quick check if a CustomerOID exists in the system.
Response:
Portfolio Data
GET /user-portfolio/{customer_oid}
Get comprehensive portfolio data for a customer.
Response Structure:
System Health
GET /health
Health check endpoint for monitoring.
Response:
🗄 Database Schema
Tables
users: Customer information with UUID CustomerOID (indexed)
assets: Investment holdings per customer
bank_accounts: Banking account details
institutions: Bank and financial institution data
transactions: Transaction history
spending: Spending pattern data
derivative_transactions: Derivative instrument trades
Key Features
Indexed CustomerOID: All tables indexed on
customer_oid
for fast queriesReferential integrity: Proper foreign key relationships
SQLModel ORM: Type-safe database operations
Automatic seeding: Sample data for testing and development
🧪 Testing
Test Files Included
test_api.py
: Comprehensive API testingtest_registration.py
: User registration workflow testingreset_database.py
: Database reset and reseeding
Running Tests
🔧 Configuration
Environment Variables
Port: Default 3000 (configurable)
Host: Default 127.0.0.1
Database: SQLite file
banking.db
Sample Data
The API includes comprehensive sample data for 5 customers:
Complete portfolio data
Multiple asset types
Various transaction patterns
Diverse spending categories
Derivative instruments
🎯 MCP Server Integration
This API is optimized for MCP (Model Context Protocol) server integration:
Key Features for MCP
CustomerOID-centric design: Easy customer identification
Comprehensive data structure: All portfolio data in single endpoint
Analysis-ready format: Pre-calculated summaries and metrics
Efficient queries: Indexed database operations
Standardized responses: Consistent JSON structure
Recommended MCP Usage
Customer Discovery: Use
/customers
to list available customersPortfolio Analysis: Use
/user-portfolio/{customer_oid}
for complete dataCustomer Management: Use registration/deletion endpoints for lifecycle management
Health Monitoring: Use
/health
for system status
🚨 Error Handling
Common Error Codes
400: Invalid CustomerOID format or validation errors
404: Customer not found
409: Duplicate customer registration
500: Internal server errors
Error Response Format
🔄 Development Workflow
Making Changes
Edit code: Modify
main.py
ordb.py
Restart server: Server restart required for validation changes
Test changes: Run test scripts to verify functionality
Reset data: Use reset script if database schema changes
Adding New Customers
📝 Best Practices
CustomerOID Management
Always use UUID format for new customers
Validate CustomerOID before database operations
Use the provided validation function consistently
Database Operations
Use dependency injection for database sessions
Implement proper error handling and rollbacks
Close sessions properly to prevent leaks
API Design
Follow RESTful conventions
Provide comprehensive error messages
Include validation for all inputs
Document all endpoints clearly
🤝 Contributing
Follow the existing code structure
Add tests for new functionality
Update documentation for API changes
Ensure CustomerOID validation is maintained
Test with sample data before deployment
📄 License
This is a dummy/example implementation for development and testing purposes.
Need help? Check the Swagger documentation at http://127.0.0.1:3000/docs when the server is running.
This server cannot be installed
A FastAPI-based banking API designed for portfolio analysis and customer data management, enabling MCP server integration with CustomerOID-based operations for financial data processing.
Related MCP Servers
- -securityFlicense-qualityAn MCP server implementation that integrates with Angle One APIs to provide standardized access to financial market data, trading operations, and portfolio management.Last updated -
- AsecurityAlicenseAqualityAn MCP server that provides comprehensive financial insights and analysis by leveraging real-time market data, news, and advanced analytics for stocks, options, financial statements, and economic indicators.Last updated -1746PythonMIT License
- -securityFlicense-qualityAn MCP server that enables interaction with the OpenFIGI API, allowing users to map securities to financial instrument identifiers through natural language.Last updated -
- -securityFlicense-qualityA FastMCP-based server that provides tools for analyzing stock market data, including concept sector strength, financial indicators, F10 information, market emotion indicators, and tracking limit-up stocks.Last updated -10