github.com/polygon-io/client-go@v1.16.4/rest/example/indices/tickers/main.go (about)

     1  // Indices - Tickers
     2  // https://polygon.io/docs/indices/get_v3_reference_tickers
     3  // https://github.com/polygon-io/client-go/blob/master/rest/reference.go
     4  package main
     5  
     6  import (
     7  	"context"
     8  	"log"
     9  	"os"
    10  
    11  	polygon "github.com/polygon-io/client-go/rest"
    12  	"github.com/polygon-io/client-go/rest/models"
    13  )
    14  
    15  func main() {
    16  	// init client
    17  	c := polygon.New(os.Getenv("POLYGON_API_KEY"))
    18  
    19  	// set params
    20  	params := models.ListTickersParams{}.
    21  		WithMarket(models.AssetIndices).
    22  		WithActive(true).
    23  		WithSort(models.TickerSymbol).
    24  		WithOrder(models.Asc).
    25  		WithLimit(1000)
    26  
    27  	// make request
    28  	iter := c.ListTickers(context.Background(), params)
    29  
    30  	// do something with the result
    31  	for iter.Next() {
    32  		log.Print(iter.Item())
    33  	}
    34  	if iter.Err() != nil {
    35  		log.Fatal(iter.Err())
    36  	}
    37  }