
GO Client Library for Global Exchange Rates API
If you’re building with Go and need reliable exchange rate data, we’ve just published an official client library to make working with our API even easier.
The globalexchangerates package is now available at pkg.go.dev and GitHub.
The library covers all the endpoints of the API, including latest rates, historical rates and conversions. It’s compatible with standard Go projects and is designed for developers who need to fetch currency exchange rates in GO for backend, accounting, finance, or integration use cases.
Quick Start
Install the package:
go get github.com/globalexchangerates/GO_GlobalExchangeRates
Create a client instance in your code:
client := globalexchangerates.NewClient("your_api_key")
Retrieve the latest exchange rates:
rates, err := client.GetLatest(context.Background(), nil)
if err != nil {
log.Fatal(err)
}
Converting Amounts and Historical Rates
Convert an amount directly using the official rates:
conversion, err := client.Convert(context.Background(), 100, &globalexchangerates.ConvertOptions{
BaseCurrency: "EUR",
ToCurrencies: []string{"USD", "GBP"},
})
if err != nil {
log.Fatal(err)
}
fmt.Println(conversion.Conversions["USD"])
Retrieve the official rates for a specific date:
date := time.Date(2025, 1, 1, 0, 0, 0, 0, time.UTC)
historical, err := client.GetHistorical(context.Background(), date, &globalexchangerates.GetHistoricalOptions{
BaseCurrency: "EUR",
Currencies: []string{"USD"},
})
Providers and a Specific Provider
Request rates from a single institution, or list the available providers and currencies:
rates, err := client.GetLatest(context.Background(), &globalexchangerates.GetLatestOptions{
Provider: "ECB",
Currencies: []string{"USD", "GBP"},
})
providers, err := client.GetProviders(context.Background(), nil)
currencies, err := client.GetCurrencies(context.Background(), nil)
Keeping the Rates Up to Date
Official rates are published once per business day, so refreshing on a schedule is usually enough to keep your data current.
The same official rates are available in other languages and tools — see our Python, C# / .NET, JavaScript, and Java client libraries, or the guides for Power BI and Google Sheets. The full method reference is in the API documentation. If you don’t have an API key yet, you can get one on the get-started page, with official rates from central banks and tax authorities worldwide.
Let us know if you use the library in a project or have feature requests—we’re always interested in improving things for Go developers.
