Monitor your Quicknode RPC credit usage and receive proactive alerts before hitting your limits. This tool uses the Admin API Usage endpoint to check your current billing period usage, predict end-of-month consumption, and send notifications through your preferred alerting channels.
- Real-time Usage Monitoring: Check current credit consumption against your plan limits
- Predictive Analytics: Forecasts monthly usage based on current consumption rate
- Days-Until-Limit Calculation: Know exactly when you'll hit your limit at the current rate
- Multi-Channel Alerting: Send alerts to Slack, PagerDuty, Discord, Opsgenie, Email, or custom webhooks
- Configurable Thresholds: Set warning (default 80%) and critical (default 95%) alert levels
- Overage Detection: Automatic critical alerts when overages occur
- Historical Data: View usage for any past billing period
- Detailed Breakdowns: Analyze usage by endpoint, chain, or RPC method
| Channel | Use Case | Setup Link |
|---|---|---|
| Slack | Team notifications via webhook | Create Webhook |
| PagerDuty | On-call alerting and incident management | Events API v2 |
| Discord | Team/community notifications | Server Settings > Integrations |
| Opsgenie | Alert management and escalation | API Key Management |
| Direct notifications via SendGrid | SendGrid API Keys | |
| Generic Webhook | Custom integrations (Zapier, n8n, etc.) | Any HTTP endpoint |
- Node.js 20+ (for native
fetchand--env-filesupport) - Quicknode account with a paid plan
- API key with
CONSOLE_RESTpermission (Create API Key)
-
Clone the repository:
git clone https://github.com/quiknode-labs/qn-guide-examples.git cd qn-guide-examples/admin-api/usage-alerting -
Install dependencies:
npm install
-
Configure environment:
cp .env.example .env
-
Add your API key to
.env:QUICKNODE_API_KEY=your_api_key_here -
Check your usage (no alerts sent):
npm run check
See your current usage and predictions without sending alerts:
npm run checkExample output:
=== Quicknode RPC Usage Report ===
Period: 2024-01-01 00:00:00 UTC - 2024-01-15 14:30:00 UTC
Timestamps: 1704067200 - 1705329000
Days in Period: 15 elapsed, 16 remaining
----------------------------------
Credits Used: 450,000
Credits Remaining: 550,000
Limit: 1,000,000
Current Usage: 45.0%
----------------------------------
PREDICTIONS
Daily Average: 30,000 credits/day
Projected Monthly: 930,000 credits (93.0%)
Status: On track to stay within limit
==================================
Thresholds: Warning=80%, Critical=95%
Would trigger: No alert
View usage for a specific month:
# Check December 2025
npm run history 2025-12
# Check month 6 of current year
npm run history 6Example output:
=== Quicknode RPC Usage Report (Historical) ===
Period: 2025-12-01 00:00:00 UTC - 2025-12-31 23:59:59 UTC
Timestamps: 1733011200 - 1735689599
------------------------------------------------
Credits Used: 1,234,567
Limit: No limit set
================================================
Analyze your usage with granular breakdowns:
# Usage by endpoint
npm run by-endpoint
# Usage by blockchain
npm run by-chain
# Usage by RPC method
npm run by-method
# All detailed reports at once
npm run detailedBy Chain Example:
=== Quicknode RPC Usage by Chain ===
------------------------------------
sol 496,830 credits 48.8% ██████████
matic 284,260 credits 27.9% ██████
eth 5,700 credits 0.6% ▏
base 4,990 credits 0.5% ▏
------------------------------------
TOTAL 791,780 credits
====================================
By Method Example:
=== Quicknode RPC Usage by Method ===
-------------------------------------
getaccountinfo Archive 276,600 credits 27.2% █████ [Archive]
eth_getlogs Archive 224,130 credits 22.0% ████ [Archive]
gettransaction Archive 184,800 credits 18.2% ████ [Archive]
-------------------------------------
TOTAL 1,017,860 credits (37 methods)
=====================================
Check usage and send alerts if thresholds are exceeded:
npm run dev # Development
npm start # Production (after npm run build)| Variable | Required | Default | Description |
|---|---|---|---|
QUICKNODE_API_KEY |
Yes | - | Your Quicknode API key |
ALERT_THRESHOLD_WARNING |
No | 80 | Warning threshold (%) |
ALERT_THRESHOLD_CRITICAL |
No | 95 | Critical threshold (%) |
Alerts trigger based on:
- Current usage exceeds threshold
- Projected usage will exceed limit (warning if >3 days away, critical if ≤3 days)
- Overages detected (always critical)
Add the relevant variables to your .env file:
SLACK_WEBHOOK_URL=https://hooks.slack.com/services/XXX/YYY/ZZZPAGERDUTY_ROUTING_KEY=your_routing_keyDISCORD_WEBHOOK_URL=https://discord.com/api/webhooks/XXX/YYYOPSGENIE_API_KEY=your_api_keySENDGRID_API_KEY=your_api_key
SENDGRID_FROM_EMAIL=alerts@yourdomain.com
ALERT_EMAIL_RECIPIENTS=team@example.com,oncall@example.comGENERIC_WEBHOOK_URL=https://your-webhook-endpoint.comPayload format:
{
"timestamp": "2024-01-15T10:30:00.000Z",
"source": "quicknode-usage-monitor",
"severity": "warning",
"title": "Quicknode RPC Usage Warning",
"message": "Your Quicknode RPC usage has reached 82.5% of your limit...",
"data": {
"usage_percent": 82.5,
"credits_used": 825000,
"credits_remaining": 175000,
"limit": 1000000,
"overages": 0
},
"prediction": {
"daily_average": 55000,
"projected_monthly": 1705000,
"projected_percent": 170.5,
"days_until_limit": 3,
"projected_overages": 705000
}
}This script is designed to run on a schedule. Options include:
# Check every hour
0 * * * * cd /path/to/usage-alerting && node dist/index.js >> /var/log/quicknode-alerts.log 2>&1
# Check every 6 hours
0 */6 * * * cd /path/to/usage-alerting && node dist/index.jsname: Quicknode Usage Check
on:
schedule:
- cron: '0 */6 * * *' # Every 6 hours
workflow_dispatch: # Manual trigger
jobs:
check-usage:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '20'
- run: npm ci
- run: npm run build
- run: npm start
env:
QUICKNODE_API_KEY: ${{ secrets.QUICKNODE_API_KEY }}
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
ALERT_THRESHOLD_WARNING: 80
ALERT_THRESHOLD_CRITICAL: 95Package as a Lambda function:
npm run build
zip -r function.zip dist/ node_modules/ package.jsonUse CloudWatch Events to trigger on a schedule.
For teams using Prometheus/Grafana, this package includes a custom exporter. See PROMETHEUS.md for details.
This tool uses the following Admin API endpoints:
| Endpoint | Description |
|---|---|
| /v0/usage/rpc | Overall RPC usage and limits |
| /v0/usage/rpc/by-endpoint | Usage breakdown by endpoint |
| /v0/usage/rpc/by-chain | Usage breakdown by blockchain |
| /v0/usage/rpc/by-method | Usage breakdown by RPC method |