Documentation
¶
Overview ¶
Package gofixerio providers simple wrapper for "Foreign exchange rates and currency conversion JSON API" (https://fixer.io).
Using this package is easy as 1-2-3:
fixerio, _ := gofixerio.New("your API key here", "EUR", "false") latestRates, err := fixerio.GetLatest() if err != nil { log.Panic(err) } log.Printf("%+v", latestRates)
Index ¶
- Constants
- type FixerIO
- func (f *FixerIO) GetConversion(from string, to string, amount float64, date string) (*ResponseConversion, error)
- func (f *FixerIO) GetFluctuation(startDate string, endDate string) (*ResponseFluctuation, error)
- func (f *FixerIO) GetHistorical(date string, symbols []string) (*ResponseHistorical, error)
- func (f *FixerIO) GetLatest(symbols []string) (*ResponseLatest, error)
- func (f *FixerIO) GetSymbols() (*ResponseSymbols, error)
- func (f *FixerIO) GetTimeseries(startDate string, endDate string) (*ResponseTimeseries, error)
- func (f *FixerIO) SetBase(base string) *FixerIO
- type ResponseConversion
- type ResponseError
- type ResponseErrorDetail
- type ResponseFluctuation
- type ResponseHistorical
- type ResponseLatest
- type ResponseSuccess
- type ResponseSymbols
- type ResponseTimeseries
Examples ¶
Constants ¶
const BaseURL = "data.fixer.io"
BaseURL is the main URL for accessing https://fixer.io API
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type FixerIO ¶
FixerIO represents a client instance
func New ¶
New eturns pointer to a new instance of FixerIO
Example ¶
package main import ( "log" gofixerio "github.com/LordotU/go-fixerio" ) func main() { fixerio, _ := gofixerio.New("your API key here", "EUR", false) latestRates, err := fixerio.GetLatest([]string{}) if err != nil { log.Panic(err) } log.Printf("%+v", latestRates) }
Output:
func (*FixerIO) GetConversion ¶
func (f *FixerIO) GetConversion(from string, to string, amount float64, date string) (*ResponseConversion, error)
GetConversion returns pointer to ResponseConversion struct which contains conversion data for given from, to, amount and date args
func (*FixerIO) GetFluctuation ¶
func (f *FixerIO) GetFluctuation(startDate string, endDate string) (*ResponseFluctuation, error)
GetFluctuation returns pointer to ResponseTimeseries struct which contains fluctuation rates map (map[string][string]float64) for given startDate and endDate arg
func (*FixerIO) GetHistorical ¶
func (f *FixerIO) GetHistorical(date string, symbols []string) (*ResponseHistorical, error)
GetHistorical returns pointer to ResponseHistorical struct which contains historical rates map (map[string]float64) for given date and symbols args
func (*FixerIO) GetLatest ¶
func (f *FixerIO) GetLatest(symbols []string) (*ResponseLatest, error)
GetLatest returns pointer to ResponseLatest struct which contains latest rates map (map[string]float64) for given symbols arg
func (*FixerIO) GetSymbols ¶
func (f *FixerIO) GetSymbols() (*ResponseSymbols, error)
GetSymbols returns pointer to ResponseSymbols struct which contains symbols map (map[string]string)
func (*FixerIO) GetTimeseries ¶
func (f *FixerIO) GetTimeseries(startDate string, endDate string) (*ResponseTimeseries, error)
GetTimeseries returns pointer to ResponseTimeseries struct which contains timeseries rates map (map[string][string]float64) for given startDate and endDate arg
type ResponseConversion ¶
type ResponseConversion struct { ResponseSuccess Query conversionQuery `json:"query"` Info conversionInfo `json:"info"` Historical bool `json:"historical"` Date string `json:"date"` Result float64 `json:"result"` }
ResponseConversion represents GetConversion response
type ResponseError ¶
type ResponseError struct { ResponseSuccess Error ResponseErrorDetail `json:"error"` }
ResponseError represents errored response
type ResponseErrorDetail ¶
type ResponseErrorDetail struct { Code int `json:"code"` Type string `json:"type"` Info string `json:"info"` }
ResponseErrorDetail represents details of errored response
type ResponseFluctuation ¶
type ResponseFluctuation struct { ResponseSuccess Fluctuation bool `json:"fluctuation"` StartDate string `json:"start_date"` EndDate string `json:"end_date"` Base string `json:"base"` Rates ratesNested `json:"rates"` }
ResponseFluctuation represents GetFluctuation response
type ResponseHistorical ¶
type ResponseHistorical struct { ResponseSuccess ResponseLatest Historical bool `json:"historical"` }
ResponseHistorical represents GetHistorical response
type ResponseLatest ¶
type ResponseLatest struct { ResponseSuccess Timestamp int `json:"timestamp"` Base string `json:"base"` Date string `json:"date"` Rates rates `json:"rates"` }
ResponseLatest represents GetLatest response
type ResponseSuccess ¶
type ResponseSuccess struct {
Success bool `json:"success"`
}
ResponseSuccess represents the success of the request
type ResponseSymbols ¶
type ResponseSymbols struct { ResponseSuccess Symbols symbols `json:"symbols"` }
ResponseSymbols represents GetSymbols response
type ResponseTimeseries ¶
type ResponseTimeseries struct { ResponseSuccess Timeseries bool `json:"timeseries"` StartDate string `json:"start_date"` EndDate string `json:"end_date"` Base string `json:"base"` Rates ratesNested `json:"rates"` }
ResponseTimeseries represents GetTimeseries response