FastAPI mock service for Central Bank of Russia currency rates API
- Full mock implementation of CBR API endpoint
- Dynamic response generation based on request parameters
- Built-in request logging to SQLite database
- Automatic Swagger documentation
- Load testing support
-
Clone the repository:
git clone https://github.com/yourusername/cbr_mock.git cd cbr_mock -
Create and activate virtual environment:
- Linux/Mac:
python -m venv venv source venv/bin/activate - Windows:
python -m venv venv .\venv\Scripts\activate
- Linux/Mac:
-
Install dependencies:
pip install -r requirements.txt
- Development mode with auto-reload:
make run
- Production mode:
make prod
- Main endpoint:
GET /scripts/XML_daily.asp?date_req=DD/MM/YYYY - Healthcheck:
GET /healthcheck - Request log:
GET /requests-log - Reset test state:
POST /reset-test-state
- Successful request:
curl "http://localhost:8000/scripts/XML_daily.asp?date_req=22/07/2025" - Force error response:
curl "http://localhost:8000/scripts/XML_daily.asp?date_req=22/07/2025&force_error=true"
- Run basic tests:
make test - Run load testing (requires locust):
make load-test
- Microservice architecture (FastAPI)
- Asynchronous interaction
- Unique data generation per test
- No hardcoded responses
- No headers usage
- Makefile with commands
- Swagger documentation
- Database integration (SQLite)
- Proto files (gRPC interface)
- Golang version