### Installation
Source: https://context7.com/finnhub-stock-api/finnhub-go/llms.txt
Install the Finnhub Go client library using Go modules.
```APIDOC
## Installation
Install the package using Go modules.
```bash
go get -u github.com/Finnhub-Stock-API/finnhub-go/v2
```
```
--------------------------------
### Get Stock Bid-Ask Data in Go
Source: https://github.com/finnhub-stock-api/finnhub-go/blob/master/docs/DefaultApi.md
This Go example retrieves the latest bid and ask prices for a given stock symbol. It uses the Finnhub Go client and requires an API key.
```go
package main
import (
"context"
"fmt"
"os"
openapiclient "./openapi"
)
func main() {
symbol := "symbol_example" // string | Symbol.
configuration := openapiclient.NewConfiguration()
api_client := openapiclient.NewAPIClient(configuration)
resp, r, err := api_client.DefaultApi.StockBidask(context.Background()).Symbol(symbol).Execute()
if err != nil {
fmt.Fprintf(os.Stderr, "Error when calling `DefaultApi.StockBidask``: %v\n", err)
fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
}
// response from `StockBidask`: LastBidAsk
fmt.Fprintf(os.Stdout, "Response from `DefaultApi.StockBidask`: %v\n", resp)
}
```
--------------------------------
### Install Finnhub Go Client
Source: https://context7.com/finnhub-stock-api/finnhub-go/llms.txt
Install the Finnhub Go client library using Go modules. Ensure you are using the latest version.
```bash
go get -u github.com/Finnhub-Stock-API/finnhub-go/v2
```
--------------------------------
### Get Finnhub Go Client (v2) with go get
Source: https://github.com/finnhub-stock-api/finnhub-go/blob/master/README.md
Explicitly get the finnhub-go module version 2.0.20 into your project.
```shell
$ go get -u github.com/Finnhub-Stock-API/finnhub-go/v2
```
--------------------------------
### Get Company EPS Estimates Go Example
Source: https://github.com/finnhub-stock-api/finnhub-go/blob/master/docs/DefaultApi.md
Fetches Earnings Per Share (EPS) estimates for a company. Requires company symbol and frequency (annual/quarterly).
```go
package main
import (
"context"
"fmt"
"os"
openapiclient "./openapi"
)
func main() {
symbol := "symbol_example" // string | Symbol of the company: AAPL.
freq := "freq_example" // string | Can take 1 of the following values: annual, quarterly. Default to quarterly (optional)
configuration := openapiclient.NewConfiguration()
api_client := openapiclient.NewAPIClient(configuration)
resp, r, err := api_client.DefaultApi.CompanyEpsEstimates(context.Background()).Symbol(symbol).Freq(freq).Execute()
if err != nil {
fmt.Fprintf(os.Stderr, "Error when calling `DefaultApi.CompanyEpsEstimates``: %v\n", err)
fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
}
// response from `CompanyEpsEstimates`: EarningsEstimates
fmt.Fprintf(os.Stdout, "Response from `DefaultApi.CompanyEpsEstimates`: %v\n", resp)
}
```
--------------------------------
### Get Company EBITDA Estimates Go Example
Source: https://github.com/finnhub-stock-api/finnhub-go/blob/master/docs/DefaultApi.md
Fetches EBITDA estimates for a company. Requires company symbol and frequency (annual/quarterly).
```go
package main
import (
"context"
"fmt"
"os"
openapiclient "./openapi"
)
func main() {
symbol := "symbol_example" // string | Symbol of the company: AAPL.
freq := "freq_example" // string | Can take 1 of the following values: annual, quarterly. Default to quarterly (optional)
configuration := openapiclient.NewConfiguration()
api_client := openapiclient.NewAPIClient(configuration)
resp, r, err := api_client.DefaultApi.CompanyEbitdaEstimates(context.Background()).Symbol(symbol).Freq(freq).Execute()
if err != nil {
fmt.Fprintf(os.Stderr, "Error when calling `DefaultApi.CompanyEbitdaEstimates``: %v\n", err)
fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
}
// response from `CompanyEbitdaEstimates`: EbitdaEstimates
fmt.Fprintf(os.Stdout, "Response from `DefaultApi.CompanyEbitdaEstimates`: %v\n", resp)
}
```
--------------------------------
### Get Finnhub Go Client (without v2)
Source: https://github.com/finnhub-stock-api/finnhub-go/blob/master/README.md
Get the Finnhub Go client library directly if not using Go Modules. Note the absence of /v2 in the import path.
```shell
$ go get -u github.com/Finnhub-Stock-API/finnhub-go
```
--------------------------------
### Get Company ESG Score Go Example
Source: https://github.com/finnhub-stock-api/finnhub-go/blob/master/docs/DefaultApi.md
Fetches the ESG score for a given company symbol.
```go
CompanyESG CompanyEsgScore(ctx).Symbol(symbol).Execute()
```
--------------------------------
### Initialize Finnhub Client and Fetch Data
Source: https://github.com/finnhub-stock-api/finnhub-go/blob/master/README.md
Demonstrates initializing the Finnhub client with an API key and making various API calls for stock data, company information, and market data. Ensure you replace '' with your actual Finnhub API key.
```golang
package main
import (
"context"
"fmt"
finnhub "github.com/Finnhub-Stock-API/finnhub-go/v2"
)
func main() {
cfg := finnhub.NewConfiguration()
cfg.AddDefaultHeader("X-Finnhub-Token", "")
finnhubClient := finnhub.NewAPIClient(cfg).DefaultApi
//Earnings calendar
earningsCalendar, _, err := finnhubClient.EarningsCalendar(context.Background()).From("2021-07-01").To("2021-07-25").Execute()
fmt.Printf("%+v\n", earningsCalendar)
// NBBO
bboData, _, err := finnhubClient.StockNbbo(context.Background()).Symbol("AAPL").Date("2021-07-23").Limit(50).Skip(0).Execute()
fmt.Printf("%+v\n", bboData)
// Bid ask
lastBidAsk, _, err := finnhubClient.StockBidask(context.Background()).Symbol("AAPL").Execute()
fmt.Printf("%+v\n", lastBidAsk)
// Stock dividends 2
dividends2, _, err := finnhubClient.StockBasicDividends(context.Background()).Symbol("KO").Execute()
fmt.Printf("%+v\n", dividends2)
//Stock candles
stockCandles, _, err := finnhubClient.StockCandles(context.Background()).Symbol("AAPL").Resolution("D").From(1590988249).To(1591852249).Execute()
fmt.Printf("%+v\n", stockCandles)
// Example with required parameters
news, _, err := finnhubClient.CompanyNews(context.Background()).Symbol("AAPL").From("2020-05-01").To("2020-05-01").Execute()
if err != nil {
fmt.Println(err)
}
fmt.Printf("%+v\n", news)
// Example with required and optional parameters
ownerships, _, err := finnhubClient.Ownership(context.Background()).Symbol("AAPL").Execute()
fmt.Printf("%+v\n", ownerships)
// Aggregate Indicator
aggregateIndicator, _, err := finnhubClient.AggregateIndicator(context.Background()).Symbol("AAPL").Resolution("D").Execute()
fmt.Printf("%+v\n", aggregateIndicator)
// Basic financials
basicFinancials, _, err := finnhubClient.CompanyBasicFinancials(context.Background()).Symbol("MSFT").Metric("all").Execute()
fmt.Printf("%+v\n", basicFinancials)
// Company earnings
earningsSurprises, _, err := finnhubClient.CompanyEarnings(context.Background()).Symbol("AAPL").Execute()
fmt.Printf("%+v\n", earningsSurprises)
// Company EPS estimates
epsEstimate, _, err := finnhubClient.CompanyEpsEstimates(context.Background()).Symbol("AAPL").Execute()
fmt.Printf("%+v\n", epsEstimate)
// Company executive
executive, _, err := finnhubClient.CompanyExecutive(context.Background()).Symbol("AAPL").Execute()
fmt.Printf("%+v\n", executive)
// Company peers
peers, _, err := finnhubClient.CompanyPeers(context.Background()).Symbol("AAPL").Execute()
fmt.Printf("%+v\n", peers)
// Company profile
profile, _, err := finnhubClient.CompanyProfile(context.Background()).Symbol("AAPL").Execute()
fmt.Printf("%+v\n", profile)
profileISIN, _, err := finnhubClient.CompanyProfile(context.Background()).Isin("US0378331005").Execute()
fmt.Printf("%+v\n", profileISIN)
profileCusip, _, err := finnhubClient.CompanyProfile(context.Background()).Cusip("037833100").Execute()
fmt.Printf("%+v\n", profileCusip)
// Company profile2
profile2, _, err := finnhubClient.CompanyProfile2(context.Background()).Symbol("AAPL").Execute()
fmt.Printf("%+v\n", profile2)
// Revenue Estimates
revenueEstimates, _, err := finnhubClient.CompanyRevenueEstimates(context.Background()).Symbol("AAPL").Execute()
fmt.Printf("%+v\n", revenueEstimates)
// List country
countries, _, err := finnhubClient.Country(context.Background()).Execute()
fmt.Printf("%+v\n", countries)
// Covid-19
covid19, _, err := finnhubClient.Covid19(context.Background()).Execute()
fmt.Printf("%+v\n", covid19)
// FDA Calendar
fdaCalendar, _, err := finnhubClient.FdaCommitteeMeetingCalendar(context.Background()).Execute()
fmt.Printf("%+v\n", fdaCalendar)
// Crypto candles
cryptoCandles, _, err := finnhubClient.CryptoCandles(context.Background()).Symbol("BINANCE:BTCUSDT").Resolution("D").From(1590988249).To(1591852249).Execute()
fmt.Printf("%+v\n", cryptoCandles)
// Crypto exchanges
cryptoExchange, _, err := finnhubClient.CryptoExchanges(context.Background()).Execute()
fmt.Printf("%+v\n", cryptoExchange)
// Crypto symbols
cryptoSymbol, _, err := finnhubClient.CryptoSymbols(context.Background()).Exchange("BINANCE").Execute()
fmt.Printf("%+v\n", cryptoSymbol[0:5])
// Economic Calendar
economicCalendar, _, err := finnhubClient.EconomicCalendar(context.Background()).Execute()
fmt.Printf("%+v\n", economicCalendar)
// Economic code
economicCode, _, err := finnhubClient.EconomicCode(context.Background()).Execute()
fmt.Printf("%+v\n", economicCode)
// Economic data
```
--------------------------------
### Get Market News in Go
Source: https://github.com/finnhub-stock-api/finnhub-go/blob/master/docs/DefaultApi.md
Retrieves market news, optionally filtering by category and a minimum ID. Requires the Finnhub Go client setup.
```go
package main
import (
"context"
"fmt"
"os"
openapiclient "./openapi"
)
func main() {
category := "category_example" // string | This parameter can be 1 of the following values general, forex, crypto, merger.
minId := int64(789) // int64 | Use this field to get only news after this ID. Default to 0 (optional)
configuration := openapiclient.NewConfiguration()
api_client := openapiclient.NewAPIClient(configuration)
resp, r, err := api_client.DefaultApi.MarketNews(context.Background()).Category(category).MinId(minId).Execute()
if err != nil {
fmt.Fprintf(os.Stderr, "Error when calling `DefaultApi.MarketNews``: %v\n", err)
fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
}
// response from `MarketNews`: []MarketNews
fmt.Fprintf(os.Stdout, "Response from `DefaultApi.MarketNews`: %v\n", resp)
}
```
--------------------------------
### Initialize Go Modules
Source: https://github.com/finnhub-stock-api/finnhub-go/blob/master/README.md
Run this command in your project's root directory to initialize Go Modules.
```sh
go mod init
```
--------------------------------
### Initialize Finnhub API Client
Source: https://context7.com/finnhub-stock-api/finnhub-go/llms.txt
Create and configure the Finnhub API client with your API key. The API key is added as a default header.
```go
package main
import (
"context"
finnhub "github.com/Finnhub-Stock-API/finnhub-go/v2"
)
func main() {
cfg := finnhub.NewConfiguration()
cfg.AddDefaultHeader("X-Finnhub-Token", "YOUR_API_KEY")
finnhubClient := finnhub.NewAPIClient(cfg).DefaultApi
// Client is now ready to use
}
```
--------------------------------
### Get Indices Historical Constituents Go Example
Source: https://github.com/finnhub-stock-api/finnhub-go/blob/master/docs/DefaultApi.md
Retrieves historical constituents for a given stock index symbol. Requires setting up the API client and providing the symbol.
```go
package main
import (
"context"
"fmt"
"os"
openapiclient "./openapi"
)
func main() {
symbol := "symbol_example" // string | symbol
configuration := openapiclient.NewConfiguration()
api_client := openapiclient.NewAPIClient(configuration)
resp, r, err := api_client.DefaultApi.IndicesHistoricalConstituents(context.Background()).Symbol(symbol).Execute()
if err != nil {
fmt.Fprintf(os.Stderr, "Error when calling `DefaultApi.IndicesHistoricalConstituents``: %v\n", err)
fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
}
// response from `IndicesHistoricalConstituents`: IndicesHistoricalConstituents
fmt.Fprintf(os.Stdout, "Response from `DefaultApi.IndicesHistoricalConstituents`: %v\n", resp)
}
```
--------------------------------
### Get Bond Price Data
Source: https://github.com/finnhub-stock-api/finnhub-go/blob/master/docs/DefaultApi.md
Retrieve historical bond price data using ISIN, start, and end timestamps. Ensure the `openapi` package is imported correctly.
```go
package main
import (
"context"
"fmt"
"os"
openapiclient "./openapi"
)
func main() {
isin := "isin_example" // string | ISIN.
from := int64(789) // int64 | UNIX timestamp. Interval initial value.
to := int64(789) // int64 | UNIX timestamp. Interval end value.
configuration := openapiclient.NewConfiguration()
api_client := openapiclient.NewAPIClient(configuration)
resp, r, err := api_client.DefaultApi.BondPrice(context.Background()).Isin(isin).From(from).To(to).Execute()
if err != nil {
fmt.Fprintf(os.Stderr, "Error when calling `DefaultApi.BondPrice``: %v\n", err)
fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
}
// response from `BondPrice`: BondCandles
fmt.Fprintf(os.Stdout, "Response from `DefaultApi.BondPrice`: %v\n", resp)
}
```
--------------------------------
### NewInstitutionalProfileInfoWithDefaults Constructor
Source: https://github.com/finnhub-stock-api/finnhub-go/blob/master/docs/InstitutionalProfileInfo.md
Instantiates a new InstitutionalProfileInfo object with default values. Does not guarantee that properties required by the API are set.
```go
func NewInstitutionalProfileInfoWithDefaults() *InstitutionalProfileInfo
```
--------------------------------
### Get ETF Country Exposure with Go
Source: https://github.com/finnhub-stock-api/finnhub-go/blob/master/docs/DefaultApi.md
Retrieve country exposure data for ETFs by providing either the ETF symbol or ISIN. The client setup is standard for API calls.
```go
package main
import (
"context"
"fmt"
"os"
openapiclient "./openapi"
)
func main() {
symbol := "symbol_example" // string | ETF symbol. (optional)
isin := "isin_example" // string | ETF isin. (optional)
configuration := openapiclient.NewConfiguration()
api_client := openapiclient.NewAPIClient(configuration)
resp, r, err := api_client.DefaultApi.EtfsCountryExposure(context.Background()).Symbol(symbol).Isin(isin).Execute()
if err != nil {
fmt.Fprintf(os.Stderr, "Error when calling `DefaultApi.EtfsCountryExposure``: %v\n", err)
fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
}
// response from `EtfsCountryExposure`: ETFsCountryExposure
fmt.Fprintf(os.Stdout, "Response from `DefaultApi.EtfsCountryExposure`: %v\n", resp)
}
```
--------------------------------
### Instantiate NewsroomArticle with Defaults
Source: https://github.com/finnhub-stock-api/finnhub-go/blob/master/docs/NewsroomArticle.md
Use NewNewsroomArticleWithDefaults to create a new NewsroomArticle object, assigning only default values to properties that have them defined.
```go
func NewNewsroomArticleWithDefaults() *NewsroomArticle
```
--------------------------------
### Get Insider Sentiment Go Example
Source: https://github.com/finnhub-stock-api/finnhub-go/blob/master/docs/DefaultApi.md
Fetches insider sentiment data for a company symbol within a specified date range. Ensure to provide valid dates and the company symbol.
```go
package main
import (
"context"
"fmt"
"os"
"time"
openapiclient "./openapi"
)
func main() {
symbol := "symbol_example" // string | Symbol of the company: AAPL.
from := time.Now() // string | From date: 2020-03-15.
to := time.Now() // string | To date: 2020-03-16.
configuration := openapiclient.NewConfiguration()
api_client := openapiclient.NewAPIClient(configuration)
resp, r, err := api_client.DefaultApi.InsiderSentiment(context.Background()).Symbol(symbol).From(from).To(to).Execute()
if err != nil {
fmt.Fprintf(os.Stderr, "Error when calling `DefaultApi.InsiderSentiment``: %v\n", err)
fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
}
// response from `InsiderSentiment`: InsiderSentiments
fmt.Fprintf(os.Stdout, "Response from `DefaultApi.InsiderSentiment`: %v\n", resp)
}
```
--------------------------------
### NewSupportResistanceWithDefaults Constructor
Source: https://github.com/finnhub-stock-api/finnhub-go/blob/master/docs/SupportResistance.md
Instantiates a new SupportResistance object with default values. Does not guarantee that properties required by the API are set.
```go
func NewSupportResistanceWithDefaults() *SupportResistance
```
--------------------------------
### Get ETF Holdings (Go)
Source: https://github.com/finnhub-stock-api/finnhub-go/blob/master/docs/DefaultApi.md
Retrieves the holdings of an ETF, optionally by date or by skipping a number of results. This Go example demonstrates querying historical or latest ETF constituents.
```Go
package main
import (
"context"
"fmt"
"os"
openapiclient "./openapi"
)
func main() {
symbol := "symbol_example" // string | ETF symbol. (optional)
isin := "isin_example" // string | ETF isin. (optional)
skip := int64(789) // int64 | Skip the first n results. You can use this parameter to query historical constituents data. The latest result is returned if skip=0 or not set. (optional)
date := "date_example" // string | Query holdings by date. You can use either this param or skip param, not both. (optional)
configuration := openapiclient.NewConfiguration()
api_client := openapiclient.NewAPIClient(configuration)
resp, r, err := api_client.DefaultApi.EtfsHoldings(context.Background()).Symbol(symbol).Isin(isin).Skip(skip).Date(date).Execute()
if err != nil {
fmt.Fprintf(os.Stderr, "Error when calling `DefaultApi.EtfsHoldings``: %v\n", err)
fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
}
// response from `EtfsHoldings`: ETFsHoldings
fmt.Fprintf(os.Stdout, "Response from `DefaultApi.EtfsHoldings`: %v\n", resp)
}
```
--------------------------------
### Client Initialization
Source: https://context7.com/finnhub-stock-api/finnhub-go/llms.txt
Initialize and configure the Finnhub API client with your API key.
```APIDOC
## Client Initialization
Create and configure the Finnhub API client with your API key.
```go
package main
import (
"context"
finnhub "github.com/Finnhub-Stock-API/finnhub-go/v2"
)
func main() {
cfg := finnhub.NewConfiguration()
cfg.AddDefaultHeader("X-Finnhub-Token", "YOUR_API_KEY")
finnhubClient := finnhub.NewAPIClient(cfg).DefaultApi
// Client is now ready to use
}
```
```
--------------------------------
### MarketStatus Constructor Methods
Source: https://github.com/finnhub-stock-api/finnhub-go/blob/master/docs/MarketStatus.md
Information on how to create new instances of the MarketStatus model.
```APIDOC
## MarketStatus Constructors
### NewMarketStatus
`func NewMarketStatus() *MarketStatus`
**Description:** Instantiates a new MarketStatus object. This constructor assigns default values to properties that have them defined and ensures properties required by the API are set. The set of arguments may change if the set of required properties changes.
### NewMarketStatusWithDefaults
`func NewMarketStatusWithDefaults() *MarketStatus`
**Description:** Instantiates a new MarketStatus object. This constructor only assigns default values to properties that have them defined, but it doesn't guarantee that properties required by the API are set.
```
--------------------------------
### Get Investment Themes (Go)
Source: https://github.com/finnhub-stock-api/finnhub-go/blob/master/docs/DefaultApi.md
Use this to retrieve a list of supported investment themes. Ensure the `theme` variable is set to a valid theme string.
```go
package main
import (
"context"
"fmt"
"os"
openapiclient "./openapi"
)
func main() {
theme := "theme_example" // string | Investment theme. A full list of themes supported can be found here.
configuration := openapiclient.NewConfiguration()
api_client := openapiclient.NewAPIClient(configuration)
resp, r, err := api_client.DefaultApi.InvestmentThemes(context.Background()).Theme(theme).Execute()
if err != nil {
fmt.Fprintf(os.Stderr, "Error when calling `DefaultApi.InvestmentThemes``: %v\n", err)
fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
}
// response from `InvestmentThemes`: InvestmentThemes
fmt.Fprintf(os.Stdout, "Response from `DefaultApi.InvestmentThemes`: %v\n", resp)
}
```
--------------------------------
### Get USA Spending Data with Finnhub Go API
Source: https://github.com/finnhub-stock-api/finnhub-go/blob/master/docs/DefaultApi.md
This Go code snippet shows how to retrieve USA spending data using the Finnhub Go API. It utilizes the Finnhub Go client library and requires a stock symbol, a start date, and an end date. The function returns USA spending results or an error.
```Go
package main
import (
"context"
"fmt"
"os"
"time"
openapiclient "./openapi"
)
func main() {
symbol := "symbol_example" // string | Symbol.
from := time.Now() // string | From date YYYY-MM-DD. Filter for actionDate
to := time.Now() // string | To date YYYY-MM-DD. Filter for actionDate
configuration := openapiclient.NewConfiguration()
api_client := openapiclient.NewAPIClient(configuration)
resp, r, err := api_client.DefaultApi.StockUsaSpending(context.Background()).Symbol(symbol).From(from).To(to).Execute()
if err != nil {
fmt.Fprintf(os.Stderr, "Error when calling `DefaultApi.StockUsaSpending``: %v\n", err)
fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
}
// response from `StockUsaSpending`: UsaSpendingResult
fmt.Fprintf(os.Stdout, "Response from `DefaultApi.StockUsaSpending`: %v\n", resp)
}
```
--------------------------------
### MutualFundProfileData - Currency Methods
Source: https://github.com/finnhub-stock-api/finnhub-go/blob/master/docs/MutualFundProfileData.md
Methods for getting, getting with ok status, and setting the Currency field.
```APIDOC
## GetCurrency
### Description
Returns the Currency field. If the field is nil, it returns the zero value for a string.
### Method
`GetCurrency`
### Response
- **string** - The value of the Currency field.
### Response Example
```go
currency := mutualFundProfileData.GetCurrency()
```
## GetCurrencyOk
### Description
Returns a tuple containing the Currency field and a boolean indicating if the field has been set.
### Method
`GetCurrencyOk`
### Response
- **(*string, bool)** - A pointer to the Currency string and a boolean. The boolean is true if the field has been set, false otherwise.
### Response Example
```go
currency, ok := mutualFundProfileData.GetCurrencyOk()
```
## SetCurrency
### Description
Sets the Currency field to the given value.
### Method
`SetCurrency`
### Parameters
- **v** (string) - Required - The value to set for Currency.
### Request Example
```go
mutualFundProfileData.SetCurrency("USD")
```
## HasCurrency
### Description
Returns a boolean indicating if the Currency field has been set.
### Method
`HasCurrency`
### Response
- **bool** - True if the field has been set, false otherwise.
### Response Example
```go
hasSet := mutualFundProfileData.HasCurrency()
```
```
--------------------------------
### Instantiate NewsroomArticle
Source: https://github.com/finnhub-stock-api/finnhub-go/blob/master/docs/NewsroomArticle.md
Use NewNewsroomArticle to create a new NewsroomArticle object. This constructor initializes default values and ensures required properties are set.
```go
func NewNewsroomArticle() *NewsroomArticle
```
--------------------------------
### NewForexSymbol Constructor
Source: https://github.com/finnhub-stock-api/finnhub-go/blob/master/docs/ForexSymbol.md
Instantiates a new ForexSymbol object. Assigns default values to properties and ensures required API properties are set.
```go
func NewForexSymbol() *ForexSymbol {
return &ForexSymbol{}
}
```
--------------------------------
### MutualFundProfileData - SfdrClassification Methods
Source: https://github.com/finnhub-stock-api/finnhub-go/blob/master/docs/MutualFundProfileData.md
Methods for getting, getting with ok status, and setting the SfdrClassification field.
```APIDOC
## GetSfdrClassification
### Description
Returns the SfdrClassification field. If the field is nil, it returns the zero value for a string.
### Method
`GetSfdrClassification`
### Response
- **string** - The value of the SfdrClassification field.
### Response Example
```go
sfdrClassification := mutualFundProfileData.GetSfdrClassification()
```
## GetSfdrClassificationOk
### Description
Returns a tuple containing the SfdrClassification field and a boolean indicating if the field has been set.
### Method
`GetSfdrClassificationOk`
### Response
- **(*string, bool)** - A pointer to the SfdrClassification string and a boolean. The boolean is true if the field has been set, false otherwise.
### Response Example
```go
sfdrClassification, ok := mutualFundProfileData.GetSfdrClassificationOk()
```
## SetSfdrClassification
### Description
Sets the SfdrClassification field to the given value.
### Method
`SetSfdrClassification`
### Parameters
- **v** (string) - Required - The value to set for SfdrClassification.
### Request Example
```go
mutualFundProfileData.SetSfdrClassification("someSfdrClassification")
```
## HasSfdrClassification
### Description
Returns a boolean indicating if the SfdrClassification field has been set.
### Method
`HasSfdrClassification`
### Response
- **bool** - True if the field has been set, false otherwise.
### Response Example
```go
hasSet := mutualFundProfileData.HasSfdrClassification()
```
```
--------------------------------
### MutualFundProfileData - ClassName Methods
Source: https://github.com/finnhub-stock-api/finnhub-go/blob/master/docs/MutualFundProfileData.md
Methods for getting, getting with ok status, and setting the ClassName field.
```APIDOC
## GetClassName
### Description
Returns the ClassName field. If the field is nil, it returns the zero value for a string.
### Method
`GetClassName`
### Response
- **string** - The value of the ClassName field.
### Response Example
```go
className := mutualFundProfileData.GetClassName()
```
## GetClassNameOk
### Description
Returns a tuple containing the ClassName field and a boolean indicating if the field has been set.
### Method
`GetClassNameOk`
### Response
- **(*string, bool)** - A pointer to the ClassName string and a boolean. The boolean is true if the field has been set, false otherwise.
### Response Example
```go
className, ok := mutualFundProfileData.GetClassNameOk()
```
## SetClassName
### Description
Sets the ClassName field to the given value.
### Method
`SetClassName`
### Parameters
- **v** (string) - Required - The value to set for ClassName.
### Request Example
```go
mutualFundProfileData.SetClassName("someClassName")
```
## HasClassName
### Description
Returns a boolean indicating if the ClassName field has been set.
### Method
`HasClassName`
### Response
- **bool** - True if the field has been set, false otherwise.
### Response Example
```go
hasSet := mutualFundProfileData.HasClassName()
```
```
--------------------------------
### NewOwnershipInfoWithDefaults Constructor
Source: https://github.com/finnhub-stock-api/finnhub-go/blob/master/docs/OwnershipInfo.md
Instantiates a new OwnershipInfo object, assigning default values only to properties that have them defined. It does not guarantee that API-required properties are set.
```go
func NewOwnershipInfoWithDefaults() *OwnershipInfo
```
--------------------------------
### GET /forexrates
Source: https://github.com/finnhub-stock-api/finnhub-go/blob/master/docs/DefaultApi.md
Retrieves foreign exchange rates. You can specify a base currency and a date to get historical data.
```APIDOC
## GET /forexrates
### Description
Retrieves foreign exchange rates. You can specify a base currency and a date to get historical data.
### Method
GET
### Endpoint
/forexrates
### Query Parameters
- **base** (string) - Optional - Base currency. Default to EUR.
- **date** (string) - Optional - Date. Leave blank to get the latest data.
### Request Example
```go
package main
import (
"context"
"fmt"
"os"
openapiclient "./openapi"
)
func main() {
base := "base_example" // string | Base currency. Default to EUR. (optional)
date := "date_example" // string | Date. Leave blank to get the latest data. (optional)
configuration := openapiclient.NewConfiguration()
api_client := openapiclient.NewAPIClient(configuration)
resp, r, err := api_client.DefaultApi.ForexRates(context.Background()).Base(base).Date(date).Execute()
if err != nil {
fmt.Fprintf(os.Stderr, "Error when calling `DefaultApi.ForexRates``: %v\n", err)
fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
}
// response from `ForexRates`: Forexrates
fmt.Fprintf(os.Stdout, "Response from `DefaultApi.ForexRates`: %v\n", resp)
}
```
### Response
#### Success Response (200)
- **Forexrates** (Forexrates) - Description of the returned Forexrates object
#### Response Example
```json
{
"example": "response body"
}
```
```
--------------------------------
### NewSupportResistance Constructor
Source: https://github.com/finnhub-stock-api/finnhub-go/blob/master/docs/SupportResistance.md
Instantiates a new SupportResistance object. Assigns default values to properties and ensures required API properties are set.
```go
func NewSupportResistance() *SupportResistance
```
--------------------------------
### LobbyingData - HouseregistrantId Management
Source: https://github.com/finnhub-stock-api/finnhub-go/blob/master/docs/LobbyingData.md
Provides methods to get, get with status, set, and check for the existence of the HouseregistrantId field in the LobbyingData model.
```APIDOC
## GetHouseregistrantId
### Description
GetHouseregistrantId returns the HouseregistrantId field if non-nil, zero value otherwise.
### Method
GET (conceptual)
### Endpoint
N/A (Model method)
### Parameters
None
### Request Example
None
### Response
#### Success Response (200)
- **HouseregistrantId** (string) - The HouseregistrantId value or zero value if nil.
#### Response Example
"some_id"
## GetHouseregistrantIdOk
### Description
GetHouseregistrantIdOk returns a tuple with the HouseregistrantId field if it's non-nil, zero value otherwise and a boolean to check if the value has been set.
### Method
GET (conceptual)
### Endpoint
N/A (Model method)
### Parameters
None
### Request Example
None
### Response
#### Success Response (200)
- **HouseregistrantId** (string) - The HouseregistrantId value or zero value if nil.
- **isSet** (bool) - True if the HouseregistrantId field has been set, false otherwise.
#### Response Example
["some_id", true]
## SetHouseregistrantId
### Description
SetHouseregistrantId sets HouseregistrantId field to given value.
### Method
POST/PUT (conceptual)
### Endpoint
N/A (Model method)
### Parameters
#### Request Body
- **v** (string) - Required - The value to set for HouseregistrantId.
### Request Example
{
"v": "new_id"
}
### Response
#### Success Response (200)
No content returned.
## HasHouseregistrantId
### Description
HasHouseregistrantId returns a boolean if a field has been set.
### Method
GET (conceptual)
### Endpoint
N/A (Model method)
### Parameters
None
### Request Example
None
### Response
#### Success Response (200)
- **hasSet** (bool) - True if the HouseregistrantId field has been set, false otherwise.
#### Response Example
true
```
--------------------------------
### Get Support/Resistance Levels (Go)
Source: https://github.com/finnhub-stock-api/finnhub-go/blob/master/docs/DefaultApi.md
Use this to fetch support and resistance levels for a specific stock symbol and resolution. Ensure the correct symbol and resolution (e.g., '1', 'D', 'W') are provided.
```go
package main
import (
"context"
"fmt"
"os"
openapiclient "./openapi"
)
func main() {
symbol := "symbol_example" // string | Symbol
resolution := "resolution_example" // string | Supported resolution includes 1, 5, 15, 30, 60, D, W, M .Some timeframes might not be available depending on the exchange.
configuration := openapiclient.NewConfiguration()
api_client := openapiclient.NewAPIClient(configuration)
resp, r, err := api_client.DefaultApi.SupportResistance(context.Background()).Symbol(symbol).Resolution(resolution).Execute()
if err != nil {
fmt.Fprintf(os.Stderr, "Error when calling `DefaultApi.SupportResistance``: %v\n", err)
fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
}
// response from `SupportResistance`: SupportResistance
fmt.Fprintf(os.Stdout, "Response from `DefaultApi.SupportResistance`: %v\n", resp)
}
```
--------------------------------
### New RevenueEstimatesInfoWithDefaults Constructor
Source: https://github.com/finnhub-stock-api/finnhub-go/blob/master/docs/RevenueEstimatesInfo.md
Instantiates a new RevenueEstimatesInfo object with default values. This constructor only assigns default values to properties that have them defined and does not guarantee that properties required by the API are set.
```go
func NewRevenueEstimatesInfoWithDefaults() *RevenueEstimatesInfo {
return &RevenueEstimatesInfo{}
}
```
--------------------------------
### Import Finnhub Go Client (v2)
Source: https://github.com/finnhub-stock-api/finnhub-go/blob/master/README.md
Import the Finnhub Go client library version 2.0.20 into your Go program.
```go
import (
finnhub "github.com/Finnhub-Stock-API/finnhub-go/v2"
)
```
--------------------------------
### Get Twitter Positive Score
Source: https://github.com/finnhub-stock-api/finnhub-go/blob/master/docs/TwitterSentimentContent.md
Retrieves the positive sentiment score, ranging from 0 to 1. Use GetPositiveScoreOk to get the value and check if it's set.
```go
func (o *TwitterSentimentContent) GetPositiveScore() float32
func (o *TwitterSentimentContent) GetPositiveScoreOk() (*float32, bool)
```
--------------------------------
### Get Response Status (S)
Source: https://github.com/finnhub-stock-api/finnhub-go/blob/master/docs/ForexCandles.md
GetS returns the S field (response status) if it's non-nil, otherwise it returns the zero value. Use GetSOk to check if the field has been set.
```go
func (o *ForexCandles) GetS() string {
if o == nil {
return ""
}
return o.S
}
```
```go
func (o *ForexCandles) GetSOk() (*string, bool) {
if o == nil || o.S == nil {
return nil, false
}
return &o.S, true
}
```
--------------------------------
### NewEbitEstimatesInfo Constructor
Source: https://github.com/finnhub-stock-api/finnhub-go/blob/master/docs/EbitEstimatesInfo.md
Instantiates a new EbitEstimatesInfo object. It assigns default values to properties with defaults defined and ensures required API properties are set.
```go
func NewEbitEstimatesInfo() *EbitEstimatesInfo {
return &EbitEstimatesInfo{}
}
```
--------------------------------
### NewEbitEstimatesInfoWithDefaults Constructor
Source: https://github.com/finnhub-stock-api/finnhub-go/blob/master/docs/EbitEstimatesInfo.md
Instantiates a new EbitEstimatesInfo object with default values. This constructor only assigns default values to properties that have them defined and does not guarantee that all required API properties are set.
```go
func NewEbitEstimatesInfoWithDefaults() *EbitEstimatesInfo {
return &EbitEstimatesInfo{}
}
```
--------------------------------
### NewForexSymbolWithDefaults Constructor
Source: https://github.com/finnhub-stock-api/finnhub-go/blob/master/docs/ForexSymbol.md
Instantiates a new ForexSymbol object with default values. Does not guarantee that properties required by the API are set.
```go
func NewForexSymbolWithDefaults() *ForexSymbol {
return &ForexSymbol{}
}
```
--------------------------------
### Get Quarter Field Value and Status
Source: https://github.com/finnhub-stock-api/finnhub-go/blob/master/docs/RevenueEstimatesInfo.md
Use GetQuarterOk to get the Quarter field's value and a boolean indicating its set status. This helps differentiate between a zero value and an unset field.
```go
func (o *RevenueEstimatesInfo) GetQuarterOk() (*int64, bool)
```
--------------------------------
### Ownership API
Source: https://github.com/finnhub-stock-api/finnhub-go/blob/master/docs/DefaultApi.md
Get ownership details for a stock.
```APIDOC
## GET /stock/ownership
### Description
Retrieves ownership details for a specified stock.
### Method
GET
### Endpoint
/stock/ownership
```
--------------------------------
### Instantiate EbitdaEstimatesInfo with Defaults
Source: https://github.com/finnhub-stock-api/finnhub-go/blob/master/docs/EbitdaEstimatesInfo.md
Use NewEbitdaEstimatesInfoWithDefaults to create a new EbitdaEstimatesInfo object. This constructor only assigns default values to properties that have them defined, without guaranteeing that required API properties are set.
```go
func NewEbitdaEstimatesInfoWithDefaults() *EbitdaEstimatesInfo
```
--------------------------------
### Forex Rates API
Source: https://github.com/finnhub-stock-api/finnhub-go/blob/master/docs/DefaultApi.md
Get forex rates.
```APIDOC
## GET /forex/rates
### Description
Forex rates.
### Method
GET
### Endpoint
/forex/rates
### Parameters
#### Query Parameters
- **base** (string) - Optional - Base currency
- **quote** (string) - Optional - Quote currency
```
--------------------------------
### NewIsinChangeInfoWithDefaults Constructor
Source: https://github.com/finnhub-stock-api/finnhub-go/blob/master/docs/IsinChangeInfo.md
Instantiates a new IsinChangeInfo object with default values. Does not guarantee that properties required by the API are set.
```go
func NewIsinChangeInfoWithDefaults() *IsinChangeInfo {
}
```
--------------------------------
### Instantiate EbitdaEstimatesInfo
Source: https://github.com/finnhub-stock-api/finnhub-go/blob/master/docs/EbitdaEstimatesInfo.md
Use NewEbitdaEstimatesInfo to create a new EbitdaEstimatesInfo object. This constructor initializes default values for properties that have them defined and ensures required API properties are set.
```go
func NewEbitdaEstimatesInfo() *EbitdaEstimatesInfo
```
--------------------------------
### Financials API
Source: https://github.com/finnhub-stock-api/finnhub-go/blob/master/docs/DefaultApi.md
Get financial statements for a company.
```APIDOC
## GET /stock/financials
### Description
Financial Statements.
### Method
GET
### Endpoint
/stock/financials
### Parameters
#### Query Parameters
- **symbol** (string) - Required - Stock symbol
- **period** (string) - Optional - "annual" or "quarterly"
- **statement** (string) - Optional - "income", "balance", "cashflow"
```
--------------------------------
### ETFs Profile API
Source: https://github.com/finnhub-stock-api/finnhub-go/blob/master/docs/DefaultApi.md
Get ETFs profile.
```APIDOC
## GET /etf/profile
### Description
ETFs Profile.
### Method
GET
### Endpoint
/etf/profile
### Parameters
#### Query Parameters
- **symbol** (string) - Required - ETF symbol
```
--------------------------------
### Instantiate CompanyProfile2
Source: https://github.com/finnhub-stock-api/finnhub-go/blob/master/docs/CompanyProfile2.md
Use NewCompanyProfile2 to create a new CompanyProfile2 object. This constructor initializes default values for properties.
```go
func NewCompanyProfile2() *CompanyProfile2
```
--------------------------------
### ETFs Holdings API
Source: https://github.com/finnhub-stock-api/finnhub-go/blob/master/docs/DefaultApi.md
Get ETFs holdings.
```APIDOC
## GET /etf/holdings
### Description
ETFs Holdings.
### Method
GET
### Endpoint
/etf/holdings
### Parameters
#### Query Parameters
- **symbol** (string) - Required - ETF symbol
```
--------------------------------
### NewIsinChangeInfo Constructor
Source: https://github.com/finnhub-stock-api/finnhub-go/blob/master/docs/IsinChangeInfo.md
Instantiates a new IsinChangeInfo object. Assigns default values to properties and ensures required API properties are set.
```go
func NewIsinChangeInfo() *IsinChangeInfo {
}
```
--------------------------------
### Economic Data API
Source: https://github.com/finnhub-stock-api/finnhub-go/blob/master/docs/DefaultApi.md
Get economic data.
```APIDOC
## GET /economic
### Description
Economic Data.
### Method
GET
### Endpoint
/economic
### Parameters
#### Query Parameters
- **country** (string) - Required - Country
- **economicCode** (string) - Required - Economic code
```
--------------------------------
### Crypto Profile API
Source: https://github.com/finnhub-stock-api/finnhub-go/blob/master/docs/DefaultApi.md
Get crypto profile.
```APIDOC
## GET /crypto/profile
### Description
Crypto Profile.
### Method
GET
### Endpoint
/crypto/profile
### Parameters
#### Query Parameters
- **symbol** (string) - Required - Crypto symbol
```
--------------------------------
### Instantiate New VisaApplication with Defaults
Source: https://github.com/finnhub-stock-api/finnhub-go/blob/master/docs/VisaApplication.md
Use NewVisaApplicationWithDefaults to create a new VisaApplication object, assigning only default values to properties that have them defined.
```go
func NewVisaApplicationWithDefaults() *VisaApplication
```
--------------------------------
### Country Metadata API
Source: https://github.com/finnhub-stock-api/finnhub-go/blob/master/docs/DefaultApi.md
Get country metadata.
```APIDOC
## GET /country
### Description
Country Metadata.
### Method
GET
### Endpoint
/country
```
--------------------------------
### Instantiate New VisaApplication
Source: https://github.com/finnhub-stock-api/finnhub-go/blob/master/docs/VisaApplication.md
Use NewVisaApplication to create a new VisaApplication object. This constructor assigns default values and ensures required properties are set.
```go
func NewVisaApplication() *VisaApplication
```
--------------------------------
### Get Sector Metrics with Go
Source: https://github.com/finnhub-stock-api/finnhub-go/blob/master/docs/DefaultApi.md
Retrieves sector metrics for a specified region. Ensure the 'region_example' is replaced with a valid region. The API key is implicitly handled by the client configuration.
```go
package main
import (
"context"
"fmt"
"os"
openapiclient "./openapi"
)
func main() {
region := "region_example" // string | Region. A list of supported values for this field can be found here.
configuration := openapiclient.NewConfiguration()
api_client := openapiclient.NewAPIClient(configuration)
resp, r, err := api_client.DefaultApi.SectorMetric(context.Background()).Region(region).Execute()
if err != nil {
fmt.Fprintf(os.Stderr, "Error when calling `DefaultApi.SectorMetric``: %v\n", err)
fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
}
// response from `SectorMetric`: SectorMetric
fmt.Fprintf(os.Stdout, "Response from `DefaultApi.SectorMetric`: %v\n", resp)
}
```
--------------------------------
### Company Executive API
Source: https://github.com/finnhub-stock-api/finnhub-go/blob/master/docs/DefaultApi.md
Get company executives.
```APIDOC
## GET /stock/executive
### Description
Company Executive.
### Method
GET
### Endpoint
/stock/executive
### Parameters
#### Query Parameters
- **symbol** (string) - Required - Stock symbol
```
--------------------------------
### Bond Profile API
Source: https://github.com/finnhub-stock-api/finnhub-go/blob/master/docs/DefaultApi.md
Get bond profile.
```APIDOC
## GET /bond/profile
### Description
Bond Profile.
### Method
GET
### Endpoint
/bond/profile
### Parameters
#### Query Parameters
- **id** (string) - Required - Bond's unique identifier
```
--------------------------------
### NewInstitutionalPortfolioInfoWithDefaults Constructor
Source: https://github.com/finnhub-stock-api/finnhub-go/blob/master/docs/InstitutionalPortfolioInfo.md
Instantiates a new InstitutionalPortfolioInfo object with default values. This constructor only assigns default values to properties that have them defined.
```go
func NewInstitutionalPortfolioInfoWithDefaults() *InstitutionalPortfolioInfo {
return &InstitutionalPortfolioInfo{}
}
```
--------------------------------
### New RevenueEstimatesInfo Constructor
Source: https://github.com/finnhub-stock-api/finnhub-go/blob/master/docs/RevenueEstimatesInfo.md
Instantiates a new RevenueEstimatesInfo object. This constructor assigns default values to properties that have them defined and ensures required API properties are set.
```go
func NewRevenueEstimatesInfo() *RevenueEstimatesInfo {
return &RevenueEstimatesInfo{}
}
```
--------------------------------
### GET /market/holiday
Source: https://github.com/finnhub-stock-api/finnhub-go/blob/master/docs/DefaultApi.md
Retrieves market holidays for a specified exchange.
```APIDOC
## GET /market/holiday
### Description
Retrieves market holidays for a specified exchange.
### Method
GET
### Endpoint
/market/holiday
### Query Parameters
- **exchange** (string) - Required - Exchange code.
### Request Example
```json
{
"exchange": "exchange_example"
}
```
### Response
#### Success Response (200)
- **MarketHoliday** - Details about market holidays.
#### Response Example
```json
{
"example": "MarketHoliday response body"
}
```
```
--------------------------------
### Naics Field Methods
Source: https://github.com/finnhub-stock-api/finnhub-go/blob/master/docs/SearchBody.md
Methods for getting the Naics field.
```APIDOC
## GetNaics
### Description
GetNaics returns the Naics field if non-nil, zero value otherwise.
### Method
`func (o *SearchBody) GetNaics() string`
```
--------------------------------
### Instantiate Dividends2Info with Defaults
Source: https://github.com/finnhub-stock-api/finnhub-go/blob/master/docs/Dividends2Info.md
Use NewDividends2InfoWithDefaults to create a new Dividends2Info object. This constructor only assigns default values to properties that have them defined, without guaranteeing that all required API properties are set.
```go
func NewDividends2InfoWithDefaults() *Dividends2Info {
inst := &Dividends2Info{}
return inst
}
```