Swift implementation of Github REST API v3

Overview

GitHubAPI

CI Status Version License Platform

Swift implementation of GitHub REST api v3. Library support Swift 4.2. Work is in progress.

Currently supported:

TODO:

Example Usage

Authentication

Basic Authentication

This lib support Basic Authentication with login/password:

let authentication = BasicAuthentication(username: "username", password: "password")
UserAPI(authentication: authentication).getUser { (response, error) in
	if let response = response {
		print(response)
	} else {
		print(error ?? "")
	}
}

OAuth2 Token (sent in a header)

If you generate personal access token or receive access token from OAuth2, you can use it with AccessTokenAuthentication:

let authentication = AccessTokenAuthentication(access_token: "token")
UserAPI(authentication: authentication).getUser(username: "serhii-londar") { (response, error) in
	if let response = response {
		print(response)
	} else {
		print(error ?? "")
	}
}

OAuth2 Token (sent as a parameter)

If you generate personal access token or receive access token from OAuth2, you can use it in next way:

let authentication = TokenAuthentication(token: "token")
UserAPI(authentication: authentication).getAllUsers(since: "1") { (reposne, error) in
	if let response = response {
		print(response)
	} else {
		print(error ?? "")
	}
}

Issues API

Create Issue:

let issue = Issue(title: "New Issue")
IssuesAPI(authentication: AccessTokenAuthentication(access_token: "access_token")).createIssue(owner: "owner", repository: "repository", issue: issue) { (response, error) in
	if let response = response {

	} else {
		print(error ?? "")
	}
}

Update Issue:

let issue = Issue(title: "Updated Issue")
        IssuesAPI(authentication: AccessTokenAuthentication(access_token: "access_token")).updateIssue(owner: "owner", repository: "repository", number: number, issue: issue) { (response, error) in
	if let response = response {

	} else {
		print(error ?? "")
	}
}

Repositories API

Get list of all repositories of user:

RepositoriesAPI(authentication: AccessTokenAuthentication(access_token: "access_token")).repositories(user: "user", type: .all) { (response, error) in
	if let response = response {

	} else {
		print(error ?? "")
	}
}

Search API

Seart all repositories which contains qwer in name:

SearchAPI().searchRepositories(q: "qwer", page: 1, per_page: 100) { (response, error) in
	if let response = response {

	} else {
		print(error ?? "")
	}
}

Example Application

To run the example project, clone the repo, and run pod install from the Example directory first.

Example project contains example app with list of all user's GitHub notification.

Requirements

  • Xcode 9 or later
  • iOS 9.0 or later
  • macOS 10.12 or later
  • Ubuntu 16.04 or later
  • Swift 4.0 or later

Installation

GitHubAPI is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod 'GithubAPI'

Author

Serhii Londar, [email protected]

License

GitHubAPI is available under the MIT license. See the LICENSE file for more info.

You might also like...
Swifter - A Twitter framework for iOS & OS X written in Swift
Swifter - A Twitter framework for iOS & OS X written in Swift

Getting Started Installation If you're using Xcode 6 and above, Swifter can be installed by simply dragging the Swifter Xcode project into your own pr

Swift client for Kubernetes
Swift client for Kubernetes

Table of contents Overview Compatibility Matrix Examples Usage Creating a client Configuring a client Client authentication Client DSL Advanced usage

 SDK for creating Telegram Bots in Swift.
SDK for creating Telegram Bots in Swift.

Chat • Changelog • Prerequisites • Getting started • Creating a new bot • Generating Xcode project • API overview • Debugging notes • Examples • Docum

Telegram Bot Framework written in Swift 5.1 with SwiftNIO network framework
Telegram Bot Framework written in Swift 5.1 with SwiftNIO network framework

Telegrammer is open-source framework for Telegram Bots developers. It was built on top of Apple/SwiftNIO

Solana + RxSolana This is a open source library on pure swift for Solana protocol

The objective is to create a cross platform, fully functional, highly tested and less depencies as posible. The project is still at initial stage. Lots of changes chan happen to the exposed api.

