Skip to content

Instantly share code, notes, and snippets.

Last active March 21, 2019 14:48
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
Count download of GitHub release module.
using Newtonsoft.Json.Linq;
using System;
using System.Net.Http;
using System.Linq;
using System.Threading.Tasks;
public static class GitHubCounter
public static async Task CountDownload(string owner, string repository)
using (var httpClient = new HttpClient())
httpClient.DefaultRequestHeaders.Add("User-Agent", "C# HttpClient");
var downloadCount =
.Parse(await httpClient.GetStringAsync($"{owner}/{repository}/releases"))
.SelectMany(x => JArray.FromObject(x["assets"]))
.Sum(x => int.Parse((string)x["download_count"]));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment