Is there a way to make an API call to get current Euro/USD exchange rates? Like, from the ECB?
Foreign Currency is generally traded "over-the-counter" between different parties. Which means there is no centralized or official rate.
Many of the official indicators of the exchange rate come from asking various banks what their rates are, and then applying some method to come up with a single rate. Bloomberg, for example uses this method.
A reasonable method to determine a representative rate is to get prices from an FX trading platform (or exchange) that can actually be traded at that price. If people are willing to buy and sell at that price, it is more likely to be representative than one which is not tradable.
Some APIs are:
- Bloomberg (either through a Terminal, B-Pipe, or Data License)
- Thomson Reuters (now Refinitiv) with similar terminal services
- Interactive Brokers (they offer market data from their proprietary "IDEAL" platform)
- Some people have had success getting data through Yahoo finance (who in turn get the data from I think FactSet - another Bloomberg competitor)
- More and more exchanges are now offering FX trading, so they too may offer prices through a market data API.
- Some third party foreign exchange market data services (e.g. oanda.com, xe.com, x-rates.com) these provide exchange data either through download or through an API for a fee.
The central banks and tax authorities may offer exchange rates they use for their own use (or for people when they file their tax returns) which can be found on their web site, though these tend to be historical, and often times refer people to FX data vendors.