Quick Start

https://api.energypriceapi.com/v1/latest?api_key=[API_KEY]

EnergypriceAPI

EnergypriceAPI provides a simple to use JSON-based REST API for energy prices and foreign exchange (forex) rates in 150+ world currencies. We provide affordable pricing, which makes our API perfect for businesses of any size including startups, online businesses, to large companies in need of live and/or historical financial data.

Our API can be deployed to power financial departments, mobile applications, and back-office systems around the world just to name a few use cases.

List of supported symbols

Definitions

Definition Description
API Key Uniquely assigned key to each API account to authenticate interactions with the API.
Symbol Three-letter currency code of a given currency.
Base Currency The currency to which exchange rates are relative to.
Quote Currency The currency an amount is converted to.

Energy Units

Brent Oil (BRENT) and WTI Crude Oil (WTI)

Expressed in per barrel (Bbl)

Gasoline (GASOLINE)

Expressed in per gallon (Gal)

Natural Gas (NATURALGAS)

Expressed in per Million British Thermal Units (MMBtu)

Live Rate Delay

Live exchange rate data is delayed based on your subscription plan.

Subscription Plan Delay
Free 24 hour updates
Basic 10 minute updates
Basic Plus 5 minute updates
Professional 60 second updates
Business 15 second updates

API Key

The EnergypriceAPI uses API keys to authenticate requests. You can view and manage your API key in the dashboard.

Please ensure to keep your API Key private as each request made with your API Key counts towards your account's plan limit.

To make a successful request, you must pass in your API Key into every request.

We provide two ways to pass in your API Key for every request. Method one is to append your API Key to the request URL. Method two is to pass in the API Key via the request header.

Query Parameter:
https://api.energypriceapi.com/v1/latest?api_key=API_KEY
Request Headers:
curl https://api.energypriceapi.com/v1/latest \
-H 'X-API-KEY: YOUR_API_KEY' \
-H 'Content-Type: application/json'

API Quota

Monitor your API usage through response headers included with each API request. These headers provide real-time information about your quota consumption and limits. Additionally, you can check your quota using the usage endpoint.

Response Headers

Key Description
X-API-CURRENT Number of requests consumed for the month.
X-API-QUOTA API quota limit for the month based on your account plan.

API Endpoints

We offer 9 customizable API endpoints, giving you access to different kinds of data. Below is a summary of all available endpoints, with detailed documentation for each in API Features.

// "symbols" - get list of all supported currencies
https://api.energypriceapi.com/v1/symbols

// "latest" - get real-time exchange rate data for all available/specific currencies
https://api.energypriceapi.com/v1/latest

// "historical" - get historical rates for a specific day
https://api.energypriceapi.com/v1/YYYY-MM-DD

// "hourly" - get hourly exchange rate data for a currency over a date range
https://api.energypriceapi.com/v1/hourly?currency=BRENT&start_date=2025-11-03&end_date=2025-11-03

// "ohlc" - get open, high, low, and close prices for a currency pair
https://api.energypriceapi.com/v1/ohlc?base=USD¤cy=WTI&date=2025-01-28

// "convert" - convert one currency to another based on real-time or historic exchange rate data
https://api.energypriceapi.com/v1/convert?from=USD&to=WTI&amount=100

// "timeframe" - request exchange rates for a specific period of time
https://api.energypriceapi.com/v1/timeframe?start_date=2021-01-01&end_date=2021-05-01

// "change" - request any currency change parameters (margin, percentage)
https://api.energypriceapi.com/v1/change?base=USD&start_date=2021-01-01&end_date=2021-05-01

// "usage" - check your API usage and quota for the current month
https://api.energypriceapi.com/v1/usage

API Error Codes

If your query fails, the API will return a 3-digit error-code and a plain text "info" property.

Example Error

{
  "success": false,
  "error": {
      "code": 104,
      "info": "Your monthly usage limit has been reached. Please upgrade your subscription plan."
  }
}

Common API Errors

