Popularity
0.8
Growing
Activity
3.4
-
5
3
0

Description

Exchange rates client for the excellent Exchange Rates API. The API provides current and historical foreign exchange rates published by the European Central Bank.

Programming language: Go
License: MIT License
Latest version: v0.0.1

exrates alternatives and similar packages

Based on the "Financial" category.
Alternatively, view exrates alternatives based on common mentions on social networks and blogs.

Do you think we are missing an alternative of exrates or a related project?

Add another 'Financial' Package

README

exrates

Build Status GoDoc License: MIT Go Report Card

Exchange rates client for the excellent Exchange Rates API. The API provides current and historical foreign exchange rates published by the European Central Bank.

Installation

go get github.com/adrg/exrates

Usage

Latest exchange rates

// Get all available exchange rates.
rates, err := exrates.Latest("USD", nil)
if err != nil {
    // Treat error.
    return
}
// Get specific exchange rates.
// rates, err := exrates.Latest("EUR", []string{"USD", "CAD"})

fmt.Printf("Exchange rates for %s on %s\n", rates.Base, rates.Date)
for currency, value := range rates.Values {
    fmt.Printf("%s: %f\n", currency, value)
}

Exchange rates on specific date

date := time.Date(2019, 3, 8, 0, 0, 0, 0, time.UTC)

// Get all available exchange rates.
rates, err := exrates.On("USD", date, nil)
if err != nil {
    // Treat error.
    return
}
// Get specific exchange rates.
// rates, err := exrates.On("EUR", date, []string{"USD", "CAD"})

fmt.Printf("Exchange rates for %s on %s\n", rates.Base, rates.Date)
for currency, value := range rates.Values {
    fmt.Printf("%s: %f\n", currency, value)
}

Exchange rates in date interval

start := time.Date(2019, 1, 1, 0, 0, 0, 0, time.UTC)
end := time.Date(2019, 4, 22, 0, 0, 0, 0, time.UTC)

// Get all available exchange rates.
days, err := exrates.Between("USD", start, end, nil)
if err != nil {
    // Treat error.
    return
}
// Get specific exchange rates.
// days, err := exrates.Between("EUR", start, end, []string{"USD", "CAD"})

for _, day := range days {
    fmt.Printf("Exchange rates for %s on %s\n", day.Base, day.Date)
    for currency, value := range day.Values {
        fmt.Printf("%s: %f\n", currency, value)
    }
}

Supported currencies

EUR - Euro
USD - US dollar
JPY - Japanese yen
BGN - Bulgarian lev
CZK - Czech koruna
DKK - Danish krone
GBP - Pound sterling
HUF - Hungarian forint
PLN - Polish zloty
RON - Romanian leu
SEK - Swedish krona
CHF - Swiss franc
ISK - Icelandic krona
NOK - Norwegian krone
HRK - Croatian kuna
RUB - Russian rouble
TRY - Turkish lira
AUD - Australian dollar
BRL - Brazilian real
CAD - Canadian dollar
CNY - Chinese yuan renminbi
HKD - Hong Kong dollar
IDR - Indonesian rupiah
ILS - Israeli shekel
INR - Indian rupee
KRW - South Korean won
MXN - Mexican peso
MYR - Malaysian ringgit
NZD - New Zealand dollar
PHP - Philippine peso
SGD - Singapore dollar
THB - Thai baht
ZAR - South African rand

Contributing

Contributions in the form of pull requests, issues or just general feedback, are always welcome.
Before making a contribution please read CONTRIBUTING.md.

References

For more information see the Exchange Rates API.

License

Copyright (c) 2019 Adrian-George Bostan.
This project is licensed under the MIT license. See LICENSE for more details.


*Note that all licence references and agreements mentioned in the exrates README section above are relevant to that project's source code only.