QuoteKit is a Swift framework to use the free APIs provided by Quotable created by Luke Peavey.
QuoteKit is a Swift framework to use the free APIs provided by Quotable created by Luke Peavey.

QuoteKit The QuoteKit is a Swift framework to use the free APIs provided by Quotable created by Luke Peavey.

Swift implementation of Github REST API v3
Swift implementation of Github REST API v3

GitHubAPI Swift implementation of GitHub REST api v3. Library support Swift 4.2. Work is in progress. Currently supported: Issues API. Activity API(Fe

GraphQL-GitHub-Reader - Simple sample project that demonstrates how to connect with GitHub's API using GraphQL + Apollo
GraphQL-GitHub-Reader - Simple sample project that demonstrates how to connect with GitHub's API using GraphQL + Apollo

GHPViewer A beatiful way to see your GitHub Profile Installation The project is splitted in two folders: GHPViewer: Contains the iOS Application relat

Fetch Multiple Rest API using Swift 5.5 Async Await with Task, TaskGroup, Continuation API
Fetch Multiple Rest API using Swift 5.5 Async Await with Task, TaskGroup, Continuation API

Source code for Tutorial on experimenting with Swift Async Await to fetch multiple REST API endpoints and eliminate Pyramid of Doom callback hell to improve code readability and maintanability

Managing Pull Requests and Issues For GitHub & GitHub Enterprise

Trailer For maintained binaries and/or more info: Latest macOS version Latest iOS version Trailer CLI for Mac, Linux and Windows Trailer for Android N

Aplicación SwiftUI para visualizar datos de Github dados un usuario y un token (Github token), implementa autenticación biométrica mediante FaceID.
Aplicación SwiftUI para visualizar datos de Github dados un usuario y un token (Github token), implementa autenticación biométrica mediante FaceID.

ios-app-swift-gitapp Aplicación SwiftUI para visualizar datos de Github dados un usuario y un token (Github token), implementa autenticación biométric

Xcode plugin to let you jump to GitHub History, Blame, PRs, Issues, Notifications of any GitHub repo with one shortcut.
Xcode plugin to let you jump to GitHub History, Blame, PRs, Issues, Notifications of any GitHub repo with one shortcut.

Reveal-In-GitHub Xcode plugin to let you jump to GitHub History, Blame, PRs, Issues, Notifications of current repo in one second. My company work on G

FlickrSearchPhotos - Simple search photos application which uses Flickr REST API made in Swift
FlickrSearchPhotos - Simple search photos application which uses Flickr REST API made in Swift

FlickrSearchPhotos - Simple search photos application which uses Flickr REST API made in Swift

A Swift library for Discord REST/Gateway API in all platforms.

swift-discord main develop A Swift library for Discord API. Package Products Discord, alias library that contains DiscordREST, DiscordGateway. Discord

The civilized way to write REST API clients for iOS / macOS
The civilized way to write REST API clients for iOS / macOS

The elegant way to write iOS / macOS REST clients Drastically simplifies app code by providing a client-side cache of observable models for RESTful re

demo: REST API with SwiftUI
demo: REST API with SwiftUI

CatAPISwiftUI demo: REST API with SwiftUI The example API is the cat API. https://thecatapi.com/ You can watch me develope this code on my Youtube cha

App for developers to test REST API.
App for developers to test REST API.

Httper Httper is a REST API test tool running on your iOS devices. It helps developers to test their REST APIs anywhere and anytime without PC. Featur

Photo Gallery App demo using a REST API

Photo Gallery iOS App - (Using Rest API) A demo Photo Gallery App using a Rest API using MVVM architecture in Swift + UIKit. Overview Fully Programmat

A stable, mature and comprehensive Objective-C library for Twitter REST API 1.1
A stable, mature and comprehensive Objective-C library for Twitter REST API 1.1

STTwitter A stable, mature and comprehensive Objective-C library for Twitter REST API 1.1 Like a FOSS version of Twitter Fabric TwitterKit, without th

Comments
  • Login with Token & Create Update File API

    Login with Token & Create Update File API

    Hello,

    • I was wondering how to login using with client id and secret and get the token back. In your example you're using GithubLoginVC which is no where to be found in the source code. Could you assist with this?

    • How would one go about using the Lib to create or update a file?

    opened by mediassumani 1
  • .get(owner: owner, repo: name.. returns nil values because of bad parsing (actually it's 401_)

    .get(owner: owner, repo: name.. returns nil values because of bad parsing (actually it's 401_)

     let authentication = AccessTokenAuthentication(access_token: GITHUB_TOKEN)
                let ghapi = RepositoriesAPI(authentication: authentication)
                ghapi.get(owner: owner, repo: name, completion:
                    { (response, error) in
                    if response != nil {
                        print(response!)
                    } else {
                        print(error ?? "empty response")
                    }
                })
    

    returns repo with all nil's.

    Actually session returns 401 with description:

    Optional<String>
      - some : "{\"message\":\"Bad credentials\",\"documentation_url\":\"https://developer.github.com/v3\"}"
    

    Can't realize, how to do authentification the right way

    opened by skywinder 1
  • RepositoriesAPI parse error

    RepositoriesAPI parse error

                let authentication = AccessTokenAuthentication(access_token: GITHUB_TOKEN)
                RepositoriesAPI(authentication: authentication).repositories(user: "skywinder", type: .all) { (response, error) in
                    if response != nil {
                        print(response!)
                    } else {
                        print(error ?? "empty response")
                    }
                    sema.signal()
                }
    

    gets error:

    typeMismatch(Swift.Array, Swift.DecodingError.Context(codingPath: [], debugDescription: "Expected to decode Array but found a dictionary instead.", underlyingError: nil))

    Line 37

    image
    opened by skywinder 0
Releases(0.0.11)
Owner
Serhii Londar
Serhii Londar
Google Directions API helper for iOS, written in Swift

PXGoogleDirections Google Directions API SDK for iOS, entirely written in Swift. ?? Features Supports all features from the Google Directions API as o

Romain L 268 Aug 18, 2022
Swift Reddit API Wrapper

reddift reddift is Swift Reddit API Wrapper framework, and includes a browser is developed using the framework. Supports OAuth2(is not supported on tv

sonson 236 Dec 28, 2022
Instagram API client written in Swift

SwiftInstagram is a wrapper for the Instagram API written in Swift. It allows you to authenticate users and request data from Instagram effortlessly.

Ander Goig 580 Nov 25, 2022
Instagram Private API Swift

SwiftyInsta Please notice SwiftyInsta may not be actively maintained at the moment of you reading this note. Refer to #244 for more info. Instagram of

Mahdi Makhdumi 218 Jan 5, 2023
A Swift client for the OpenAI API.

OpenAI A Swift client for the OpenAI API. Requirements Swift 5.3+ An OpenAI API Key Example Usage Completions import OpenAI

Mattt 161 Dec 26, 2022
Swift Bot with Vapor for Telegram Bot Api

Telegram Vapor Bot Please support Swift Telegram Vapor Bot Lib development by giving a ⭐️ Telegram Bot based on Swift Vapor. Swift Server Side Communi

OleG. 104 Jan 6, 2023
Swift library for the Twitter API v1 and v2

Swift library for the Twitter API v1 and v2

mironal 96 Dec 30, 2022
Backport of iOS 15 formatting api

This is a back-port of the .formatted API in Foundation that was introduced at WWDC '21 for iOS 15, macOS 12.0, tvOS 15.0, and watchOS 8.0.

Simon Salomons 9 Jul 22, 2022
Unofficial iOS/macOS SDK for the Notion API.

NotionClient: a Notion SDK for iOS & macOS Unofficial Notion API SDK for iOS & macOS. This is an alpha version and still work in progress. TODO Featur

David De Bels 15 Aug 4, 2022
👤 Framework to Generate Random Users - An Unofficial Swift SDK for randomuser.me

RandomUserSwift is an easy to use Swift framework that provides the ability to generate random users and their accompanying data for your Swift applic

Wilson Ding 95 Sep 9, 2022