CSharp · Console
using System;
using System.Net;
using Newtonsoft.Json.Linq;
public class Program
{
public static void Main()
{
var URL = new UriBuilder("https://statsapi.web.nhl.com/api/v1/people/8471698/stats?stats=statsSingleSeason&season=20202021");
var client = new WebClient();
JObject PlayerData = JObject.Parse(client.DownloadString(URL.ToString()));
var stats = PlayerData["stats"] as JArray;
foreach (JObject stat in stats)
{
var splits = stat["splits"] as JArray;
foreach (JObject split in splits)
{
var splitStat = split["stat"] as JObject;
// Now you have access to the "split"
// Do whatever you want
// Here is a sample for accessing the goals
var goals = splitStat["goals"].ToString();
Console.WriteLine(goals);
}
}
}
}