Error Code Description
404 User requested a non-existent API function
101 User did not supply an API Key
102 User did not supply an access key or supplied an invalid access key
103 The user's account is not active. User will be prompted to get in touch with Customer Support
104 Too Many Requests
105 User has reached or exceeded his subscription plan's monthly API request allowance
201 User entered an invalid Base Currency [ latest, historical, timeframe, change ]
202 User entered an invalid from Currency [ convert ]
203 User entered invalid to currency [ convert ]
204 User entered invalid amount [ convert ]
205 User entered invalid date [ historical, convert, timeframe, change ]
206 Invalid timeframe [ timeframe, change ]
207 Timeframe exceeded 365 days [ timeframe ]
230 Hourly queries exceeding 2 days require a paid plan [ hourly ]
231 Hourly queries cannot exceed 7 days [ hourly ]
232 Cannot request hourly data for future dates [ hourly ]
233 The DATE_TYPE parameter is only available with a paid plan [ hourly ]
234 Hourly queries requires one currency [ hourly ]
235 Hourly queries allows only one currency [ hourly ]
300 The user's query did not return any results [ latest, historical, convert, timeframe, change ]

CORS (Cross-Origin Resource Sharing)

EnergypriceAPI supports Access-Control (CORS) headers. This means you will be able to use our API via Cross-Origin HTTPS Requests. Learn more.


Supported Symbols

This endpoint is used to get the list of the most up-to-date supported symbols. Learn more here.
Requests to this endpoint do not count towards your monthly API quota.

Example API Request

https://api.energypriceapi.com/v1/symbols
?api_key=[API_KEY]

Request Parameters

Parameter Description
api_key [Required] Your API Key. More details.

Example API Response

{
  "success": true,
  "symbols": {
      "AED": "UAE Dirham",
      "AFN": "Afghan Afghani",
      "ALL": "Albanian Lek",
      ...
  }
}

Response Attributes

Attribute Description
success Returns true or false depending if the API Request succeeded. If false, refer to API Errors.
symbols Key is supported currency, value is description of currency.

Live Rates

This endpoint will return real-time exchange rate data (delayed) depending on your subscription plan.

Example API Request

https://api.energypriceapi.com/v1/latest
?api_key=[API_KEY]
&base=USD
&currencies=BRENT,GASOLINE,NATURALGAS,WTI
https://api.energypriceapi.com/v1/latest
?api_key=[API_KEY]
&base=USD
&currencies=BRENT,GASOLINE,NATURALGAS,WTI
&math=multiply(value,1.005)

Request Parameters

Parameter Description
api_key [Required] Your API Key. More details.
base [optional] Specify a base currency. Base Currency will default to USD if this parameter is not defined.
currencies [optional] Specify a comma-separated list of currency codes to limit API responses to specified currencies. If this parameter is not defined, the API will return all supported currencies.
math [optional] Specify math operators to perform on the result. Use value to refer to the rates. Specify one or more of the mathematical operators add, subtract, multiply, and/or divide.

Example API Response

{
  "success": true,
  "base": "USD",
  "timestamp": 1672289920,
  "rates": {
      "BRENT": 0.01194215,
      "GASOLINE": 0.42227946,
      "NATURALGAS": 0.21235931
      "WTI": 0.01269938
  }
}

In the example API response, that means:
1 USD (Base) = 0.01194215 barrel (Bbl) Brent Crude Oil (Quote)
1 USD (Base) = 0.42227946 gallon (Gal) Gasoline (Quote)
1 USD (Base) = 0.21235931 MMBtu Natural Gas (Quote)
1 USD (Base) = 0.01269938 barrel (Bbl) WTI Crude Oil (Quote)

You can also express the reciprocal:
1/0.01194215 BRENT = 83.73 USD (Base) <=> 1 barrel (Bbl) Brent Crude Oil = $83.73
1/0.42227946 GASOLINE = 2.36 USD (Base) <=> 1 gallon (Gal) Gasoline = $2.36
1/0.21235931 NATURALGAS = 4.709 USD (Base) <=> 1 MMBtu Natural Gas = $4.709
1/0.01269938 WTI = 78.744 USD (Base) <=> 1 barrel (Bbl) WTI Crude Oil = $78.744

