Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/dammak/github_kit
GitHubKit is a comprehensive Dart package for interacting with the GitHub API.
https://github.com/dammak/github_kit
dart-package flutter-package github github-action github-actions github-api octocat
Last synced: 4 days ago
JSON representation
GitHubKit is a comprehensive Dart package for interacting with the GitHub API.
- Host: GitHub
- URL: https://github.com/dammak/github_kit
- Owner: DAMMAK
- License: mit
- Created: 2024-10-14T10:06:24.000Z (4 months ago)
- Default Branch: master
- Last Pushed: 2024-10-16T09:25:58.000Z (4 months ago)
- Last Synced: 2025-02-02T00:46:09.269Z (4 days ago)
- Topics: dart-package, flutter-package, github, github-action, github-actions, github-api, octocat
- Language: Dart
- Homepage:
- Size: 47.9 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
README
# GitHubKit
[![GitHub License][license-badge]][license-link]
[![PRs Welcome][prs-badge]][prs-link]
[![Watch on GitHub][github-watch-badge]][github-watch-link]
[![Star on GitHub][github-star-badge]][github-star-link]
[![Watch on GitHub][github-forks-badge]][github-forks-link][license-badge]: https://img.shields.io/github/license/DAMMAK/github_kit.svg?style=for-the-badge
[license-link]: https://github.com/DAMMAK/github_kit/blob/master/LICENSE
[prs-badge]: https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=for-the-badge
[prs-link]: https://github.com/DAMMAK/github_kit/issues[github-watch-badge]: https://img.shields.io/github/watchers/DAMMAK/github_kit.svg?style=for-the-badge&logo=github&logoColor=ffffff
[github-watch-link]: https://github.com/DAMMAK/github_kit/watchers
[github-star-badge]: https://img.shields.io/github/stars/DAMMAK/github_kit.svg?style=for-the-badge&logo=github&logoColor=ffffff
[github-star-link]: https://github.com/DAMMAK/github_kit/stargazers
[github-forks-badge]: https://img.shields.io/github/forks/DAMMAK/github_kit.svg?style=for-the-badge&logo=github&logoColor=ffffff
[github-forks-link]: https://github.com/DAMMAK/github_kit/network/membersGitHubKit is a comprehensive Dart package for interacting with the GitHub API. It provides an easy-to-use interface for common GitHub operations and supports advanced features like GitHub Actions, code scanning, and secret scanning.
## Table of Contents
- [Features](#features)
- [Installation](#installation)
- [Usage](#usage)
- [Initialization](#initialization)
- [Repositories](#repositories)
- [Issues](#issues)
- [Pull Requests](#pull-requests)
- [GitHub Actions](#github-actions)
- [Code Scanning](#code-scanning)
- [Secret Scanning](#secret-scanning)
- [GraphQL API](#graphql-api)
- [Error Handling](#error-handling)
- [Pagination](#pagination)
- [Rate Limiting](#rate-limiting)
- [Logging](#logging)
- [Testing](#testing)
- [Examples](#examples)
- [Contributing](#contributing)
- [License](#license)## Features
- Complete coverage of GitHub REST API v3
- Support for GitHub GraphQL API v4
- Repositories management
- Issues and Pull Requests handling
- GitHub Actions workflow management
- Code scanning and Secret scanning APIs
- Automatic pagination handling
- Built-in rate limit handling and automatic retries
- Comprehensive logging system
- Easy error handling with custom exceptions
- Full support for authentication (Personal Access Tokens)
- Extensive documentation and examples## Installation
Add this to your package's `pubspec.yaml` file:
```yaml
dependencies:
github_kit: ^1.0.0
```Then run:
```
$ dart pub get
```## Usage
### Initialization
First, import the package and create an instance of `GitHubKit`:
```dart
import 'package:github_kit/github_kit.dart';final gitHubKit = GitHubKit(token: 'your_personal_access_token');
```### Repositories
```dart
// Get a repository
final repo = await gitHubKit.repositories.getRepository('octocat', 'Hello-World');
print('Repository: ${repo.fullName}');// Create a repository
final newRepo = await gitHubKit.repositories.createRepository('New-Repo', private: true);
print('Created new repository: ${newRepo.fullName}');// List repositories
final repos = await gitHubKit.repositories.listRepositories('octocat');
for (var repo in repos) {
print('Repo: ${repo.name}');
}
```### Issues
```dart
// Create an issue
final issue = await gitHubKit.issues.createIssue('octocat', 'Hello-World', 'Bug report', body: 'This is a bug report');
print('Created issue #${issue.number}');// Get an issue
final fetchedIssue = await gitHubKit.issues.getIssue('octocat', 'Hello-World', 1);
print('Issue title: ${fetchedIssue.title}');// List issues
final issues = await gitHubKit.issues.listIssues('octocat', 'Hello-World', state: 'open');
for (var issue in issues) {
print('Issue #${issue.number}: ${issue.title}');
}
```### Pull Requests
```dart
// Create a pull request
final pr = await gitHubKit.pullRequests.createPullRequest('octocat', 'Hello-World', 'New feature', 'feature-branch', 'main');
print('Created PR #${pr.number}');// Get a pull request
final fetchedPR = await gitHubKit.pullRequests.getPullRequest('octocat', 'Hello-World', 1);
print('PR title: ${fetchedPR.title}');// List pull requests
final prs = await gitHubKit.pullRequests.listPullRequests('octocat', 'Hello-World', state: 'open');
for (var pr in prs) {
print('PR #${pr.number}: ${pr.title}');
}
```### GitHub Actions
```dart
// List workflows
final workflows = await gitHubKit.actions.listWorkflows('octocat', 'Hello-World');
for (var workflow in workflows) {
print('Workflow: ${workflow.name}');
}// Create a workflow dispatch event
await gitHubKit.actions.createWorkflowDispatch('octocat', 'Hello-World', 'main.yml', 'main');
print('Workflow dispatch created');
```### Code Scanning
```dart
// List code scanning alerts
final alerts = await gitHubKit.codeScanning.listCodeScanningAlerts('octocat', 'Hello-World');
for (var alert in alerts) {
print('Alert #${alert.number}: ${alert.state}');
}
```### Secret Scanning
```dart
// List secret scanning alerts
final secretAlerts = await gitHubKit.secretScanning.listSecretScanningAlerts('octocat', 'Hello-World');
for (var alert in secretAlerts) {
print('Secret Alert #${alert.number}: ${alert.state}');
}
```### GraphQL API
```dart
final result = await gitHubKit.graphql('''
query {
viewer {
login
repositories(first: 10) {
nodes {
name
stargazerCount
}
}
}
}
''');
print('Logged in as: ${result['viewer']['login']}');
```## Error Handling
GitHubKit uses custom exceptions for error handling. Always wrap your API calls in a try-catch block:
```dart
try {
final repo = await gitHubKit.repositories.getRepository('octocat', 'Hello-World');
print('Repository: ${repo.fullName}');
} catch (e) {
if (e is GitHubException) {
print('GitHub API Error: ${e.message} (Status: ${e.statusCode})');
} else {
print('Error: $e');
}
}
```## Pagination
Most list methods in GitHubKit handle pagination automatically. You can control pagination using the `perPage` and `page` parameters:
```dart
final repos = await gitHubKit.repositories.listRepositories('octocat', perPage: 100, page: 2);
```## Rate Limiting
GitHubKit automatically handles rate limiting by retrying requests when limits are hit. You can configure retry behavior when creating the GitHubKit instance:
```dart
final gitHubKit = GitHubKit(
token: 'your_token',
maxRetries: 5,
retryDelay: Duration(seconds: 10),
);
```## Logging
GitHubKit includes a built-in logging system. You can configure logging when creating the GitHubKit instance:
```dart
final gitHubKit = GitHubKit(token: 'your_token');
gitHubKit.setLogLevel(LogLevel.debug);
```## Testing
To run the tests for GitHubKit:
```
$ dart test
```## Examples
For more examples, check the `example` folder in the repository.
## Contributing
Contributions are welcome! Please read our [Contributing Guide](CONTRIBUTING.md) for more information.
## License
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.