目录
目录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>")
邀请码
    Gitlink(确实开源)
  • 加入我们
  • 官网邮箱:gitlink@ccf.org.cn
  • QQ群
  • QQ群
  • 公众号
  • 公众号

©Copyright 2023 CCF 开源发展委员会
Powered by Trustie& IntelliDE 京ICP备13000930号