Exchange rate example – API

There are several ways we can get exchange rates.

Unlike the weather API we used in last chapter that is free for use. For the finance data, each free source comes with its limitations. Take Currency API as example, it only comes with currencies from 16 countries and CNY is not in the list. And for the Open Exchange Rate API, the free one doesn’t allow to change the base currency for the conversion.

In our example, we will use the Open Exchange Rate service. I also suggest to check out the documentation or API on how to use the service.

Example of using Open Exchange Rate to calculate CNY -> MOP conversion.

2MOP -> USD -> CNY
4cny_usd = 1 / 6.100569
5usd_mop = 8.00591
6cny_mop = cny_usd * usd_mop

What’s next? We’re going to take a look at “Exchange rate example – Exchange function”.

overlaied image when clicked on thumbnail

Makzan | Mobile web app dev with phonegap | Table of Content