---
title: Use Google Sheets Apps Script to track Open Source GitHub and Docker statistics - Codenotary
description: MONITOR & MANAGE THE RISK EXPOSURE OF YOUR APPLICATIONS WITH TRUESBOM®
image: https://codenotary.com/hubfs/Imported_Blog_Media/Blog-Default-General-Feb-10-2023-08-06-57-7409-AM.jpg
---

**$ protect --distro linux --machines 25 --free**

[Start now](https://apps.codenotary.com/linux)

[![cn-logo-black-nobg](https://codenotary.com/hubfs/cn-logo-black-nobg.svg)](https://codenotary.com/)

- Product
  
  #### [![AgentMon Start](https://codenotary.com/hubfs/AgentMon%20Start.svg) **AgentMon Start** Organization-wide AI agent spend, security and device fleet TRY NOW →](https://apps.codenotary.com/agentmon-start)
  
  #### [![AgentMon for Enterprise](https://codenotary.com/hubfs/AgentMon%20for%20Enterprise.svg) **AgentMon** Currently monitors more \> 7 million agent interactions/day. TRY NOW →](https://codenotary.com/agentmon)
  
  #### [![AgentX](https://codenotary.com/hubfs/AgentX.svg) **AgentX** Agentic network control middleware. TRY NOW →](https://codenotary.com/agent-network-control)
  
  #### [![Autonomous Security](https://codenotary.com/hubfs/Autonomous%20Security.svg) **Autonomous Security** AI Agents keep your servers secure. TRY NOW →](https://codenotary.com/trust)
- Use Cases
  
  #### [**AI Agent Risk Monitoring** Continuous oversight of autonomous agents across every environment.](https://codenotary.com/use-cases#risk)
  
  #### [**Autonomous Security Operations** Self-healing defenses that detect, contain, and remediate threats.](https://codenotary.com/use-cases#agentops)
  
  #### [**AI Coding Governance & Performance Monitoring** AI-generated code reviewed, tracked, and held to quality standards.](https://codenotary.com/use-cases#performance)
  
  #### [**AI Tool Cost & Usage Optimization** Spend and consumption optimized across every AI service in use.](https://codenotary.com/use-cases#cost)
  
  #### [**AI Tool Security & Policy Enforcement** Approved AI usage enforced with guardrails and policy controls.](https://codenotary.com/use-cases#security#security)
  
  #### [**Shadow AI Governance** Unsanctioned AI tools discovered, surfaced, and brought under control.](https://codenotary.com/use-cases#shadowit)
- [Blog](https://codenotary.com/blog)
- [Press](https://codenotary.com/press)
- Resources
  
  #### [**Integrations** Connect with your favorite tools and platforms. LEARN MORE →](https://codenotary.com/integrations)
  
  #### [**Support** Get help from our dedicated support team. GET HELP →](https://support.codenotary.com)
  
  #### [**Success Stories** Read how customers achieve their goals. READ MORE →](https://codenotary.com/success)
  
  #### [**Learn** Access documentation and learning resources. EXPLORE →](https://codenotary.com/learn)

[Login](https://apps.codenotary.com/auth/login)

[All posts](https://codenotary.com/blog/all)

 Mar 02, 2022

# Use Google Sheets Apps Script to track Open Source GitHub and Docker statistics

 By  [Dennis](https://codenotary.com/blog/author/dennis)  ·   2 minute read

If you run and maintain an Open Source project you’ll typically will want to keep track of things like your downloads, stars, commits over time, etc. to help you gauge engagement and overall health of your project. Here’s a quick way hack to keep track of some of this data in Google Sheet which will help you simplify the collection of data and help you better understand what that data means for your project.

## GitHub

Let’s start with GitHub repository statistics. To collect data a lot of data from github, you’ll need to [generate a token](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/creating-a-personal-access-token). But, if you’re only going to run a few requests you can ignore the token use, but it is recommended to avoid throttling.

Let’s take our repositories for [immudb](https://github.com/Codenotary/immudb) and [CAS](https://github.com/Codenotary/cas). We’d like to collect a monthly entry for the 2 repositories, that look like this:

![](https://codenotary.com/hs-fs/hubfs/Imported_Blog_Media/image-2-1024x33-1.png?width=1024&height=33&name=image-2-1024x33-1.png)

To start with, let’s first create a Google Sheet with the structure as shown in the above screenshot. We’ll fill the document line by line using [Google Apps Script](https://developers.google.com/apps-script), a javascript platform that lets you integrate with and automate tasks across Google Docs.

Once we have our documents, we can now click on the “Apps Scripts” entry in the “Extensions” menu:

![](https://codenotary.com/hs-fs/hubfs/Imported_Blog_Media/image-3-3.png?width=333&height=188&name=image-3-3.png)

The following script will pull the data from GitHub and populate our sheet. Copy & paste the code into the Apps Script function and give it a name. You only need to change the token to your own and include your repository names.

```
var TOKEN = 'your-private-token';

function recordGithubstats() {
  repos = ['org/repo', 'org/repo'];
  
  var headers = {
       "Authorization": "Token " + TOKEN,
       "Accept": "application/vnd.github.v3+json"
   };
     
   //Logger.log(headers);
     
   var options = {
       "headers": headers,
       "method" : "GET",
       "muteHttpExceptions": true
   };

  var row = [new Date()];
  
  repos.forEach(function (repo) {
    var response = UrlFetchApp.fetch("https://api.github.com/repos/" + repo, options);
    var response2 = UrlFetchApp.fetch("https://api.github.com/repos/" + repo + "/contributors?page=1&per_page=1000", options);
    var response3 = UrlFetchApp.fetch("https://api.github.com/repos/" + repo + "/releases", options);
    var downloadStats = 0;
    var repoStats = JSON.parse(response.getContentText());
    var contrStats = JSON.parse(response2.getContentText());
    var downloads = JSON.parse(response3.getContentText());
    
    Logger.log(downloads);
    
    for(var i = 0; i < downloads.length; i++) {
      var assets = downloads[i].assets
      for(var x = 0; x < assets.length; x++) {
             downloadStats = downloadStats + downloads[i].assets[x].download_count;
         }   
    }

    row.push(repoStats['stargazers_count']);
    row.push(repoStats['forks_count']);
    row.push(repoStats['subscribers_count']);
    row.push(contrStats.length);
    row.push(downloadStats);
                       
  });
  
  var sheet = SpreadsheetApp.getActiveSheet();
  sheet.appendRow(row);
}
```

You can now run it to see if the cells in the sheet will be filled with the correct numbers. (Btw, you have quite decent debugging capabilities in Google’s Apps Script to check the API response content.)

That’s it, you now can run it manually or using the built-in scheduler. Our results looked like this:

![](https://codenotary.com/hs-fs/hubfs/Imported_Blog_Media/Screen-Shot-2022-03-02-at-14_16_11-1024x77-1.png?width=1024&height=77&name=Screen-Shot-2022-03-02-at-14_16_11-1024x77-1.png)

## Docker

We can do the same for Docker Hub too and collect image download statistics. Let’s add the Title to some new columns in the sheet, open the Apps Script editor and paste the following code (just don’t forget to change the image names).

![](https://codenotary.com/hs-fs/hubfs/Imported_Blog_Media/image-4-4.png?width=599&height=36&name=image-4-4.png)

```
function recordDockerImagePullCount() {
  images = ['org/container', 'org/container'];
  var row = [new Date()];
  
  images.forEach(function (image) {
    var pull_count = get_image_pull_count(image);
    row.push(pull_count);
  });
  
  var sheet = SpreadsheetApp.getActiveSheet();
  sheet.appendRow(row);
}

function get_image_pull_count(image) {
  var response = UrlFetchApp.fetch("https://hub.docker.com/v2/repositories/" + image);
  var imageStats = JSON.parse(response.getContentText());
  return imageStats['pull_count'];
}
```

And here we see our results:

![](https://codenotary.com/hs-fs/hubfs/Imported_Blog_Media/Screen-Shot-2022-03-02-at-14_22_01-1024x139-1.png?width=1024&height=139&name=Screen-Shot-2022-03-02-at-14_22_01-1024x139-1.png)

The best thing about using Google Sheets with the Apps script is the built-in scheduler. That way you can run the script daily, weekly or monthly to track all the required statistics.

To do so, just click on the timer icon:

![](https://codenotary.com/hs-fs/hubfs/Imported_Blog_Media/image-1-Feb-10-2023-08-06-37-2184-AM.png?width=502&height=177&name=image-1-Feb-10-2023-08-06-37-2184-AM.png)

and configure the scheduler

![](https://codenotary.com/hs-fs/hubfs/Imported_Blog_Media/image-Feb-10-2023-08-06-35-1417-AM.png?width=667&height=889&name=image-Feb-10-2023-08-06-35-1417-AM.png)

Of course, you can use this kind of script with anything that provides an online API. It’s a very simple, yet very powerful and convenient solution for regular statistic tracking and reporting. Hopefully having more insight into your community can help you better engage with them and continue to grow your contributor base and project.

[![Share on twitter](https://4059529.fs1.hubspotusercontent-na1.net/hub/4059529/hubfs/01-marketplace/twitter-color.png?width=35&height=35&name=twitter-color.png)](https://twitter.com/intent/tweet?original_referer=https://codenotary.com/blog/use-google-sheets-apps-script-to-track-open-source-github-and-docker-statistics&utm_medium=social&utm_source=twitter&url=https://codenotary.com/blog/use-google-sheets-apps-script-to-track-open-source-github-and-docker-statistics&utm_medium=social&utm_source=twitter&source=tweetbutton&text=) [![Share on facebook](https://4059529.fs1.hubspotusercontent-na1.net/hub/4059529/hubfs/01-marketplace/facebook-color.png?width=35&height=35&name=facebook-color.png)](http://www.facebook.com/share.php?u=https://codenotary.com/blog/use-google-sheets-apps-script-to-track-open-source-github-and-docker-statistics&utm_medium=social&utm_source=facebook) [![Share on linkedin](https://4059529.fs1.hubspotusercontent-na1.net/hub/4059529/hubfs/01-marketplace/linkedin-color.png?width=35&height=35&name=linkedin-color.png)](http://www.linkedin.com/shareArticle?mini=true&url=https://codenotary.com/blog/use-google-sheets-apps-script-to-track-open-source-github-and-docker-statistics&utm_medium=social&utm_source=linkedin) [![Share on pinterest](https://4059529.fs1.hubspotusercontent-na1.net/hub/4059529/hubfs/pinterest.jpg?width=35&height=35&name=pinterest.jpg)](http://pinterest.com/pin/create/button/?url=https://codenotary.com/blog/use-google-sheets-apps-script-to-track-open-source-github-and-docker-statistics&utm_medium=social&utm_source=pinterest&media=)

```json
{
  "@context" : "https://schema.org",
  "@type" : "BlogPosting",
  "author" : {
    "@type" : "Person",
    "name" : "Dennis",
    "url" : "https://codenotary.com/blog/author/dennis"
  },
  "dateModified" : "2023-02-14T21:18:16.074Z",
  "datePublished" : "2022-03-02T17:25:10.000Z",
  "headline" : "Use Google Sheets Apps Script to track Open Source GitHub and Docker statistics - Codenotary",
  "image" : [ "https://codenotary.com/hubfs/Imported_Blog_Media/Blog-Default-General-Feb-10-2023-08-06-57-7409-AM.jpg" ],
  "mainEntityOfPage" : {
    "@id" : "https://codenotary.com/blog/use-google-sheets-apps-script-to-track-open-source-github-and-docker-statistics",
    "@type" : "WebPage"
  },
  "publisher" : {
    "@type" : "Organization",
    "logo" : {
      "@type" : "ImageObject",
      "url" : "https://codenotary.com/hubfs/logo-light.svg"
    },
    "name" : "Codenotary, Inc."
  }
}
```

```json
{
  "@context" : "http://schema.org",
  "@type" : "Article",
  "author" : {
    "@type" : "Person",
    "name" : [ "Dennis" ],
    "url" : "https://codenotary.com/blog/author/dennis"
  },
  "datePublished" : "2022-03-02T17:25:10+0000",
  "description" : "MONITOR & MANAGE THE RISK EXPOSURE OF YOUR APPLICATIONS WITH TRUESBOM®",
  "headline" : "Use Google Sheets Apps Script to track Open Source GitHub and Docker statistics",
  "image" : "https://23873599.fs1.hubspotusercontent-na1.net/hubfs/23873599/Imported_Blog_Media/Blog-Default-General-Feb-10-2023-08-06-57-7409-AM.jpg",
  "publisher" : {
    "@type" : "Organization",
    "logo" : {
      "@type" : "ImageObject",
      "url" : "https://cdn2.hubspot.net/hubfs/23873599/logo-light.svg"
    },
    "name" : ""
  },
  "url" : "https://codenotary.com/blog/use-google-sheets-apps-script-to-track-open-source-github-and-docker-statistics"
}
```