Documentation ¶
Overview ¶
Package currencylayer provides a simple REST API with real-time and historical exchange rates for 168 world currencies, delivering currency pairs in universally usable JSON format - compatible with any of your applications. Spot exchange rate data is retrieved from several major forex data providers in real-time, validated, processed and delivered hourly, every 10 minutes, or even within the 60-second market window. Providing the most representative forex market value available ("midpoint" value) for every API request, the currencylayer API powers currency converters, mobile applications, financial software components and back-office systems all around the world. https://currencylayer.com/product for product information https://currencylayer.com/documentation for API documentation and supported functionality
Index ¶
- Constants
- type ChangeRate
- type Changes
- type ConversionRate
- type CurrencyLayer
- func (c *CurrencyLayer) Convert(from, to, date string, amount float64) (float64, error)
- func (c *CurrencyLayer) GetHistoricalData(date string, currencies []string, source string) (map[string]float64, error)
- func (c *CurrencyLayer) GetRates(baseCurrency, symbols string) (map[string]float64, error)
- func (c *CurrencyLayer) GetSupportedCurrencies() ([]string, error)
- func (c *CurrencyLayer) GetliveData(currencies, source string) (map[string]float64, error)
- func (c *CurrencyLayer) QueryCurrencyChange(startDate, endDate, baseCurrency string, currencies []string) (map[string]Changes, error)
- func (c *CurrencyLayer) QueryTimeFrame(startDate, endDate, baseCurrency string, currencies []string) (map[string]interface{}, error)
- func (c *CurrencyLayer) SendHTTPRequest(endPoint string, values url.Values, result interface{}) error
- func (c *CurrencyLayer) Setup(config base.Settings) error
- type Error
- type HistoricalRates
- type LiveRates
- type SupportedCurrencies
- type TimeFrame
Constants ¶
const ( AccountFree = iota AccountBasic AccountPro AccountEnterprise APIEndpointURL = "http://apilayer.net/api/" APIEndpointURLSSL = "https://apilayer.net/api/" APIEndpointList = "list" APIEndpointLive = "live" APIEndpointHistorical = "historical" APIEndpointConversion = "convert" APIEndpointTimeframe = "timeframe" APIEndpointChange = "change" )
const declarations consist of endpoints and APIKey privileges
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ChangeRate ¶
type ChangeRate struct { Success bool `json:"success"` Error Error `json:"error"` Terms string `json:"terms"` Privacy string `json:"privacy"` Change bool `json:"change"` StartDate string `json:"start_date"` EndDate string `json:"end_date"` Source string `json:"source"` Quotes map[string]Changes `json:"quotes"` }
ChangeRate is the response type that holds rate change data.
type Changes ¶
type Changes struct { StartRate float64 `json:"start_rate"` EndRate float64 `json:"end_rate"` Change float64 `json:"change"` ChangePCT float64 `json:"change_pct"` }
Changes is a sub-type of ChangeRate that holds the actual changes of rates.
type ConversionRate ¶
type ConversionRate struct { Success bool `json:"success"` Error Error `json:"error"` Privacy string `json:"privacy"` Terms string `json:"terms"` Query struct { From string `json:"from"` To string `json:"to"` Amount float64 `json:"amount"` } `json:"query"` Info struct { Timestamp int64 `json:"timestamp"` Quote float64 `json:"quote"` } `json:"info"` Historical bool `json:"historical"` Date string `json:"date"` Result float64 `json:"result"` }
ConversionRate is a response type holding a converted rate.
type CurrencyLayer ¶
CurrencyLayer is a foreign exchange rate provider at https://currencylayer.com NOTE default base currency is USD when using a free account. Has automatic upgrade to a SSL connection.
func (*CurrencyLayer) Convert ¶
func (c *CurrencyLayer) Convert(from, to, date string, amount float64) (float64, error)
Convert converts one currency amount to another currency amount.
func (*CurrencyLayer) GetHistoricalData ¶
func (c *CurrencyLayer) GetHistoricalData(date string, currencies []string, source string) (map[string]float64, error)
GetHistoricalData returns historical exchange rate data for every past day of the last 16 years.
func (*CurrencyLayer) GetRates ¶
func (c *CurrencyLayer) GetRates(baseCurrency, symbols string) (map[string]float64, error)
GetRates is a wrapper function to return rates for GoCryptoTrader
func (*CurrencyLayer) GetSupportedCurrencies ¶
func (c *CurrencyLayer) GetSupportedCurrencies() ([]string, error)
GetSupportedCurrencies returns supported currencies
func (*CurrencyLayer) GetliveData ¶
func (c *CurrencyLayer) GetliveData(currencies, source string) (map[string]float64, error)
GetliveData returns live quotes for foreign exchange currencies
func (*CurrencyLayer) QueryCurrencyChange ¶
func (c *CurrencyLayer) QueryCurrencyChange(startDate, endDate, baseCurrency string, currencies []string) (map[string]Changes, error)
QueryCurrencyChange returns the change (both margin and percentage) of one or more currencies, relative to a Source Currency, within a specific time-frame (optional).
func (*CurrencyLayer) QueryTimeFrame ¶
func (c *CurrencyLayer) QueryTimeFrame(startDate, endDate, baseCurrency string, currencies []string) (map[string]interface{}, error)
QueryTimeFrame returns historical exchange rates for a time-period. (maximum range: 365 days)
func (*CurrencyLayer) SendHTTPRequest ¶
func (c *CurrencyLayer) SendHTTPRequest(endPoint string, values url.Values, result interface{}) error
SendHTTPRequest sends a HTTP request, if account is not free it automatically upgrades request to SSL.
type HistoricalRates ¶
type HistoricalRates struct { Success bool `json:"success"` Error Error `json:"error"` Terms string `json:"terms"` Privacy string `json:"privacy"` Historical bool `json:"historical"` Date string `json:"date"` Timestamp int64 `json:"timestamp"` Source string `json:"source"` Quotes map[string]float64 `json:"quotes"` }
HistoricalRates is a response type holding rates priced from the past.
type LiveRates ¶
type LiveRates struct { Success bool `json:"success"` Error Error `json:"error"` Terms string `json:"terms"` Privacy string `json:"privacy"` Timestamp int64 `json:"timestamp"` Source string `json:"source"` Quotes map[string]float64 `json:"quotes"` }
LiveRates is a response type holding rates priced now.
type SupportedCurrencies ¶
type SupportedCurrencies struct { Success bool `json:"success"` Error Error `json:"error"` Terms string `json:"terms"` Privacy string `json:"privacy"` Currencies map[string]string `json:"currencies"` }
SupportedCurrencies holds supported currency information
type TimeFrame ¶
type TimeFrame struct { Success bool `json:"success"` Error Error `json:"error"` Terms string `json:"terms"` Privacy string `json:"privacy"` Timeframe bool `json:"timeframe"` StartDate string `json:"start_date"` EndDate string `json:"end_date"` Source string `json:"source"` Quotes map[string]interface{} `json:"quotes"` }
TimeFrame is a response type holding exchange rates for a time period