https://github.com/averageencoreenjoer/tron-wallet-info
Microservice for obtaining information about wallets in the Tron network. Allows you to get the TRX balance, bandwidth and energy by wallet address. Saves the history of queries in the database with pagination support. Implemented on FastAPI using SQLAlchemy ORM and TronPy.
https://github.com/averageencoreenjoer/tron-wallet-info
api blockchain crypto docker fastapi microservice pytest python3 sqlalchemy tron tronpy
Last synced: about 2 months ago
JSON representation
Microservice for obtaining information about wallets in the Tron network. Allows you to get the TRX balance, bandwidth and energy by wallet address. Saves the history of queries in the database with pagination support. Implemented on FastAPI using SQLAlchemy ORM and TronPy.
- Host: GitHub
- URL: https://github.com/averageencoreenjoer/tron-wallet-info
- Owner: averageencoreenjoer
- Created: 2025-07-22T13:40:34.000Z (11 months ago)
- Default Branch: main
- Last Pushed: 2025-07-26T16:04:29.000Z (11 months ago)
- Last Synced: 2025-08-03T18:15:39.492Z (11 months ago)
- Topics: api, blockchain, crypto, docker, fastapi, microservice, pytest, python3, sqlalchemy, tron, tronpy
- Language: Python
- Homepage:
- Size: 13.7 KB
- Stars: 1
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Tron Wallet Info Service
Microservice for obtaining information about wallets in the Tron network with saving the history of requests.
## Features
- 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
## Technologies
- Python 3.11
- FastAPI
- SQLAlchemy 2.0
- TronPy
- Pytest
- Docker
## Quick Start
### Without Docker
```bash
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
```
### With Docker
```bash
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
## Configuration
Create a `.env` file based on `.env.example`:
```bash
cp .env.example .env
```
Available environment variables:
- `DATABASE_URL` - Database URL (default: sqlite:///./tron_wallet.db)
- `TRON_NETWORK` - Tron network (shasta/mainnet)
## API Endpoints
### Getting wallet info
`POST /wallet-info`
```json
{
"address": "TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t"
}
```
Response example:
```json
{
"address": "TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t",
"trx_balance": 1000000,
"bandwidth": 500,
"energy": 200
}
```
### Getting request history
`GET /request-history?skip=0&limit=10`
Example answer:
```json
{
"count": 15,
"results": [
{
"id": 15,
"address": "TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t",
"trx_balance": 1000000,
"bandwidth": 500,
"energy": 200,
"created_at": "2023-10-05T12:00:00"
},
...
]
}
```
## Testing
```bash
# Running tests
pytest -v
# Running tests with coverage
pytest --cov=app --cov-report=html
```
## API documentation
After running the application, the documentation is available at:
- Swagger UI: http://localhost:8000/docs
- ReDoc: http://localhost:8000/redoc
## Using Docker
### Building an image
```bash
docker-compose build
```
### Starting a service
```bash
docker-compose up
```
### Stopping the service
```bash
docker-compose down
```
### To use PostgreSQL
Uncomment the db section in docker-compose.yml and set:
```env
DATABASE_URL=postgresql://tron:tronpass@db:5432/tron_db
```
## Database migrations
```bash
# Generating migrations
alembic revision --autogenerate -m "Description of changes"
# Applying migrations
alembic upgrade head
```