exchange

package
v0.4.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 30, 2025 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package exchange provides some API client for exchange rates.

Index

Constants

This section is empty.

Variables

View Source
var ErrNotFound = errors.New("not found")

Functions

This section is empty.

Types

type Exchanger

type Exchanger interface {
	// GetExchangeRate returns the exchange rate at the given time.
	// If the time is zero time, the latest exchange rate is returned.
	GetExchangeRate(
		ctx context.Context, from, to string, time time.Time,
	) (float64, time.Time, error)
}

type Fawazahmed0

type Fawazahmed0 struct {
	// contains filtered or unexported fields
}

Fawazahmed0 is a free API that provides exchange rates for over 200 currencies. Only support daily exchange rates. The input time will be formatted in UTC timezone.

func NewFawazahmed0

func NewFawazahmed0(hc *http.Client) *Fawazahmed0

func (*Fawazahmed0) GetExchangeRate

func (f *Fawazahmed0) GetExchangeRate(ctx context.Context, from, to string, t time.Time,
) (n float64, dt time.Time, err error)

type Fawazahmed0Resp

type Fawazahmed0Resp map[string]any

type Frankfurter

type Frankfurter struct {
	// contains filtered or unexported fields
}

Frankfurter is a free API that provides exchange rates for over 200 currencies. Only support daily exchange rates. The input time will be formatted in UTC timezone.

func NewFrankfurter

func NewFrankfurter(hc *http.Client) *Frankfurter

func (*Frankfurter) GetExchangeRate

func (f *Frankfurter) GetExchangeRate(ctx context.Context, from, to string, t time.Time,
) (n float64, dt time.Time, err error)

type FrankfurterResp

type FrankfurterResp struct {
	Base  string             `json:"base"`
	Date  string             `json:"date"` // 2025-06-13
	Rates map[string]float64 `json:"rates"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL