A Cloudflare Worker service that aggregates cryptocurrency pricing data from multiple sources.
├── config
│ ├── chains.ts
│ └── hosted-scalar.ts
├── index.ts
├── middleware
│ ├── auth.ts
│ └── security.ts
├── prices.ts
├── services
│ ├── birdeye.ts
│ ├── codex.ts
│ ├── coinpaprika.ts
│ ├── defillama.ts
│ ├── dexscreener.ts
│ └── geckoterminal.ts
└── types.ts
- Multi-source price aggregation
- Chain-agnostic design
- Historical price lookups
- API key authentication
- Request rate limiting
Currently supported:
- Birdeye (requires API key)
- Codex (requires API key)
- GeckoTerminal [CoinGecko] (30 address limit per request)
- Dexscreener (30 address limit per request)
- DeFiLlama
Coming soon:
- Dexview
- Coinpaprika
- Coinmarketcap
- Install required packages:
bun add zod hono openapi3-ts @scalar/hono-api-reference @hono/zod-validator @types/bun
- (Optional) Configure dprint for code formatting:
bun add dprint && touch dprint.json && dprint config add typescript
For more information about dprint, visit the official documentation.
- Set up Cloudflare secrets:
bunx wrangler secret put BIRDEYE_API
bunx wrangler secret put CODEX_API
bunx wrangler secret put COINMARKETCAP_API
- Create KV Namespace for API key authentication:
bunx wrangler kv:namespace create "API_KEYS"
confirm output and annotate namespace for future reference later, if ever needed
Note: (Not as secure as using Cloudflare Secrets, which should be implemented for actual production usage)
-
Add the generated namespace ID to your
wrangler.toml
-
Add an API key to the KV store:
bunx wrangler kv:key put --binding=API_KEYS "your-api-key-here" "true"
curl -H "X-API-Key: {YOUR_API_KEY}" https://{YOUR_WORKER_DOMAIN}/health
Basic price lookup:
curl -X POST \
-H "X-API-Key: {YOUR_API_KEY}" \
-H "Content-Type: application/json" \
-d '{"chainId": 1, "tokenAddress": "0x41545f8b9472d758bb669ed8eaeeecd7a9c4ec29"}' \
https://{YOUR_WORKER_DOMAIN}/api/prices
Historical price lookup:
curl -X POST \
-H "X-API-Key: {YOUR_API_KEY}" \
-H "Content-Type: application/json" \
-d '{
"chainId": 1,
"tokenAddress": "0x41545f8b9472d758bb669ed8eaeeecd7a9c4ec29",
"timestamp": 1732084737
}' \
https://{YOUR_WORKER_DOMAIN}/api/prices
interface PriceResponse {
price: number;
timestamp: number;
source: string;
}
- Clone the repository
- Install dependencies with
bun install
- Create a
.dev.vars
file for local development:
BIRDEYE_API=your_birdeye_api_key
CODEX_API=your_codex_api_key
COINMARKETCAP_API=your_coinmarketcap_api_key
- Run locally with
bun run dev
- Deploy with
bun run deploy
- Fork the repository
- Create a feature branch
- Commit your changes
- Push to the branch
- Create a Pull Request
MIT License - See LICENSE file for details