A basic FastAPI application with Redis to cache the query results.
- Docker
Export some environment variables:
export REDIS_PORT=6379
export REDIS_HOST=localhost
export REDIS_DB=0
CACHE_EXPIRATION_TIME=500
default value: 300
For "production usage", use a password:
export REDIS_PASSEWORD=youpasswordhere
docker run -d --name redis --env REDIS_PASSWORD -p 6379:6379 redis
If you want to have an "advanced interface" to watch the cache, use redis-stack:
docker run -d --name redis -p 6379:6379 -p 8001:8001 --env redis/redis-stack:latest
docker pull ghcr.io/charlesjudith/get-crypto-prices:0.0.7
docker run --env REDIS_HOST --env REDIS_PORT --env REDIS_DB --env REDIS_PASSWORD --env CACHE_EXPIRATION_TIME -p 8000:8000 ghcr.io/charlesjudith/get-crypto-prices:0.0.7
Check the API doc: http://127.0.0.1:8000/docs
Use the API: http://127.0.0.1:8000/price?symbols=cosmos¤cy=usd
Price on the last 24 hours is sent by default:
{"cosmos":{"usd":7.13,"usd_24h_change":3.6971000822019406}}
For Kubernetes deployment, there's an Helm chart: https://github.com/StakeLab-Zone/StakeLab/tree/main/Charts/coingecko-api
The demo deployed on Akash cloud is not up.