| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Name | Name | Last commit date | ||
|---|---|---|---|---|
The github-api-ps-module is a PowerShell module designed to simplify interactions with the GitHub API. It provides a collection of cmdlets to perform various operations, such as managing repositories, organizations, and interacting with GitHub's REST and GraphQL APIs. This module is ideal for developers and administrators who want to automate GitHub workflows.
Ensure these variables are set in your environment before running the module.
git clone https://github.com/your-repo/github-api-ps-module.gitImport-Module ./GitHubRestModule.psd1To authenticate with the GitHub API, ensure your environment variables are properly set up (e.g., GITHUB_TOKEN for personal access token authentication). Then, call the Update-GitHubToken cmdlet:
Update-GitHubTokenThis will authenticate your session and allow you to interact with the GitHub API.
Use the Invoke-GitHubApiRoute cmdlet to perform simple API actions. For example:
# Get repository details
Invoke-GitHubApiRoute -Method GET -Route "/repos/my-org/my-repo"
# Create a new issue
Invoke-GitHubApiRoute -Method POST -Route "/repos/my-org/my-repo/issues" -Body @{ title = "New Issue"; body = "Issue description" }Leverage the Invoke-PaginatedGitHubApiRoute cmdlet to handle paginated API responses automatically:
# List all repositories in an organization
Invoke-PaginatedGitHubApiRoute -Method GET -Route "/orgs/my-org/repos"Use the Invoke-GitHubGraphql cmdlet to execute GraphQL queries:
# Example GraphQL query
$query = @"
{
repository(owner: \"my-org\", name: \"my-repo\") {
issues(last: 5) {
edges {
node {
title
url
}
}
}
}
}
"@
Invoke-GitHubGraphql -Query $queryFor paginated GraphQL queries, use the Invoke-GitHubGraphqlQuery cmdlet:
# Example paginated GraphQL query
$query = @"
{
repository(owner: \"my-org\", name: \"my-repo\") {
issues(first: 5, after: $cursor) {
pageInfo {
hasNextPage
endCursor
}
edges {
node {
title
url
}
}
}
}
}
"@
Invoke-GitHubGraphqlQuery -Query $queryWhen an API endpoint returns a 202 status code due to data loading, use the Invoke-GitHubApiRouteRetryOn202 cmdlet to handle retries automatically:
Invoke-GitHubApiRouteRetryOn202 -Method GET -Route "/repos/my-org/my-repo/insights"This module automatically handles rate limits and throttling. To explicitly check rate limits, use the Assert-GitHubRateLimits cmdlet:
Assert-GitHubRateLimitsIf you prefer using the GitHub CLI (gh), this module integrates seamlessly and provides rate limit protection out of the box.
Contributions are welcome! Please follow these steps:
This project is licensed under the MIT License. See the LICENSE file for details.
If you encounter any issues or have questions, feel free to open an issue in this repository.
| Back | FazBrowse Home | New Git URL |