Response Attributes

Attribute Description
success Returns true or false depending if the API Request succeeded. If false, refer to API Errors.
base Returns base currency used for the request.
timestamp Returns the UNIX timestamp the given exchange rates were collected.
rates Returns exchange rate data for the currencies requested.

Historical Rates

This endpoint will return historical exchange rate data. The previous day's historical rates become available each day at 00:05 AM GMT. Use format YYYY-MM-DD or yesterday for the base url.

[Year-Month-Day]

Example API Request

https://api.energypriceapi.com/v1/2022-12-24
?api_key=[API_KEY]
&base=USD
&currencies=BRENT,GASOLINE,NATURALGAS,WTI
https://api.energypriceapi.com/v1/yesterday
?api_key=[API_KEY]
&base=USD
&currencies=BRENT,GASOLINE,NATURALGAS,WTI

Request Parameters

Parameter Description
api_key [Required] Your API Key. More details.
base [optional] Specify a base currency. Base Currency will default to USD if this parameter is not defined.
currencies [optional] Specify a comma-separated list of currency codes to limit API responses to specified currencies. If this parameter is not defined, the API will return all supported currencies.

Example API Response

{
  "success": true,
  "base": "USD",
  "timestamp": 1616558399,
  "rates": {
      "BRENT": 0.01191611,
      "GASOLINE": 0.41813012,
      "NATURALGAS": 0.19884669,
      "WTI": 0.01259652
  }
}

In the example API response, that means:
1 USD (Base) = 0.01191611 barrel (Bbl) Brent Crude Oil (Quote)
1 USD (Base) = 0.41813012 gallon (Gal) Gasoline (Quote)
1 USD (Base) = 0.19884669 MMBtu Natural Gas (Quote)
1 USD (Base) = 0.01259652 barrel (Bbl) WTI Crude Oil (Quote)

You can also express the reciprocal:
1/0.01191611 BRENT = 83.92 USD (Base) <=> 1 barrel (Bbl) Brent Crude Oil = $83.92
1/0.41813012 GASOLINE = 2.39 USD (Base) <=> 1 gallon (Gal) Gasoline = $2.39
1/0.19884669 NATURALGAS = 5.02 USD (Base) <=> 1 MMBtu Natural Gas = $5.02
1/0.01259652 WTI = 79.38 USD (Base) <=> 1 barrel (Bbl) WTI Crude Oil = $79.38

Response Attributes

Attribute Description
success Returns true or false depending if the API Request succeeded. If false, refer to API Errors.
base Returns base currency used for the request.
timestamp Returns the UNIX timestamp the given exchange rates were collected.
rates Returns exchange rate data for the currencies requested.

Currency Convert

This endpoint is used to convert any amount from one currency to another.

Example API Request

https://api.energypriceapi.com/v1/convert
?api_key=[API_KEY]
&from=USD
&to=WTI
&amount=100
&date=2022-12-24

Request Parameters

Parameter Description
api_key [Required] Your API Key. More details.
from [optional] Specify currency you would like to convert from. Base Currency will default to USD if this parameter is not defined.
to [Required] Specify currency you would like to convert to.
amount [Required] The amount to convert.
date [optional] Specify date to use historical midpoint value for conversion. Otherwise, it will use live exchange rate date with delay specified based on your subscription plan.

Example API Response

{
  "success": true,
  "query": {
      "from": "USD",
      "to": "WTI",
      "amount": 100
  },
  "info": {
      "quote": 0.01259652,
      "timestamp": 1671839999
  },
  "result": 1.25965208
}

Response Attributes

Attribute Description
success Returns true or false depending if the API Request succeeded. If false, refer to API Errors.
query -> from Returns currency converted from used for the request.
query -> to Returns currency converted to used for the request.
query -> amount Returns amount to convert.
info -> quote Returns the exchange rate used for the conversion.
info -> timestamp Returns the UNIX timestamp the given exchange rates were collected.
result Returns conversion result.

Timeframe Query

This endpoint is used to get historical rates for a specified time period (max range: 365 days).

Example API Request

