Go API client for finnhub.io
Overview
Installation
Install package:
$ go get -u github.com/Finnhub-Stock-API/finnhub-go
Example (check out other methods documentation here):
package main
import (
"context"
"fmt"
finnhub "github.com/Finnhub-Stock-API/finnhub-go"
"github.com/antihax/optional"
)
func main() {
finnhubClient := finnhub.NewAPIClient(finnhub.NewConfiguration()).DefaultApi
auth := context.WithValue(context.Background(), finnhub.ContextAPIKey, finnhub.APIKey{
Key: "<API_KEY>",
})
stockCandles, _, err := finnhubClient.StockCandles(auth, "AAPL", "D", 1590988249, 1591852249, nil)
fmt.Printf("%+v\n", stockCandles)
news, _, err := finnhubClient.CompanyNews(auth, "AAPL", "2020-05-01", "2020-05-01")
if err != nil {
panic(err)
}
fmt.Printf("%+v\n", news)
investorsOwnershipOpts := &finnhub.InvestorsOwnershipOpts{Limit: optional.NewInt64(10)}
ownerships, _, err := finnhubClient.InvestorsOwnership(auth, "AAPL", investorsOwnershipOpts)
fmt.Printf("%+v\n", ownerships)
aggregateIndicator, _, err := finnhubClient.AggregateIndicator(auth, "AAPL", "D")
fmt.Printf("%+v\n", aggregateIndicator)
basicFinancials, _, err := finnhubClient.CompanyBasicFinancials(auth, "MSFT", "margin")
fmt.Printf("%+v\n", basicFinancials)
earningsSurprises, _, err := finnhubClient.CompanyEarnings(auth, "AAPL", nil)
fmt.Printf("%+v\n", earningsSurprises)
epsEstimate, _, err := finnhubClient.CompanyEpsEstimates(auth, "AAPL", nil)
fmt.Printf("%+v\n", epsEstimate)
executive, _, err := finnhubClient.CompanyExecutive(auth, "AAPL")
fmt.Printf("%+v\n", executive)
peers, _, err := finnhubClient.CompanyPeers(auth, "AAPL")
fmt.Printf("%+v\n", peers)
profile, _, err := finnhubClient.CompanyProfile(auth, &finnhub.CompanyProfileOpts{Symbol: optional.NewString("AAPL")})
fmt.Printf("%+v\n", profile)
profileISIN, _, err := finnhubClient.CompanyProfile(auth, &finnhub.CompanyProfileOpts{Isin: optional.NewString("US0378331005")})
fmt.Printf("%+v\n", profileISIN)
profileCusip, _, err := finnhubClient.CompanyProfile(auth, &finnhub.CompanyProfileOpts{Cusip: optional.NewString("037833100")})
fmt.Printf("%+v\n", profileCusip)
profile2, _, err := finnhubClient.CompanyProfile2(auth, &finnhub.CompanyProfile2Opts{Symbol: optional.NewString("AAPL")})
fmt.Printf("%+v\n", profile2)
revenueEstimates, _, err := finnhubClient.CompanyRevenueEstimates(auth, "AAPL", nil)
fmt.Printf("%+v\n", revenueEstimates)
countries, _, err := finnhubClient.Country(auth)
fmt.Printf("%+v\n", countries)
covid19, _, err := finnhubClient.Covid19(auth)
fmt.Printf("%+v\n", covid19)
cryptoCandles, _, err := finnhubClient.CryptoCandles(auth, "BINANCE:BTCUSDT", "D", 1590988249, 1591852249)
fmt.Printf("%+v\n", cryptoCandles)
cryptoExchange, _, err := finnhubClient.CryptoExchanges(auth)
fmt.Printf("%+v\n", cryptoExchange)
cryptoSymbol, _, err := finnhubClient.CryptoSymbols(auth, "BINANCE")
fmt.Printf("%+v\n", cryptoSymbol[0:5])
earningsCalendar, _, err := finnhubClient.EarningsCalendar(auth, &finnhub.EarningsCalendarOpts{
From: optional.NewString("2020-06-12"), To: optional.NewString("2020-06-20")})
fmt.Printf("%+v\n", earningsCalendar)
economicCode, _, err := finnhubClient.EconomicCode(auth)
fmt.Printf("%+v\n", economicCode)
economicData, _, err := finnhubClient.EconomicData(auth, "MA-USA-656880")
fmt.Printf("%+v\n", economicData)
filings, _, err := finnhubClient.Filings(auth, &finnhub.FilingsOpts{Symbol: optional.NewString("AAPL")})
fmt.Printf("%+v\n", filings)
financials, _, err := finnhubClient.Financials(auth, "AAPL", "bs", "annual")
fmt.Printf("%+v\n", financials)
financialsReported, _, err := finnhubClient.FinancialsReported(auth, &finnhub.FinancialsReportedOpts{Symbol: optional.NewString("AAPL")})
fmt.Printf("%+v\n", financialsReported)
forexCandles, _, err := finnhubClient.ForexCandles(auth, "OANDA:EUR_USD", "D", 1590988249, 1591852249)
fmt.Printf("%+v\n", forexCandles)
forexExchanges, _, err := finnhubClient.ForexExchanges(auth)
fmt.Printf("%+v\n", forexExchanges)
forexRates, _, err := finnhubClient.ForexRates(auth, nil)
fmt.Printf("%+v\n", forexRates)
forexSymbols, _, err := finnhubClient.ForexSymbols(auth, "OANDA")
fmt.Printf("%+v\n", forexSymbols)
fundOwnership, _, err := finnhubClient.FundOwnership(auth, "AAPL", nil)
fmt.Printf("%+v\n", fundOwnership)
generalNews, _, err := finnhubClient.GeneralNews(auth, "general", nil)
fmt.Printf("%+v\n", generalNews)
ipoCalendar, _, err := finnhubClient.IpoCalendar(auth, "2020-01-01", "2020-06-15")
fmt.Printf("%+v\n", ipoCalendar)
majorDevelopment, _, err := finnhubClient.MajorDevelopments(auth, "AAPL", nil)
fmt.Printf("%+v\n", majorDevelopment)
newsSentiment, _, err := finnhubClient.NewsSentiment(auth, "AAPL")
fmt.Printf("%+v\n", newsSentiment)
patterns, _, err := finnhubClient.PatternRecognition(auth, "AAPL", "D")
fmt.Printf("%+v\n", patterns)
priceTarget, _, err := finnhubClient.PriceTarget(auth, "AAPL")
fmt.Printf("%+v\n", priceTarget)
quote, _, err := finnhubClient.Quote(auth, "AAPL")
fmt.Printf("%+v\n", quote)
recommendationTrend, _, err := finnhubClient.RecommendationTrends(auth, "AAPL")
fmt.Printf("%+v\n", recommendationTrend)
dividends, _, err := finnhubClient.StockDividends(auth, "KO", "2019-01-01", "2020-06-30")
fmt.Printf("%+v\n", dividends)
splits, _, err := finnhubClient.StockSplits(auth, "AAPL", "2000-01-01", "2020-06-15")
fmt.Printf("%+v\n", splits)
stockSymbols, _, err := finnhubClient.StockSymbols(auth, "US")
fmt.Printf("%+v\n", stockSymbols[0:5])
supportResitance, _, err := finnhubClient.SupportResistance(auth, "AAPL", "D")
fmt.Printf("%+v\n", supportResitance)
technicalIndicator, _, err := finnhubClient.TechnicalIndicator(auth, "AAPL", "D", 1583098857, 1584308457, "sma", &finnhub.TechnicalIndicatorOpts{
IndicatorFields: map[string]interface{}{
"timeperiod": 3,
},
})
fmt.Printf("%+v\n", technicalIndicator)
transcripts, _, err := finnhubClient.Transcripts(auth, "AAPL_162777")
fmt.Printf("%+v\n", transcripts)
transcriptsList, _, err := finnhubClient.TranscriptsList(auth, "AAPL")
fmt.Printf("%+v\n", transcriptsList)
upgradeDowngrade, _, err := finnhubClient.UpgradeDowngrade(auth, &finnhub.UpgradeDowngradeOpts{Symbol: optional.NewString("BYND")})
fmt.Printf("%+v\n", upgradeDowngrade)
tickData, _, err := client.StockTick(auth, "AAPL", "2020-03-25", 500, 0)
fmt.Printf("%+v\n", tickData)
indicesConstData, _, err := client.IndicesConstituents(auth, "^GSPC")
fmt.Printf("%+v\n", indicesConstData)
indicesHistoricalConstData, _, err := client.IndicesHistoricalConstituents(auth, "^GSPC")
fmt.Printf("%+v\n", indicesHistoricalConstData)
etfsProfileData, _, err := client.EtfsProfile(auth, "^GSPC")
fmt.Printf("%+v\n", etfsProfileData)
etfsHoldingsData, _, err := client.EtfsHoldings(auth, "^GSPC")
fmt.Printf("%+v\n", etfsHoldingsData)
etfsIndustryExposureData, _, err := client.EtfsIndustryExposure(auth, "^GSPC")
fmt.Printf("%+v\n", etfsIndustryExposureData)
etfsCountryExposureData, _, err := client.EtfsCountryExposure(auth, "^GSPC")
fmt.Printf("%+v\n", etfsCountryExposureData)
}
License
Apache License