How-to guidesHow-to

Calculate an average exchange rate over a period

Average the last 30 days of daily USD to JPY rates

29 Oct 2026 · 3 min read

Add the daily USD to JPY rates, then divide by the number of days with a rate. The result is the average JPY per USD for that period. The calculation uses example numbers from the response at 29 Oct 2026, 23:25 UTC, with a date window of 2026-09-30 to 2026-10-29.

Choose the period and quote direction

Use USD as the base and JPY as the symbol for the last 30 days. Every value then has the same unit, JPY per USD. The API quotes every currency against USD, so this pair gives you the daily inputs for the average directly.

The example window runs from 2026-09-30 to 2026-10-29. The free tier includes 30 days of daily history; older dates need a plan with more history. Use the dates of the accounting period or invoice batch you want the average to describe.

Read the rates in the data array

The range response keeps its daily rows in data. Each row has date, rates and source. Read the JPY value from each row's rates object. The row's source identifies the daily reference fix that the value comes from.

The response also has result, base, start_date and end_date, plus next_cursor, has_more and notice. Check the returned date window against the period you selected. The daily rows are the inputs to the calculation, so count those rows when you prepare the divisor.

Shell
curl "https://api.exchangerate.dev/v1/range?base=USD&symbols=JPY&start_date=2026-09-30&end_date=2026-10-29"

Divide the sum by the returned row count

The formula is average = sum of the daily rates / number of days with a rate. For this window, 22 daily rates add up to 3,474.297 JPY per USD. Divide that sum by 22 to get 157.923 JPY per USD.

The example series was captured at 29 Oct 2026, 23:25 UTC. Its lowest daily rate is 156.803 JPY per USD and its highest is 158.599 JPY per USD. These are the smallest and largest daily values in the series.

StepCalculationResult
Days with a rate2026-09-30 to 2026-10-2922
Sum of the daily rates22 rates of JPY per USD3,474.297
Average3,474.297 ÷ 22157.923 JPY per USD
Lowest to highestsmallest and largest daily rate156.803 to 158.599

Use the mean for the selected period

The result describes the simple mean of the daily reference fixes for an accounting period or invoice batch. Each returned daily rate has equal weight in the formula. A day with a larger invoice amount has the same weight as any other day with a rate.

A simple mean of daily rates is not a volume-weighted rate. Keep that distinction clear when you use 157.923 JPY per USD for a batch: the calculation uses daily rates and their count, with no transaction volumes in its inputs.

Count days with a reference fix

Divide by the number of rows returned, not by the calendar days in the window. The endpoint returns a daily reference rate per business day. A Friday row is followed by a Monday row because weekends have no row.

A public holiday of the fixing source can also leave a date without a fix. That date has no row and contributes nothing to either the sum or the count. A 30-day calendar window therefore uses the returned row count as its divisor.

Check access limits and timestamps

Keyless calls allow 10 requests a minute and 100 an hour per IP, with rates 15 minutes late. A free key has 5,000 requests a month and 10 requests a minute, also with rates 15 minutes late. Paid plans are live.

A latest response carries source, market_session, timestamp, data_updated_at and rates, plus the notice "Indicative rates, not for settlement." The range response has no data_updated_at; 29 Oct 2026, 23:25 UTC records when the example series was captured.

The rates are indicative mid-market figures, not for settlement or trading. Banks, cards and transfer services apply their own spread and fees. The period average uses the daily reference fixes returned by the API.

Questions

Should I divide by 30 for a 30-day window?

Use the number of returned rows. Weekends have no row, and public holidays of the fixing source can also have no fix. The example window has 22 days with a rate, so its divisor is 22.

What does the average measure?

It is the simple mean of the daily JPY per USD reference fixes in the selected period. Each returned rate has equal weight. The formula does not use transaction volumes, so the result is not a volume-weighted rate.

When was the example series captured?

The example series was captured at 29 Oct 2026, 23:25 UTC. The range response has no `data_updated_at` field. Each daily row has its own `date`, `rates` and `source`, which identifies the daily reference fix.

Can I average an older accounting period?

Older dates need a plan with more history. The free tier includes 30 days of daily history. For the selected period, add the daily rates returned and divide by the number of rows with a rate.

Keep reading

Get a free API key

Free has 5,000 requests a month and 10 requests a minute. No credit card is required.

Get a free key