Microservice for obtaining information about wallets in the Tron network with saving the history of requests.
- Getting information about the wallet (TRX balance, bandwidth, energy)
- Saving the history of requests in the DB
- Viewing history with pagination
- Full API documentation (Swagger UI)
- Unit and integration tests
- Docker support
- Python 3.11
- FastAPI
- SQLAlchemy 2.0
- TronPy
- Pytest
- Docker
git clone https://github.com/averageencoreenjoer/tron-wallet-info
cd tron_wallet_info
python -m venv venv
source venv/bin/activate
pip install -r requirements.txt
uvicorn app.main:app --reload
git clone https://github.com/averageencoreenjoer/tron-wallet-info
cd tron_wallet_info
docker-compose up --build
The application will be available at: http://localhost:8000
Create a .env
file based on .env.example
:
cp .env.example .env
Available environment variables:
DATABASE_URL
- Database URL (default: sqlite:///./tron_wallet.db)TRON_NETWORK
- Tron network (shasta/mainnet)
POST /wallet-info
{
"address": "TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t"
}
Response example:
{
"address": "TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t",
"trx_balance": 1000000,
"bandwidth": 500,
"energy": 200
}
GET /request-history?skip=0&limit=10
Example answer:
{
"count": 15,
"results": [
{
"id": 15,
"address": "TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t",
"trx_balance": 1000000,
"bandwidth": 500,
"energy": 200,
"created_at": "2023-10-05T12:00:00"
},
...
]
}
# Running tests
pytest -v
# Running tests with coverage
pytest --cov=app --cov-report=html
After running the application, the documentation is available at:
- Swagger UI: http://localhost:8000/docs
- ReDoc: http://localhost:8000/redoc
docker-compose build
docker-compose up
docker-compose down
Uncomment the db section in docker-compose.yml and set:
DATABASE_URL=postgresql://tron:tronpass@db:5432/tron_db
# Generating migrations
alembic revision --autogenerate -m "Description of changes"
# Applying migrations
alembic upgrade head