A REST API service that provides information about Taraxa blockchain snapshots stored in Google Cloud Storage. The service fetches snapshot data from a GCP bucket and returns the latest snapshots for different networks (mainnet, testnet, devnet) and types (full, light).
- Multi-network support: mainnet, testnet, devnet
- Snapshot types: full and light snapshots
- Latest snapshot selection: Returns the most recent snapshot based on block number and timestamp
- Health and readiness probes: Kubernetes-ready endpoints
- Caching: Built-in caching to reduce API calls to GCP
- Docker ready: Multi-stage Docker build with security best practices
- Kubernetes ready: Complete Helm chart for deployment
- CI/CD pipeline: GitHub Actions with automated testing, building, and security scanning
GET /?network={network}
Parameters:
network(required): The blockchain network (mainnet,testnet, ordevnet)
Response:
{
"full": {
"block": 19547931,
"timestamp": "2025-07-06 06:27",
"url": "https://storage.googleapis.com/taraxa-snapshot/mainnet-full-db-block-19547931-20250706-062734.tar.gz"
},
"light": {
"block": 19546050,
"timestamp": "2025-07-06 04:58",
"url": "https://storage.googleapis.com/taraxa-snapshot/mainnet-light-db-block-19546050-20250706-045815.tar.gz"
}
}GET /health
Returns the health status of the service.
GET /ready
Verifies the service can connect to the GCP bucket and is ready to serve requests.
The application can be configured using environment variables:
| Variable | Default | Description |
|---|---|---|
PORT |
8080 |
HTTP server port |
GCP_BUCKET_NAME |
taraxa-snapshot |
GCP bucket name |
GCP_BUCKET_URL |
https://storage.googleapis.com/storage/v1/b/taraxa-snapshot/o |
GCP bucket API URL |
- Go 1.24.3 or later
- Docker (optional)
- Kubernetes cluster with Helm (for deployment)
-
Clone the repository
git clone https://github.com/taraxa/snapshots-api.git cd snapshots-api -
Install dependencies
make deps
-
Run tests
make test -
Run the application
make run
-
Test the API
# In another terminal make test-api
Run make help to see all available targets:
Available targets:
help Show this help message
build Build the Go application
test Run all tests
test-coverage Generate test coverage report
run Run the application locally
clean Clean build artifacts
fmt Format Go code
vet Run go vet
deps Download and tidy dependencies
docker-build Build Docker image
docker-run Run Docker container
helm-lint Lint Helm chart
helm-template Render Helm templates
helm-install Install Helm chart (requires kubectl context)
helm-upgrade Upgrade Helm chart (requires kubectl context)
helm-uninstall Uninstall Helm chart (requires kubectl context)
dev-setup Setup development environment
dev-test Run development tests (format, vet, test)
ci-test Run CI-like tests locally
test-api Test API endpoints (requires running server)make docker-buildmake docker-rundocker run -p 8080:8080 \
-e PORT=8080 \
-e GCP_BUCKET_NAME=taraxa-snapshot \
-e GCP_BUCKET_URL=https://storage.googleapis.com/storage/v1/b/taraxa-snapshot/o \
snapshots-api:latest-
Install the chart
helm install snapshots-api ./charts/snapshots-api
-
Install with custom values
helm install snapshots-api ./charts/snapshots-api \ --set replicaCount=3 \ --set resources.requests.memory=256Mi \ --set ingress.enabled=true \ --set ingress.hosts[0].host=snapshot.taraxa.io
-
Upgrade the deployment
helm upgrade snapshots-api ./charts/snapshots-api
Key Helm values you can override:
# Number of replicas
replicaCount: 2
# Docker image configuration
image:
repository: ghcr.io/taraxa/snapshots-api
tag: "latest"
# Resource limits
resources:
limits:
cpu: 500m
memory: 512Mi
requests:
cpu: 100m
memory: 128Mi
# Ingress configuration
ingress:
enabled: true
hosts:
- host: snapshot.taraxa.io
paths:
- path: /
pathType: Prefix
# Environment variables
env:
GCP_BUCKET_NAME: "taraxa-snapshot"
GCP_BUCKET_URL: "https://storage.googleapis.com/storage/v1/b/taraxa-snapshot/o"The project includes a comprehensive GitHub Actions pipeline that:
- Runs all tests with coverage reporting
- Performs code quality checks (formatting, vetting, static analysis)
- Lints Helm charts
- Builds and pushes Docker images to GitHub Container Registry
- Runs security scans with Trivy
- Generates Software Bill of Materials (SBOM)
- Creates GitHub releases with deployment instructions
- Tags Docker images with version numbers
- Vulnerability scanning with Trivy
- SARIF upload to GitHub Security tab
- SBOM generation for supply chain security
- Multi-architecture builds (amd64, arm64)
.
├── cmd/server/ # Application entrypoint
├── internal/
│ ├── api/ # HTTP handlers and routing
│ ├── config/ # Configuration management
│ ├── models/ # Data models
│ ├── parser/ # Snapshot filename parsing
│ └── service/ # Business logic
├── charts/snapshots-api/ # Helm chart
├── .github/workflows/ # CI/CD pipelines
├── Dockerfile # Container definition
└── Makefile # Development tasks
- API receives request with network parameter
- Service checks cache for recent data
- If cache miss, fetches snapshot list from GCP bucket
- Parser extracts metadata from snapshot filenames
- Service identifies latest snapshots by block number/timestamp
- Response formatted and returned with caching headers
The project includes comprehensive test coverage:
- Unit tests for all packages
- Integration tests for API endpoints
- Mock services for external dependencies
- Helm chart testing with template validation
Run tests with coverage:
make test-coverage/health- Basic service health (always returns 200 if service is running)/ready- Readiness check (verifies GCP bucket connectivity)
- Structured logging for all requests and errors
- Request/response logging with status codes
- Error logging with context
Ready for integration with Prometheus/metrics collection:
- HTTP request duration and status codes (via ingress controller)
- Pod resource usage (via Kubernetes metrics)
- Custom application metrics can be added
- Container runs as non-root user
- Read-only root filesystem
- Security context restrictions
- Regular dependency updates via Dependabot
- Vulnerability scanning in CI
- HTTP caching headers set (5-minute cache)
- Internal caching (5-minute TTL)
- Efficient snapshot parsing and selection
- Horizontal pod autoscaling support
- Health and readiness probes
- Graceful shutdown handling
- Resource limits and requests defined
- Multiple replica support
- Fork the repository
- Create a feature branch
- Make your changes with tests
- Run
make dev-testto verify all checks pass - Submit a pull request
This project is licensed under the MIT License - see the LICENSE file for details.
For questions and support:
- GitHub Issues: Create an issue
- Email: [email protected]