New "recent" data_type for the Change Query Endpoint

Last updated on January 02, 2025

< Back to Blogs

Change Endpoint Update

We are thrilled to announce an enhancement to our existing Change Query endpoint: the addition of the "recent" date type. This new feature allows you to easily track the 24-hour change of currencies, making it more convenient to display real-time data on your platforms.

Key Features of the Change Query Endpoint

  • Flexible Timeframes: Specify a start and end date to get precise change values for your desired period.
  • Base Currency: Choose a base currency for your calculations, with USD as the default.
  • Currency Selection: Limit responses to specific currencies by providing a comma-separated list of currency codes.
  • Predefined Date Types: Use predefined date types like "recent", "yesterday", "week", "month", or "year" to quickly retrieve rate changes for common periods.

New "Recent" Date Type

The "recent" date type is a powerful addition that calculates the change from yesterday's closing rate to the current rate. This is particularly useful for displaying 24-hour changes on websites, providing a seamless experience for users who need up-to-date information.

Note on "Yesterday" Date Type

While the "recent" date type calculates the change from yesterday's closing rate to the current rate, the "yesterday" date type calculates the change from the start of yesterday to the end of yesterday. This distinction is important for users who need to understand the difference between a full day's change and a rolling 24-hour change. For most use cases, the "recent" date type is the best choice.

Example API Request

To demonstrate the capabilities of the Change Query endpoint with the new "recent" date type, here is an example request:

https://api.metalpriceapi.com/v1/change
?api_key=[API_KEY]
&date_type=recent
&base=USD
&currencies=XAU

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. Defaults to USD if not defined.
currencies [Optional] Specify a comma-separated list of currency codes.
date_type [Optional] Use "recent", "yesterday", "week", "month", or "year" to override start and end dates.

Date Type Options

  • recent: Calculates change from yesterday's closing rate to the current rate (subject to your plan's delay).
  • yesterday: Calculates change from the start of yesterday to the 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.

Use Case

Before the introduction of the "recent" date type to the /change endpoint, displaying a 24-hour change required two separate queries: one to the /historical endpoint to get the starting point and another to the /latest endpoint to get the latest value. Now, with the "recent" date type, you can achieve this with a single request.

We hope this new feature enhances your experience and provides greater flexibility in how you use our API.


For any questions or support, feel free to contact our support team.