ismartcoding / currency-api

Free Currency Exchange Rates API with 169 Currencies & No Rate Limits
MIT License
37 stars 4 forks source link

[Help] Calculate rates of two currencies where non of which is the base #4

Closed RaptaG closed 7 months ago

RaptaG commented 7 months ago

This can be achieved by a simple division:

currency1 = rate of currency2 / rate of currency1 currency2

Example

1 Euro = (the value for Yen from the API) / (the value for Euro from the API) Yen


Mathematical explanation

x is the rate $ to € from the API y is the rate $ to ¥ from the API

1$ = x € 1$ = y ¥

1$ = 1$ <=> x € = y ¥ <=> 1€ = y/x ¥

ismartcoding commented 7 months ago

Something like that, you already found the solution. The default base is USD. https://raw.githubusercontent.com/ismartcoding/currency-api/main/latest/data.json

RaptaG commented 7 months ago

I kept it here so that other people can see it before requesting basing from all currencies, which would increase the APIs size without reason.

I recommend you reopen and pin this so that other developers can see it