Free Go Exchange Rate API

Welcome to the UniRate API Go documentation. Our free exchange rate API gives you real-time and historical currency conversion you can drop into any Go service — whether it's an API, worker, CLI, or data pipeline. If you need to price orders, settle invoices, or run multi-currency analytics, the client is ready.

The official Go client library is written to feel like the standard library — context.Context on every method, sentinel errors, and no third-party dependencies.

With UniRate API, you get:

  • Real-time exchange rates for 170+ currencies (fiat + crypto)
  • Historical rates back to 1999 and time-series up to 5 years
  • VAT rates for countries worldwide
  • Free tier with no credit card required

The Go library is designed to be:

  • Idiomatic: context.Context on every method, sentinel errors
  • Zero external dependencies — pure standard library
  • Requires Go 1.21 or newer
  • Swappable *http.Client for tests and custom transports
  • Open source on GitHub

For full reference on endpoints, rate limits, and advanced options, see our main API documentation.

Below you'll find examples using the official UniRate Go client.

Getting Started with Go

Install with go get github.com/UniRate-API/unirate-api-go, then import as unirate "github.com/UniRate-API/unirate-api-go".


// Install: go get github.com/UniRate-API/unirate-api-go

package main

import (
    "context"
    "fmt"
    "log"
    "os"
    "time"

    unirate "github.com/UniRate-API/unirate-api-go"
)

func main() {
    client := unirate.New(os.Getenv("UNIRATE_API_KEY"),
        unirate.WithTimeout(10*time.Second),
    )
    ctx := context.Background()

    // Current rate
    rate, err := client.GetRate(ctx, "USD", "EUR")
    if err != nil {
        log.Fatal(err)
    }
    fmt.Printf("USD -> EUR: %.4f\n", rate)

    // Convert an amount
    euros, err := client.Convert(ctx, 100, "USD", "EUR")
    if err != nil {
        log.Fatal(err)
    }
    fmt.Printf("100 USD = %.2f EUR\n", euros)

    // All rates for a base
    rates, _ := client.GetAllRates(ctx, "USD")
    fmt.Printf("%d rates for USD\n", len(rates))

    // Supported currencies
    codes, _ := client.GetSupportedCurrencies(ctx)
    fmt.Printf("%d currencies supported\n", len(codes))

    // Historical rate on a specific date
    hist, _ := client.GetHistoricalRate(ctx, "2024-01-01", "USD", "EUR")
    fmt.Printf("USD -> EUR on 2024-01-01: %.4f\n", hist)

    // Time series (up to 5 years)
    series, _ := client.GetTimeSeries(ctx,
        "2024-01-01", "2024-01-07",
        1,
        "USD",
        []string{"EUR", "GBP"},
    )
    _ = series

    // VAT rate for a country (ISO-3166 alpha-2)
    de, _ := client.GetVATRate(ctx, "DE")
    fmt.Printf("Germany VAT: %.1f%%\n", de.VATData.VATRate)
}

Response Example


USD -> EUR: 0.9245
100 USD = 92.45 EUR
593 rates for USD
593 currencies supported
USD -> EUR on 2024-01-01: 0.9056
Germany VAT: 19.0%

Important Notes

  • Replace 'UNIRATE_API_KEY' with your actual API key from unirateapi.com
  • Install with: go get github.com/UniRate-API/unirate-api-go
  • Requires Go 1.21 or newer
  • Always pass a context.Context — it supports cancellation and request timeouts
  • Historical endpoints require a Pro API key (403 on free tier)
  • Use unirate.WithTimeout, WithHTTPClient, or WithBaseURL to customize the client
  • Sentinel errors — compare with errors.Is(err, unirate.ErrAuthentication) etc.

Not a Developer?

We offer paid implementation services to integrate our API into your application without you needing to write any code.

Contact Us for a Quote

Ready to Get Started?

Sign up now to get your API key and start converting currencies in your Go applications.

Get Your API Key