using System.Collections.Generic;
public static void Main()
int totalGoals = getTotalGoals("Real Madrid", 2012);
Console.WriteLine(totalGoals.ToString());
public static int getTotalGoals(string team, int year)
var current = GetMatches(year.ToString(), team, page.ToString(), $"team{i}");
foreach(Match m in current.data)
if (m.team1 == team) goals += m.team1goals;
if (m.team2 == team) goals += m.team2goals;
if (page>current.total_pages) break;
public static MatchResult GetMatches(string year, string team, string page, string teamSearch)
HttpClient client = new HttpClient();
string url = $"https://jsonmock.hackerrank.com/api/football_matches?year={year}&{teamSearch}={team}&page={page}";
var current = client.GetAsync(url).Result;
MatchResult result = JsonConvert.DeserializeObject<MatchResult>(current.Content.ReadAsStringAsync().Result);
public string team1 {get;set;}
public string team2 {get;set;}
public int team1goals {get;set;}
public int team2goals {get;set;}
public class MatchResult {
public List<Match> data {get;set;}
public int total_pages {get;set;}