Query /hourly Rates with Unix Timestamps

Last updated on May 02, 2026

< Back to Blogs

Hourly Endpoint Now Supports Unix Timestamps

We're excited to announce a new way to query the /hourly endpoint: in addition to the existing start_date / end_date parameters, you can now specify your time range using start and end Unix timestamps. This gives you precise hour-level control over the data you fetch, without the overhead of pulling a full day of rates when you only need a few hours.

Why Unix Timestamps Matter

Date strings are convenient, but they come with hidden costs: every query returns 24 hourly entries per day, and turning a server-side timestamp into a YYYY-MM-DD string requires timezone handling on the client. Unix timestamps fix both:

  • Pull only the hours you need: A 3-hour window now returns 3 entries instead of 24, reducing payload size and downstream processing.
  • Skip timezone math: Pass the timestamp you already have — no need to convert epochs to UTC date strings before calling the API.
  • Cleaner integrations: Most programming languages, time-series databases, and charting libraries already work in Unix-second timestamps. Now your API calls do too.

How to Use the New Parameters

To query a specific hour range, make a GET request with start and end set to Unix timestamps (seconds since epoch):

https://api.metalpriceapi.com/v1/hourly?api_key=[API_KEY]&base=USD&currency=XAU&start=1762128000&end=1762146000

The example above returns 6 hourly entries from 2025-11-03 00:00 UTC through 05:00 UTC.

Request Parameters

  • api_key: [Required] Your unique API key.
  • base: [Optional] The base currency symbol. Defaults to USD.
  • currency: [Required] A single quote currency symbol (e.g., XAU).
  • start: [Optional] Start of the range as a Unix timestamp.
  • end: [Optional] End of the range as a Unix timestamp. Defaults to the current hour if omitted.

A Few More Examples

Fetch a single hour (start and end set to the same hour):

https://api.metalpriceapi.com/v1/hourly?api_key=[API_KEY]&currency=XAG&start=1762128000&end=1762128000

Fetch a full UTC day — 24 hourly entries from 00:00 through 23:00:

https://api.metalpriceapi.com/v1/hourly?api_key=[API_KEY]&currency=XAU&start=1762128000&end=1762210800

Key Details

  • Pick one form per request: start / end and start_date / end_date cannot be combined in the same call. The same applies to date_type (today, yesterday, week).
  • Same plan limits apply: Free plan users can query up to 2 days; paid plan users can query up to 7 days.
  • Same response shape: The response format is identical regardless of which input form you use, so existing client code works without changes.

Get Started Today

The new parameters are live across all MetalpriceAPI endpoints — no migration or version bump required. Existing date-string queries continue to work exactly as before. For full details, visit the API documentation.

If you have questions or run into issues, our support team is happy to help.

— MetalpriceAPI Team