Skip to content

Add Frankfurter v2 provider (frankfurter_v2 driver)#39

Open
anousss007 wants to merge 1 commit into
worksome:mainfrom
anousss007:feat/frankfurter-v2-provider
Open

Add Frankfurter v2 provider (frankfurter_v2 driver)#39
anousss007 wants to merge 1 commit into
worksome:mainfrom
anousss007:feat/frankfurter-v2-provider

Conversation

@anousss007
Copy link
Copy Markdown

Summary

The bundled frankfurter driver targets the v1 API (GET /latest?from=&to= returning { "rates": { "CODE": rate } }). The v2 API is shaped differently:

  • endpoint: GET /v2/rates?base=EUR&quotes=USD,AED
  • response: a list of rows — [{ "date": ..., "base": ..., "quote": ..., "rate": ... }]

So v2 can't be reached by swapping FRANKFURTER_BASE_URL alone (hitting /v2/latest?from=... returns a 404). v2 also covers a much larger currency set than the ECB-only v1 — for example AED and MAD, which don't come back from the v1 latest call — and that's the main reason to support it.

What this adds

  • FrankfurterV2Provider — calls /rates with base/quotes and maps the v2 rows back into the quote => rate shape before building Rates.
  • A new frankfurter_v2 driver in ExchangeRateManager (no API key; base URL configurable via FRANKFURTER_V2_BASE_URL, defaulting to https://api.frankfurter.dev/v2).
  • Config block, README section, unit tests, and the manager "can instantiate all drivers" dataset entry.

It's kept as a separate driver (frankfurter_v2) rather than changing frankfurter, so it's fully non-breaking. Happy to instead fold it into the existing driver behind a version option if you'd prefer that shape.

Small note: the provider parses the response date with !Y-m-d, so the retrievedAt date can't roll over when the instance is converted to the Europe/Amsterdam timezone (independent of the runner's local time/zone).

Follows up on the discussion about adding v2 support.

The bundled frankfurter driver targets the v1 API (GET /latest?from=&to= returning {rates:{CODE:rate}}). The v2 API uses GET /v2/rates?base=&quotes= and returns a list of rows shaped {date, base, quote, rate}, so it is not reachable by swapping the base URL alone. v2 also covers a much larger currency set than the ECB-only v1 (e.g. AED, MAD).

Add a FrankfurterV2Provider that maps the v2 rows back into the quote => rate shape before building Rates, registered as a new 'frankfurter_v2' driver (no API key, base_url configurable via FRANKFURTER_V2_BASE_URL). Includes unit tests, the manager dataset entry, a config block and a README section.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant