Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added related companies support #429

Merged
merged 1 commit into from
Jun 18, 2024
Merged

Conversation

justinpolygon
Copy link
Contributor

Update client with related companies support. This PR updates the spec, adds a GetTickerRelatedCompanies function, params, response, test, and a working example. This also fixes #424 for the spec changes.

// Stocks - Related Companies
// https://polygon.io/docs/stocks/get_v1_related-companies__ticker
// https://github.com/polygon-io/client-go/blob/master/rest/reference.go
package main

import (
	"context"
	"log"
	"os"

	polygon "github.com/polygon-io/client-go/rest"
	"github.com/polygon-io/client-go/rest/models"
)

func main() {

	// init client
	c := polygon.New(os.Getenv("POLYGON_API_KEY"))

	// set params
	params := models.GetTickerRelatedCompaniesParams{
		Ticker: "AAPL",
	}

	// make request
	res, err := c.GetTickerRelatedCompanies(context.Background(), &params)
	if err != nil {
		log.Fatal(err)
	}

	// do something with the result
	log.Print(res)

}
$ go run rest/example/stocks/related-companies/main.go
2024/06/18 13:33:20 &{{{} OK e1aa58d77611eef9a9e98f904539c34d 0  } [{MSFT} {GOOGL} {AMZN} {GOOG} {TSLA} {NVDA} {META} {NFLX} {DIS} {BRK.B}]}

@justinpolygon justinpolygon merged commit ec83a35 into master Jun 18, 2024
16 checks passed
@justinpolygon justinpolygon deleted the jw-add-related-companies branch June 18, 2024 20:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Client update needed to match REST spec changes
2 participants