Go to file
Alexander Ignition 280f91a0dd Update GHRequest mutating methods 2022-06-24 22:12:03 +03:00
.github/workflows Workflow test matrix (#5) 2022-02-19 17:42:24 +03:00
Sources/Octokot Update GHRequest mutating methods 2022-06-24 22:12:03 +03:00
Tests/OctokotTests Update GHRequest mutating methods 2022-06-24 22:12:03 +03:00
.gitignore Draft 2021-11-07 11:51:03 +03:00
LICENSE Initial commit 2021-11-07 11:43:40 +03:00
Makefile Workflow test matrix (#5) 2022-02-19 17:42:24 +03:00
Package.swift Concurrency backport (#2) 2022-01-11 18:36:14 +03:00
README.md Moved Configuration in GitHubAPI 2022-06-21 16:05:50 +03:00

README.md

🐱 Octokot

Test SPM compatible Swift 5.3 GitHub license

Swift toolkit for the GitHub API

Instalation

Add dependency to Package.swift...

.package(url: "https://github.com/Alexander-Ignition/Octokot", branch: "main"),

... and your target

.target(name: "ExampleApp", dependencies: ["Octokot"]),

Usage

Import the library and you can create an instance of the GitHub API. It is a wrapper over the GitHub REST API

import Octokot

let github = GitHubAPI()

Most methods are similar to urls from REST API.

You can call them using swift @dynamicMemberLookup ...

let repo = try await github.repos.apple.swift()

... or you can use them via subscript.

let repo = try await github.repos["server-swift"]["async-http-client"]()

Authentication

Personal Access Token

Create a Personal Access Token after which you can set it in the configuration and use the methods for which authentication is required.

var configuration = GitHubAPI.Configuration.default
configuration.accessToken = .string("<personal_access_token>")

let github = GitHubAPI(configuration: configuration)

let user = try await github.user()

Personal Access Token can be in base 64 encoded strings for this case there is a second method in the configuration.

configuration.accessToken = .base64EncodedString("<base64_encoded_personal_access_token>")