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

     1  // Forex - Exchanges
     2  // https://polygon.io/docs/forex/get_v3_reference_exchanges
     3  package main
     4  
     5  import (
     6  	"context"
     7  	"log"
     8  	"os"
     9  
    10  	polygon "github.com/polygon-io/client-go/rest"
    11  	"github.com/polygon-io/client-go/rest/models"
    12  )
    13  
    14  func main() {
    15  	// init client
    16  	c := polygon.New(os.Getenv("POLYGON_API_KEY"))
    17  
    18  	// set params
    19  	params := models.GetExchangesParams{}.
    20  		WithAssetClass(models.AssetFx)
    21  
    22  	// make request
    23  	res, err := c.GetExchanges(context.Background(), params)
    24  	if err != nil {
    25  		log.Fatal(err)
    26  	}
    27  
    28  	// do something with the result
    29  	log.Print(res)
    30  }