using System; using System.Globalization; using System.Linq; using System.Net.Http; using System.Text.Json; // Print numbers with a dot, whatever the language of the machine CultureInfo.CurrentCulture = CultureInfo.InvariantCulture; // Read VOO's file (one GET, no key), naming your own project using var http = new HttpClient(); http.DefaultRequestHeaders.UserAgent.ParseAdd( "MyProject/1.0 (+https://example.com)"); using var doc = JsonDocument.Parse(await http.GetStringAsync( "https://tickerinside.com/api/v1/fund/voo.json")); var fund = doc.RootElement; // The date of the issuer's file the weights come from Console.WriteLine( $"VOO holdings_as_of {fund.GetProperty("holdings_as_of").GetString()}"); // holdings maps each ticker to its weight in percent: sort it, largest first var rows = fund.GetProperty("holdings").EnumerateObject() .OrderByDescending(h => h.Value.GetDouble()).ToList(); Console.WriteLine($"{rows.Count} holdings, largest first"); foreach (var h in rows) Console.WriteLine($"{h.Name} {h.Value.GetDouble()}"); // The line to print under any figure you quote Console.WriteLine(fund.GetProperty("cite_as").GetString());