Celerium.GitHub
Buy me a coffee
Whether you use this project, have learned something from it, or just like it, please consider supporting it by buying me a coffee, so I can dedicate more time on open-source projects like this :)
About The Project
The Celerium.GitHub PowerShell module wraps the GitHub REST API (API version 2026-03-10). Every operation of the official GitHub OpenAPI description has a command, about 1,280 operations in 50+ categories (repositories, issues, pull requests, actions, orgs, teams, security, Copilot, …), and one shared request engine handles authentication, API versioning, pagination, rate limits, retries, and errors.
- :book: Celerium.GitHub project documentation can be found on GitHub Pages
- :book: GitHub’s REST API documentation is at docs.github.com/en/rest
- :wrench: The commands are generated from the GitHub OpenAPI spec, see Architecture
Breaking change from 1.x. The 1.1.0 release of this repository was a template that still talked to a different product and never worked against GitHub. Version 2.0.0 is a rewrite: there is no GitHub compatible command from 1.x to migrate from. See the CHANGELOG.
Install
Celerium.GitHub supports Windows PowerShell 5.1 and PowerShell 7+ on Windows, Linux, and macOS.
Install-Module -Name Celerium.GitHub -Scope CurrentUser
# or
Install-PSResource -Name Celerium.GitHub -Scope CurrentUser
Import-Module -Name Celerium.GitHub
The module has about 1,300 commands and an import takes a few seconds. Importing never makes a network call.
Quick start
Import-Module -Name Celerium.GitHub
# Token from a SecureString (never put a token in a script)
Add-GitHubApiKey -ApiKeySecureString (Read-Host -Prompt 'GitHub token' -AsSecureString)
Test-GitHubApiKey # Success, Login, Scopes, RateLimit
Get-GitHubUserAuthenticated # GET /user
Get-GitHubRepository -Owner octocat -Repo Hello-World
Get-GitHubIssueForRepo -Owner octocat -Repo Hello-World -State open -AllResults
New-GitHubIssue -Owner octocat -Repo Hello-World -Title 'Found a bug' -BodyText 'Steps to reproduce' -WhatIf
More runnable scripts are in the examples folder.
Authentication
The token is resolved for every request in this order:
- The token stored with
Add-GitHubApiKey(kept as aSecureStringin memory) - The
GITHUB_TOKENenvironment variable - The
GH_TOKENenvironment variable - No token (public data with a low rate limit)
Add-GitHubApiKey -ApiKeySecureString $Token # a SecureString
'<token>' | Add-GitHubApiKey # a string from the pipeline (converted to a SecureString at once)
Get-GitHubApiKey # the SecureString (-AsPlainText when you really need it)
Remove-GitHubApiKey
In GitHub Actions use GITHUB_TOKEN (env: GITHUB_TOKEN: $), nothing else is needed. The token is never written to the verbose or debug output.
Use fine-grained personal access tokens with the least permissions you need.
Settings and the token can be saved with Export-GitHubModuleSettings and restored with Import-GitHubModuleSettings
(~/Celerium.GitHub/config.psd1). On Windows the token is encrypted with DPAPI for your user, on Linux and macOS it is not encrypted, use the environment variable there.
GitHub Enterprise Server
Add-GitHubBaseUri -BaseUri 'https://github.example.com/api/v3' # upload url is derived (/api/uploads)
Add-GitHubBaseUri -BaseUri 'https://api.octocorp.ghe.com' # Enterprise Cloud with data residency
Get-GitHubBaseUri
Remove-GitHubBaseUri # back to https://api.github.com
Only https addresses are accepted. Some endpoints exist only on GitHub.com or only on GHES; the command help says when an endpoint is GitHub Cloud only.
Naming convention
Commands are generated from the operationId of the GitHub OpenAPI spec:
| HTTP method | Verb | Example |
|---|---|---|
| GET | Get |
Get-GitHubRepository (GET /repos/{owner}/{repo}) |
| POST | New |
New-GitHubRepositoryForAuthenticatedUser (POST /user/repos), New-GitHubIssue |
| PATCH, PUT | Set |
Set-GitHubRepository (PATCH /repos/{owner}/{repo}) |
| DELETE | Remove |
Remove-GitHubRepository |
- Repeated words: when the action starts with the same word as the category prefix the repeat is dropped (singular and plural forms count as equal):
actions/get-actions-cache-usageisGet-GitHubActionsCacheUsage(notGet-GitHubActionsActionsCacheUsage),oidc/create-oidc-custom-property-inclusion-for-orgisNew-GitHubOidcCustomPropertyInclusionForOrg. If the shorter name would collide with another command the generator keeps the repeated word for that operation and warns. - Aliases: every command has an alias
Get-GH<Noun>(the verb is part of the alias unless it isGet):Get-GitHubRepositoryisGet-GHRepository,New-GitHubIssueisGet-GHNewIssue,Set-GitHubRepositoryisGet-GHSetRepository,Remove-GitHubRepositoryisGet-GHRemoveRepository. - Parameters are the PascalCase of the GitHub names:
owneris-Owner,per_pageis-PerPage. Request body properties are typed parameters as well (has_issuesis-HasIssues);-Bodysends a complete body with the original JSON names. A body property that clashes with another parameter is prefixed withBody(the issue text is-BodyText). - Categories: the folder of a command under
Publicand the page group in the documentation, such asRepos,Issues,Pulls,Actions. - Find commands with
Get-Command -Module Celerium.GitHub -Name '*Issue*'or in the command reference. The Tracking CSV (docs/endpoints.csv) lists the command for every endpoint.
Write commands
Every POST, PUT, PATCH, and DELETE command supports -WhatIf and -Confirm. DELETE commands have a high confirm impact and ask for confirmation by default.
Remove-GitHubRepository -Owner octocat -Repo scratch -WhatIf # shows the request, nothing is sent
Set-GitHubRepository -Owner octocat -Repo scratch -Description 'Updated' -HasWiki:$false
Set-GitHubRepository -Owner octocat -Repo scratch -Body @{ description = 'Updated'; has_wiki = $false }
Pagination
List commands have -PerPage, -Page, and -AllResults. -AllResults follows the Link header (it never leaves the API host) and streams the items to the pipeline page by page, so Select-Object -First 10 stops early. Without -AllResults you get exactly one page, unchanged.
Get-GitHubRepositoryForOrg -Org octocat -AllResults
Get-GitHubIssueForRepo -Owner octocat -Repo Hello-World -PerPage 100 -Page 2
Rate limits
The rate limit of every response is recorded:
$Response = Get-GitHubLastResponse
$Response.RateLimit.Remaining # also Limit, Used, Reset (UTC DateTime), Resource
Get-GitHubRateLimit # every limit of the token, does not count against the limit
When the primary or secondary limit is hit the module waits for the reset or for the Retry-After time and writes a warning, up to MaxRateLimitWaitSeconds (default 300). A longer wait is returned as an error. Transient server errors (500, 502, 503, 504) and connection failures are retried with exponential backoff for GET requests only, a write is never repeated blindly. Change the behavior with Initialize-GitHubModuleSettings -MaxRetryCount 5 -MaxRateLimitWaitSeconds 600 -TimeoutSeconds 60.
Errors
A failed request is a normal PowerShell error record (use -ErrorAction Stop with try/catch):
try { Get-GitHubRepository -Owner octocat -Repo missing -ErrorAction Stop }
catch {
$_.FullyQualifiedErrorId # GitHubApi.404
$_.CategoryInfo.Category # ObjectNotFound
$_.TargetObject.StatusCode # 404 (also Method, Uri, Message, DocumentationUrl, Errors, RequestId)
}
Endpoints that answer 204 or 404 for yes or no return $true or $false. Test-GitHubApiKey never throws.
Escape hatch, downloads, and uploads
Invoke-GitHubRequest -Path '/repos/{owner}/{repo}/topics' -PathParameters @{ owner = 'octocat'; repo = 'Hello-World' }
Invoke-GitHubRequest -Method POST -Path '/markdown' -Body @{ text = 'Hello **world**' } -Raw
Get-GitHubRepositoryDownloadZipballArchive -Owner octocat -Repo Hello-World -Ref main -OutFile .\hello.zip
Release asset uploads use -InFile and the uploads.github.com host. See Architecture for the request flow.
Development
Requires PowerShell 7 for the generator and the docs, and the pinned modules listed in build/Prerequisites.psd1.
./build/Install-Prerequisites.ps1 # Pester 6.2.0, PSScriptAnalyzer 1.25.0, ModuleBuilder 3.2.18, PlatyPS 1.0.3
./build/Install-Prerequisites.ps1 -CheckOnly # validate only
./build/Get-GitHubSpec.ps1 # download the pinned OpenAPI spec (docs/api.github.com.2026-03-10.json)
./build/New-PublicFunctions.ps1 # regenerate the commands, the manifest lists, and docs/endpoints.csv
./build/Test-NamingConvention.ps1 # PascalCase, approved verbs, no aliases
./build/Test-EndpointCoverage.ps1 # CSV + manifest vs the spec
./build/Invoke-PesterTests.ps1 -Version 2.0.0 # source module
./build/Invoke-ModuleBuild.ps1 -Version 2.0.0 # build/Celerium.GitHub/2.0.0
./build/Invoke-PesterTests.ps1 -Version 2.0.0 -BuildTarget built # built module
./build/Invoke-HelpContent.ps1 # docs/site (PlatyPS), about a minute
./build/Compare-GitHubSpec.ps1 # spec vs docs.github.com crawl (polite, cached in build/Cache)
Files under Celerium.GitHub/Public/<Category> are generated, do not edit them by hand. CI fails when the committed files differ from the generator output. The unit tests never use the network or a token. Opt-in live tests (tests/Live, tag Live) need GITHUB_TOKEN; they create and delete a temporary private repository.
The 14 MB OpenAPI spec is only used by the build scripts and is not shipped in the module.
Known limitations
- About 1,280 commands make the module slower to import than a small module (a few seconds; Windows PowerShell 5.1 is slower than PowerShell 7).
- Command names are derived from the spec
operationIds, so a few names are long (Get-GitHubActionsCacheRetentionLimitForOrganization). Use theGet-GH*aliases or tab completion. Some nouns are plural because the spec is (PSUseSingularNounsis turned off). - Webhook payload schemas, GraphQL, and git operations are not part of this module.
- Deprecated operations are generated and write a warning when called.
- Request body parameters follow the spec. Properties that the spec describes only as free form objects are
[object]parameters, use-Bodyfor full control. - On Linux and macOS the exported settings file does not encrypt the token.
- Endpoints that exist only on GitHub Enterprise Server or in a preview are not in the pinned spec, call them with
Invoke-GitHubRequest.
Contributing
If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag “enhancement”. Don’t forget to give the project a star! Thanks again!
See the CONTRIBUTING guide for more information about contributing.
License
Distributed under the MIT license. See LICENSE for more information.