A lightweight Express.js server that provides cryptocurrency price feeds with support for multiple fiat currencies. The server caches prices using Redis and updates them periodically via the Coinranking API.
The primary repo for this project is at: https://github.com/Panmoni/yapbay.
- Real-time USDC pricing in multiple currencies (USD, EUR, COP, NGN, VES)
- Redis caching for improved performance
- 15-minute automatic price updates
- Custom handling for VES (Venezuelan Bolivar) using hardcoded rates
- RESTful API endpoint for price queries
- Node.js
- Redis server
- Coinranking API key
- Clone the repository
- Install dependencies:
npm install- Create a
.envfile with the following variables:
PORT=4000
REDIS_URL=redis://localhost:6379
COINRANKING_API_KEY=your_api_key_here
HARDCODED_VES_USD=103.99
CR_USDC_UUID=aKzUVe4Hh_CON
CR_COP_UUID=Y7N-jnLhqYiW
CR_NGN_UUID=znnRJjGM4nVb- Start the Redis server
- Run the application:
npm startThis service is deployed using Podman Quadlets, which provides systemd integration for containerized services.
The deployment uses a Pod structure where the pricing server and Redis share a network namespace:
- Pod:
pricing- Provides shared network and port exposure - Redis Container: Cache service accessible at
localhost:6379within the pod - Pricing Server Container: Main application service
The deployment consists of three Quadlet files located in the deploy/ directory of this repository:
pricing.pod- Pod definition with exposed ports (4000 for API, 6379 for Redis)redis.container- Redis cache servicepricing-server.container- Pricing server application
See deploy/README.md for installation instructions.
# Check service status
systemctl --user status pricing-server.service
systemctl --user status redis.service
# View logs
journalctl --user -u pricing-server.service -f
journalctl --user -u redis.service -f
# Restart services
systemctl --user restart pricing-server.service
systemctl --user restart redis.service
# Enable auto-start on boot
systemctl --user enable pricing-server.service redis.service
# Stop services
systemctl --user stop pricing-server.service redis.service# View running containers
podman ps
# View pod structure
podman pod ps
# View container logs directly
podman logs pricing-server
podman logs redisThe services are configured with Restart=always, so they will automatically restart on failure.
GET /price
Query Parameters:
token: Cryptocurrency token (e.g., USDC)fiat: Fiat currency (USD, EUR, COP, NGN, VES)
Example:
GET /price?token=USDC&fiat=USD
Response:
{
"status": "success",
"data": {
"price": "1.00",
"timestamp": 1679890000
}
}curl http://localhost:4000/api-usage curl http://localhost:4000/price\?token\=USDC\&fiat\=NGN\&source\=binance\&type\=BUY curl http://localhost:4000/price\?token\=USDC\&fiat\=VES
x