OilPriceAPI Docs
GitHub
GitHub
  • Interactive Explorer

    • Interactive API Explorer
  • Price Data

    • API Reference
    • Get Latest Prices
    • Historical Prices
    • Batch Prices
    • Excel Latest Price Gateway
    • Price Widget Endpoints
    • Price Utility Endpoints
    • Natural Gas Intelligence
  • Commodities

    • List Commodities
    • Get Commodity Details
  • AI Agents (MCP)

    • Get Market Brief
    • Subscriptions / Watches
    • Agent Subscriptions with MCP
  • Marine Fuels

    • Marine Fuel API
    • List Marine Fuel Ports
    • Get Port Details with Prices
    • Bunker Fuels
    • Maritime Fuels
  • Premium Endpoints

    • All Prices API - One Call, All Commodities
    • Cushing Oil Storage Intelligence API
    • Drilling Intelligence API
    • Marine Fuels API
    • ICE Brent Futures API
    • Benchmark Close
    • Aviation Fuel Pilot
  • Spreads & Margins

    • Spreads & Margins
    • Crack Spreads
    • Basis Spreads
    • Refining Margins
    • Curve Structure
    • Physical Premiums
  • Market Indicators

    • Market Indicators
    • Fuel Switching
    • Price Context
    • Storage Analytics
    • CFTC Positioning
    • Congressional Trades
    • Market Annotations
  • Futures

    • Futures API
    • ICE Brent Futures
    • ICE WTI Futures
    • ICE Gas Oil Futures
    • NYMEX Natural Gas Futures
    • ICE EUA Carbon Futures
    • EU Carbon Futures
    • TTF Gas Futures
    • LNG JKM Futures
    • UK Carbon Futures
  • Dark Data (Premium)

    • Energy Intelligence API
    • Rig Counts
    • Well Permits
    • Well Production Beta
    • Oil Inventories
    • OPEC Production
    • Drilling Productivity
    • Forecasts (STEO)
  • Well Production (Beta)

    • Well Production Data
    • Well Production API Reference
  • Analytics

    • Analytics API
  • Webhooks API

    • Webhooks API Reference
    • Webhook Endpoint Reference
  • Alerts

    • Price Alerts API
  • Account & Billing

    • Account API
    • API Keys
    • Subscriptions
    • Organizations

API Keys

Manage API keys for authenticated account workflows.

Endpoints

MethodEndpointDescription
GET/v1/api-keysList API keys
POST/v1/api-keysCreate a new API key
DELETE/v1/api-keys/:idRevoke an API key
POST/v1/api-keys/:id/rollRoll a key

List Keys

curl "https://api.oilpriceapi.com/v1/api-keys" \
  -H "Authorization: Token YOUR_API_KEY"
{
  "status": "success",
  "data": [
    {
      "id": "key_123",
      "name": "Production",
      "prefix": "opa_live_",
      "last_used_at": "2026-07-15T14:30:00Z",
      "created_at": "2026-06-01T10:00:00Z"
    }
  ]
}

Create Key

curl -X POST "https://api.oilpriceapi.com/v1/api-keys" \
  -H "Authorization: Token YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"name":"Staging"}'

New keys are shown once. Store them immediately in your secret manager.

Roll Key

curl -X POST "https://api.oilpriceapi.com/v1/api-keys/key_123/roll" \
  -H "Authorization: Token YOUR_API_KEY"

Rolling creates a replacement secret for the selected key. Treat the old secret as revoked unless your account has an explicitly configured grace window.

Delete Key

curl -X DELETE "https://api.oilpriceapi.com/v1/api-keys/key_123" \
  -H "Authorization: Token YOUR_API_KEY"

Security Checklist

  • Use separate keys per environment.
  • Never expose keys in frontend JavaScript.
  • Rotate keys on a regular schedule and after staff/vendor changes.
  • Monitor /v1/account and usage dashboards after every roll.

Error Cases

StatusWhen
401Missing or invalid API key
403Key management is not allowed for this account
404Key id not found
422Name or request body invalid
Last Updated: 7/16/26, 1:53 PM
Prev
Account API
Next
Subscriptions