Using GitHub Web Services (Part 1)

by Feb 2, 2021

A lot of open-source software is hosted by GitHub these days. This includes such powerful tools like Windows Terminal or the Visual Studio Code editor.

GitHub offers public web services to query repository details for registered organizations (such as Microsoft), so if you’d like to find out whether there are new releases for a particular software, try querying the web service.

The example below queries details for the “Windows Terminal” repository inside the organization “Microsoft”:

PS> $url = ''
PS> Invoke-RestMethod -UseBasicParsing -Uri $url

url              :
assets_url       :
upload_url       :
html_url         :
id               : 34250658
author           : @{login=DHowett; id=189190; node_id=MDQ6VXNlcjE4OTE5MA==; 
                   gravatar_id=; url=; 
                   followers_url=; following_ur
                   type=User; site_admin=False}
node_id          : MDc6UmVsZWFzZTM0MjUwNjU4
tag_name         : v1.4.3243.0
target_commitish : main
name             : Windows Terminal v1.4.3243.0
draft            : False
prerelease       : False
created_at       : 2020-11-20T21:34:28Z
published_at     : 2020-11-20T21:43:33Z
assets           : {@{url=
                   75927; id=28575927; node_id=MDEyOlJlbGVhc2VBc3NldDI4NTc1OTI3; 
                   label=; uploader=; content_type=application/octet-stream; state=uploaded; 
                   size=22834909; download_count=28268; created_at=2020-11-20T21:43:26Z; 
                   updated_at=2020-11-20T21:43:28Z; browser_download_url=
                   1.4.3243.0_8wekyb3d8bbwe.msixbundle}, @{url=
                   icrosoft/terminal/releases/assets/28575931; id=28575931; 
                   node_id=MDEyOlJlbGVhc2VBc3NldDI4NTc1OTMx; name=Microsoft.WindowsTerminal_1
         ; label=; 
                   uploader=; content_type=application/zip; state=uploaded; size=22311138; 
                   download_count=5063; created_at=2020-11-20T21:43:31Z; 
                   updated_at=2020-11-20T21:43:32Z; browser_download_url=
tarball_url      :
zipball_url      :
body             : This is a quick servicing release to address a couple glaring issues in 
                   the 1.4 stable release.
                   A [preinstallation](
                   deploy-preinstalled-apps) kit is available for system integrators and 
                   OEMs interested in prepackaging Windows Terminal with a Windows image. 
                   More information is available in the [DISM documentation on preinstallatio
                   all-apps-using-dism). Users who do not intend to preinstall Windows 
                   Terminal should continue using the _msixbundle_ distribution.
                   Bugs fixed in this release:
                   * We reverted the tab switcher to _off by default_, because we changed 
                   your defaults on you so that tab switching was both enabled and _in 
                   most-recently-used order_. I'm sorry about that. (#8325)
                      * To turn the switcher back on, in MRU order, add the global setting 
                   `"useTabSwitcher": true`.
                   * We'd previously said the default value for `backgroundImageStretch` was 
                   `uniformToFill`, but it was actually `fill`. We've updated the code to 
                   make it `uniformToFill`. (#8280)
                   * The tab switcher used to occasionally eat custom key bindings and 
                   break, but @Don-Vito came through and helped it not do that. Thanks! 

From this rich set of information, you could pick the details you need to know, i.e. the latest download locations in various formats:

$url = ''
$info = Invoke-RestMethod -UseBasicParsing -Uri $url 

    TAR =  $info.tarball_url
    ZIP =  $info.zipball_url
    AppX = $info.Assets.Browser_Download_url[0]
} | Format-List

The result then looks like this:

TAR  :
ZIP  :
AppX :

Twitter This Tip! ReTweet this Tip!