package main import ( "encoding/json" "fmt" "log" "net/http" "time" ) func main() { // Read the list of covered funds (one GET, no key), naming your own // project req, err := http.NewRequest("GET", "https://tickerinside.com/api/v1/funds.json", nil) if err != nil { log.Fatal(err) } req.Header.Set("User-Agent", "MyProject/1.0 (+https://example.com)") client := &http.Client{Timeout: 30 * time.Second} resp, err := client.Do(req) if err != nil { log.Fatal(err) } defer resp.Body.Close() if resp.StatusCode != http.StatusOK { log.Fatalf("HTTP %d", resp.StatusCode) } // Decode the fields this example uses var doc struct { AsOf string `json:"as_of"` Count int `json:"count"` SecCount int `json:"sec_count"` Funds []struct { T string `json:"t"` // the ticker N string `json:"n"` // the name } `json:"funds"` } if err := json.NewDecoder(resp.Body).Decode(&doc); err != nil { log.Fatal(err) } // funds: read from their issuers' own files, with the date of the data fmt.Println(doc.Count, "funds from issuer files, as_of", doc.AsOf) // sec_funds: more US stock ETFs, from SEC filings, t and n as in funds fmt.Println(doc.SecCount, "more from SEC filings, listed in sec_funds") // One entry per fund for _, f := range doc.Funds { fmt.Println(f.T, f.N) } }