https://api.energypriceapi.com/v1/timeframe
?api_key=[API_KEY]
&start_date=2022-12-23
&end_date=2022-12-24
&base=USD
&currencies=BRENT,GASOLINE,NATURALGAS,WTI

Request Parameters

Parameter Description
api_key [Required] Your API Key. More details.
start_date [Required] Specify the start date of your timeframe.
end_date [Required] Specify the end date of your timeframe.
base [optional] Specify a base currency. Base Currency will default to USD if this parameter is not defined.
currencies [optional] Specify a comma-separated list of currency codes to limit API responses to specified currencies. If this parameter is not defined, the API will return all supported currencies.

Example API Response

{
  "success": true,
  "base": "USD",
  "start_date": "2022-12-23",
  "end_date": "2022-12-24",
  "rates": {
      "2022-12-23": {
        "BRENT": 0.01187747,
        "GASOLINE": 0.41813012,
        "NATURALGAS": 0.19884669,
        "WTI": 0.01259652
      },
      "2022-12-24": {
        "BRENT": 0.01191611,
        "GASOLINE": 0.41813012,
        "NATURALGAS": 0.19884669,
        "WTI": 0.01259652
      },
  }

Response Attributes

Attribute Description
success Returns true or false depending if the API Request succeeded. If false, refer to API Errors.
base Returns base currency used for the request.
start_date Returns start date of your timeframe for the request.
end_date Returns end date of your timeframe for the request.
rates Returns exchange rate data for the currencies requested.

Change Query

This endpoint is used to request the change (percentage) of one of more currencies, relative to a base currency with a specific time-frame (optional).

The API will return change values of the specified start_date and end_date.

Example API Request

https://api.energypriceapi.com/v1/change
?api_key=[API_KEY]
&start_date=2022-12-22
&end_date=2022-12-24
&base=USD
&currencies=BRENT

Request Parameters

Parameter Description
api_key [Required] Your API Key. More details.
start_date [Required] Specify the start date of your timeframe.
end_date [Required] Specify the end date of your timeframe.
base [optional] Specify a base currency. Base Currency will default to USD if this parameter is not defined.
currencies [optional] Specify a comma-separated list of currency codes to limit API responses to specified currencies. If this parameter is not defined, the API will return all supported currencies.
date_type [optional] Specify "recent", "yesterday", "week", "month", or "year" to retrieve the rate change for the corresponding time period. If provided, this parameter overrides "start_date" and "end_date".

  • recent: Calculates change from yesterday's closing rate to the current rate (subject to your plan's delay)
  • yesterday: Calculates change from start of yesterday to end of yesterday
  • week: Calculates change over the last 7 days
  • month: Calculates change over the last month
  • year: Calculates change over the last year

Example API Response

