Billing API
Overview
The Billing API allows you to manage your subscription, view invoices, and update payment methods programmatically. All billing is handled securely through Stripe.
Plans & Pricing
The table below is sourced from the billing source of truth, GET /billing/plans — generated at build time and refreshed live in your browser — so it never drifts from the product. If the request fails it falls back to the last committed values.
| Plan | Price / mo | Requests / mo | Rate limit | Highlights |
|---|---|---|---|---|
| Developer | $19 | 10,000 | 60 / rolling 60s | Real-time prices, 1-year history, email support |
| Starter | $49 | 50,000 | 60 / rolling 60s | Webhooks, 5-year history |
| ProfessionalPopular | $99 | 250,000 | 60 / rolling 60s | Futures, WebSocket, market brief, priority support |
| Scale | $299 | 1,000,000 | 60 / rolling 60s | Everything in Professional + drilling intelligence, Slack support |
Need a custom SLA or volume beyond Scale? Contact us for Enterprise.
Endpoints
Get Available Plans
GET /billing/plans
No API key is needed. The response has one row per Stripe price, so each plan appears once for monthly billing (interval: "month") and once for annual billing (interval: "year"). Prices are in cents.
Each row carries an entitlements object. It is resolved from the plan's configured Stripe price, not from marketing copy, and it is the same set of entitlements the API enforces:
| Field | Values |
|---|---|
request_limit | Monthly request quota |
history_depth | latest_only, one_year, five_year or unlimited |
futures, websocket, webhooks, drilling_intelligence, well_permits | true or false |
The features.webhooks and features.websocket flags are derived from entitlements. Read entitlements when you need to know what a plan can access; features_list is display text.
Response (one row shown):
{
"status": "success",
"data": {
"plans": [
{
"id": "price_1TFvS4EKmJotBWfJbFJm0Mr5",
"stripe_price_id": "price_1TFvS4EKmJotBWfJbFJm0Mr5",
"name": "Developer",
"amount": 1900,
"formatted_amount": "$19.00",
"currency": "usd",
"interval": "month",
"api_request_limit": 10000,
"lookup_key": "developer_monthly",
"entitlements": {
"request_limit": 10000,
"history_depth": "one_year",
"futures": false,
"websocket": false,
"webhooks": false,
"drilling_intelligence": false,
"well_permits": false
},
"features": {
"requests_per_month": 10000,
"support_level": "email",
"api_keys": 3,
"webhooks": false,
"websocket": false
},
"tier_names": {
"current": "developer",
"display": "Developer"
},
"features_list": [
"10,000 API requests per month",
"1-year historical data (where available)",
"Email support",
"3 API keys"
]
}
]
}
}
Fields not shown above (description, price, metadata, interval_count and the rest of features) are also returned. Plans that are no longer sold are not listed. Subscribers on a retired price keep it and are not repriced.
Get Current Subscription
GET /billing/subscriptions/current
Response:
{
"subscription": {
"id": "sub_123",
"plan": "professional",
"status": "active",
"current_period_start": "2025-01-01T00:00:00Z",
"current_period_end": "2025-02-01T00:00:00Z",
"cancel_at_period_end": false,
"usage": {
"requests_used": 45000,
"requests_limit": 250000,
"percent_used": 18
}
}
}
Create Subscription
POST /billing/subscriptions
Request Body:
{
"plan_id": "professional",
"billing_period": "monthly"
}
Change Plan
POST /billing/subscriptions/change_plan
Request Body:
{
"new_plan_id": "professional"
}
Plan changes are prorated. Upgrades take effect immediately; downgrades take effect at the next billing period.
Cancel Subscription
POST /billing/subscriptions/cancel
Cancels at end of current billing period. You retain access until then.
Reactivate Subscription
POST /billing/subscriptions/reactivate
Reactivates a subscription scheduled for cancellation.
Payment Methods
List Payment Methods
GET /billing/payment_methods
Update Payment Method
PATCH /billing/payment_methods/update
Request Body:
{
"payment_method_id": "pm_card_visa_123"
}
Create Setup Intent
POST /billing/intents/setup
Returns a Stripe Setup Intent for adding a new payment method.
Invoices
List Invoices
GET /billing/invoices
Response:
{
"invoices": [
{
"id": "inv_123",
"amount": 7900,
"currency": "usd",
"status": "paid",
"period_start": "2025-01-01",
"period_end": "2025-01-31",
"pdf_url": "https://invoice.stripe.com/..."
}
]
}
Usage Tracking
Get Current Usage
GET /billing/usage
Response:
{
"period": {
"start": "2025-01-01T00:00:00Z",
"end": "2025-02-01T00:00:00Z"
},
"requests": {
"used": 45000,
"limit": 250000,
"remaining": 205000
},
"daily_breakdown": [
{ "date": "2025-01-15", "requests": 1500 },
{ "date": "2025-01-16", "requests": 1800 }
]
}
Customer Portal
For self-service billing management, redirect users to Stripe's Customer Portal:
POST /billing/customer-portal/sessions
Response:
{
"url": "https://billing.stripe.com/session/..."
}
Redirect users to this URL for:
- Update payment method
- View invoice history
- Download invoices
- Cancel subscription
Credit Packs (Pay-as-you-go)
For users who exceed their monthly limits:
List Available Credit Packs
GET /billing/credit_packs
Purchase Credits
POST /billing/credit_purchases
Request Body:
{
"pack_id": "10k_requests",
"quantity": 1
}
Webhook Events
Subscribe to billing webhooks for real-time updates:
| Event | Description |
|---|---|
subscription.created | New subscription started |
subscription.updated | Plan changed |
subscription.cancelled | Subscription cancelled |
invoice.paid | Payment successful |
invoice.payment_failed | Payment failed |
usage.limit_warning | 80% of limit reached |
usage.limit_exceeded | 100% of limit reached |
Questions?
Contact support@oilpriceapi.com for billing questions or custom Enterprise pricing.