import com.google.gson.JsonElement; import com.google.gson.JsonObject; import com.google.gson.JsonParser; import java.net.URI; import java.net.http.HttpClient; import java.net.http.HttpRequest; import java.net.http.HttpResponse; public class FundsList { public static void main(String[] args) throws Exception { // Read the list of covered funds (one GET, no key), naming your own // project var request = HttpRequest.newBuilder( URI.create("https://tickerinside.com/api/v1/funds.json")) .header("User-Agent", "MyProject/1.0 (+https://example.com)") .build(); var response = HttpClient.newHttpClient() .send(request, HttpResponse.BodyHandlers.ofString()); if (response.statusCode() != 200) { throw new RuntimeException("HTTP " + response.statusCode()); } JsonObject doc = JsonParser.parseString(response.body()) .getAsJsonObject(); // funds: read from their issuers' own files, with the date of the data System.out.println(doc.get("count") + " funds from issuer files, as_of " + doc.get("as_of").getAsString()); // sec_funds: more US stock ETFs, from SEC filings, t and n as in funds System.out.println(doc.get("sec_count") + " more from SEC filings, listed in sec_funds"); // One entry per fund: t is the ticker, n the name for (JsonElement e : doc.getAsJsonArray("funds")) { JsonObject f = e.getAsJsonObject(); System.out.println(f.get("t").getAsString() + " " + f.get("n").getAsString()); } } }