{
  "success": true,
  "base": "USD",
  "start_date": "2022-12-22",
  "end_date": "2022-12-24",
  "rates": {
      "BRENT": {
        "start_rate": 0.01217137,
        "end_rate": 0.01191611,
        "change": -0.00025526,
        "change_pct": -2.0972
      }
  }

Response Attributes

Attribute Description
success Returns true or false depending if the API Request succeeded. If false, refer to API Errors.
base Returns base currency used for the request.
start_date Returns start date of your timeframe for the request.
end_date Returns end date of your timeframe for the request.
rates -> start_rate Returns exchange rate for the start date.
rates -> end_rate Returns exchange rate for the end date.
rates -> change Returns change (decimal number) of the given currency rate between the start and end date.
rates -> change_pct Returns percent change of the given currency rate between your start and end date. Formula used is ((end_rate - start_rate) / start_rate) * 100

Hourly Rates

This endpoint returns hourly exchange rate data for a given currency over a specified date range. It provides 24 data points per day, one for each hour.

Only one currency is allowed per request. Free users can query up to 2 days; paid users can query up to 7 days. Future dates are not allowed.

Example API Request

https://api.energypriceapi.com/v1/hourly
?api_key=[API_KEY]
&base=USD
&currency=BRENT
&start_date=2025-11-03
&end_date=2025-11-03

Request Parameters

Parameter Description
api_key [Required] Your API Key. More details.
base [optional] Specify a base currency. Base Currency will default to USD if this parameter is not defined.
currency [Required] Specify a single currency code. Only one currency is allowed per request.
start_date [optional] Specify the start date in YYYY-MM-DD format. Defaults to today.
end_date [optional] Specify the end date in YYYY-MM-DD format. Defaults to today.
date_type [optional] (Paid plan) Specify "today", "yesterday", or "week" as a shortcut. If provided, this parameter overrides "start_date" and "end_date".

  • today: Using today's date
  • yesterday: Using yesterday's date
  • week: Using the last 7 days
math [optional] (Paid plan) Specify math operators to perform on the result. Use value to refer to the rates. Specify one or more of the mathematical operators add, subtract, multiply, and/or divide.

Example API Response

{
  "success": true,
  "base": "USD",
  "start_date": "2025-11-03",
  "end_date": "2025-11-03",
  "rates": [
    {
      "timestamp": 1762128000,
      "rates": {
        "BRENT": 0.01194215
      }
    },
    {
      "timestamp": 1762131600,
      "rates": {
        "BRENT": 0.01196832
      }
    },
    ...
  ]
}

Response Attributes

Attribute Description
success Returns true or false depending if the API Request succeeded. If false, refer to API Errors.
base Returns base currency used for the request.
start_date Returns start date of the hourly query.
end_date Returns end date of the hourly query.
rates -> timestamp Returns the UNIX timestamp for the hourly data point.
rates -> rates Returns exchange rate data for the requested currency.

Open/High/Low/Close (OHLC)

This endpoint will return open, high, low, and close prices for a given currency pair.

OHLC data uses a 00:00 to 23:59:59 GMT trading day. The open price is captured at midnight GMT (00:00), and the close price is captured at 23:59:59 GMT. The previous day's OHLC data becomes available at 00:05 AM GMT.

Example API Request

https://api.energypriceapi.com/v1/ohlc
?api_key=[API_KEY]
&base=USD
&currency=WTI
&date=2025-01-28

Request Parameters

Parameter Description
api_key [Required] Your API Key. More details.
base [optional] Specify a base currency. Base Currency will default to USD if this parameter is not defined.
currency [Required] Specify a currency.
date [Required] Specify a date in the format YYYY-MM-DD to get the OHLC for specified date.
date_type [optional] (Paid plan) Specify "yesterday", "week", "month", or "year" to retrieve the rate change for the corresponding time period. If provided, this parameter overrides "date".

  • yesterday: Using the previous day's OHLC date
  • week: Using the previous week's OHLC date
  • month: Using the previous month's OHLC date
  • year: Using the previous year's OHLC date

Example API Response

{
  "success": true,
  "base": "USD",
  "quote": "WTI",
  "timestamp": 1738108799,
  "rate": {
      "close": 0.01269938,
      "high": 0.01285012,
      "low": 0.01255318,
      "open": 0.01271186
  }
}

Response Attributes

Attribute Description
success Returns true or false depending if the API Request succeeded. If false, refer to API Errors.
base Returns base currency used for the request.
quote Returns quote currency used for the request.
timestamp Returns the UNIX timestamp for the OHLC data.
rate -> close Returns close price for the specified date.
rate -> high Returns high price for the specified date.
rate -> low Returns low price for the specified date.
rate -> open Returns open price for the specified date.

Usage

This endpoint is used to check your API usage and quota for the current month.
Requests to this endpoint do not count towards your monthly API quota.

Example API Request

https://api.energypriceapi.com/v1/usage
?api_key=[API_KEY]

Request Parameters

Parameter Description
api_key [Required] Your API Key. More details.

Example API Response

{
  "success": true,
  "result": {
      "plan": "Business",
      "used": 12,
      "total": 100,
      "remaining": 88
  }
}

Response Attributes

Attribute Description
success Returns true or false depending if the API Request succeeded. If false, refer to API Errors.
plan Returns your current plan.
used Returns the number of requests used for the current month.
total Returns your total quota for the current month.
remaining Returns your remaining quota for the current month.