Skip to content

Official Go SDK for OpenExchangeAPI — fast and lightweight client for fetching exchange rates and working with ISO 4217 data.

License

Notifications You must be signed in to change notification settings

OpenExchangeAPI/sdk-golang

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 

Repository files navigation

OpenExchangeAPI Go SDK

Minimal, idiomatic Go client for OpenExchangeAPI

  • All endpoints supported
  • API key is optional
  • Returns Go structs for all responses
  • Uses context.Context for all public methods
  • Clear error handling

Installation

go get github.com/openexchangeapi/openexchangeapi-go

Usage

package main

import (
    "context"
    "fmt"
    "github.com/openexchangeapi/openexchangeapi-go"
)

func main() {
    client := openexchangeapi.NewClient("") // API key optional
    ctx := context.Background()

    // Get latest rates
    latest, err := client.GetLatest(ctx, nil)
    if err != nil {
        panic(err)
    }
    fmt.Println(latest)

    // Convert currency
    result, err := client.Convert(ctx, "USD", "EUR", 100)
    if err != nil {
        panic(err)
    }
    fmt.Println(result)
}

API Reference

  • GetLatest(ctx, base)
  • GetLatestPrecise(ctx, base)
  • GetHistorical(ctx, date, base)
  • GetHistoricalPrecise(ctx, date, base)
  • Convert(ctx, from, to, amount)
  • ConvertPrecise(ctx, from, to, amount)
  • ListCurrencies(ctx, type)
  • GetCurrency(ctx, code)

All methods return Go structs and errors.

Error Handling

All errors are returned as error values. Check errors as usual in Go.

License

MIT

About

Official Go SDK for OpenExchangeAPI — fast and lightweight client for fetching exchange rates and working with ISO 4217 data.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages