Swiftpack.co - bdrelling/GoatHerb as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by bdrelling.
bdrelling/GoatHerb 0.2.3
Cross-platform Swift library for accessing the public GitHub API.
⭐️ 2
🕓 4 weeks ago
iOS macOS watchOS tvOS
.package(url: "https://github.com/bdrelling/GoatHerb.git", from: "0.2.3")

GoatHerb

CI Status Code Coverage Latest Release Swift Compatibility Platform Compatibility License

GoatHerb is a cross-platform Swift library for accessing the GitHub API.

Features

General

  • ☑ Compatible with swift-log.
  • ☑ Full concurrency (async/await) support.
  • ☑ Cross-platform support:
    • ☑ iOS
    • ☑ macOS
    • ☑ tvOS
    • ☑ watchOS
    • ☑ Linux (optimized for Server-side Swift)

Most cross-platform SDKs simply replace Foundation's URLSession with SwiftNIO's AsyncHTTPClient and call it a day. Not GoatHerb! GoatHerb is built on top of KippleNetworking, which intelligently chooses between Foundation's URLSession or SwiftNIO's AsyncHTTPClient depending on the platform, ensuring optimal networking for the platform it's running on.

GitHub API

  • ☑ Get Rate Limit
  • ☑ Get User
  • ☑ Get Organization
  • ☑ Get User Repositories
  • ☑ Get Organization Repositories
  • ☑ Get Repository

That's it for now! If you're looking for a more feature-complete SDK, check out the list of GitHub SDKs on Swift Package Index.

Usage

Create a GitHub object.

let gitHub = GitHub()

You can optionally provide an accessToken in the initializer, or via setting the GITHUB_ACCESS_TOKEN or GITHUB_TOKEN environment variable.

let gitHub = GitHub(accessToken: "<token>")

From there, requests are extremely straight-forward. Here are some examples:

// Get a user.
let user = try await self.gitHub.getUser("bdrelling")

// Get an organization.
let organization = try await self.gitHub.getOrganization("swift-kipple")

// Get all repositories for a user.
let repositories = try await self.gitHub.getRepositories(user: "bdrelling")

// Get all repositories for an organization.
let repositories = try await self.gitHub.getRepositories(org: "swift-kipple")

Contributing

Discussions, issues, and pull requests are more than welcome! I'm happy to extend the functionality of this library, with respect to the features listed in the Out of Scope section.

If opening a pull request, please ensure that the package retains as close to 100% code coverage as possible.

Credits

Special thanks to @boiarqin for providing me with an unforgettable repository name.

License

This project is released under the MIT license. See LICENSE for details.

GitHub

link
Stars: 2
Last commit: 2 weeks ago
jonrohan Something's broken? Yell at me @ptrpavlik. Praise and feedback (and money) is also welcome.

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics