Unofficial GitHub API client in Swift

Overview

Github.swift

❤️ Support my apps ❤️

❤️ ❤️ 😇 😍 🤘 ❤️ ❤️

CI Status Version Carthage Compatible License Platform

Description

Usage

Client

  • User: identify a user
  • Server: identify server (Github or Github Enterprise)
  • Client: make request. If associated with a valid token, it is considered authenticated client
let _ =
  Client.signInUsingWebBrowser(Server.dotComServer, scopes: [.Repository])
    .flatMap { client in
      return client.fetchUserRepositories()
    }.subscribeNext { repositories in
      repositories.forEach { print($0.name)
    }
  }

Request Descriptor

Make your own request using RequestDescriptor, using syntax from Construction

let requestDescriptor: RequestDescriptor = construct {
  $0.path = "repos/\(owner)/\(name)"
  $0.etag = "12345"
  $0.offset = 2
  $0.perPage = 50
  $0.parameters["param"] = "value"
  $0.headers["header"] = "value"
  $0.method = .PUT  
}

return enqueue(requestDescriptor).map {
  return Parser.one($0)
}

Pagination

  • The subscribe gets called many times if there is pagination
client
.fetchUserRepositories()
.subscribeNext { repositories in
  // This gets called many times depending pagination
  repositories.forEach { print($0.name)
}
  • Use toArray if we want subscribe to be called once with all the values collected
client
.fetchUserRepositories()
.toArray()
.subscribeNext { repositories: [[Repository]] in
  repositories.flatMap({$0}).forEach { print($0.name)
}

Features

Metadata

  • Fetch server metadata

Sign in

  • Native flow
  • OAuth flow

User

  • Follow
  • Unfollow
  • Fetch user info

Repository

  • Fetch repositories
  • Create repository
  • Fetch commits
  • Fetch pull requests
  • Fetch issues
  • Watch

Pull request

  • Make pull requests

Issue

  • Create issue
  • Fetch issues

Organization

  • Fetch organizations
  • Fetch teams

Search

  • Search repositories

Event

  • Fetch user events

Gists

  • Fetch gists

Git

  • Create tree
  • Create blob
  • Create commit

Activity

  • Star
  • Unstar

Notification

  • Fetch notifications

Installation

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

pod 'GithubSwift'

GithubSwift is also available through Carthage. To install just write into your Cartfile:

github "onmyway133/Github.swift"

Author

Khoa Pham, [email protected]

Contributing

We would love you to contribute to GithubSwift, check the CONTRIBUTING file for more info.

License

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

You might also like...
An Elegant Spotify Web API Library Written in Swift for iOS and macOS
An Elegant Spotify Web API Library Written in Swift for iOS and macOS

Written in Swift 4.2 Spartan is a lightweight, elegant, and easy to use Spotify Web API wrapper library for iOS and macOS written in Swift 3. Under th

Swift Wrapper For Bittrex API

BittrexApiKit Swift client for Bittrex api. It support all APIs with most recent changes. more info here let api = Bittrex(apikey: "api key", secretke

A Swift library for the Forecast.io Dark Sky API
A Swift library for the Forecast.io Dark Sky API

Requirements To use ForecastIO, all you need is an API key for the Dark Sky API. ForecastIO supports iOS (≥9.0), macOS (≥10.10), watchOS (≥2.0), and t

Questrade API written in Swift.

QuestradeAPI Getting Started The QuestAPI is made up of two main concepts: ResponseProviders API ResponseProviders The job of the provider is to retur

Endless-Api-OP - A swift server for Endless
Endless-Api-OP - A swift server for Endless

Endless-Api Introduce Hear is endless-api open source library. Endless-Api is us

The best way to use the Zora API in your Swift projects.

ZoraKit The best way to use the Zora API in your Swift projects. Disclaimer This is still very much a work in progress, and is really a proof-of-conce

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

Twitter API for Cocoa developers

FHSTwitterEngine Twitter API for Cocoa developers Created by Nathaniel Symer FHSTwitterEngine can: Authenticate using OAuth and/or xAuth. Make a reque

An easy-to-use Objective-C wrapper for the Uber API (no longer supported)
An easy-to-use Objective-C wrapper for the Uber API (no longer supported)

UberKit UberKit is a simple Objective-C wrapper for the new Uber API . Installation Cocoapods UberKit is available through Cocoapods. To install it, s

Comments
  • The 'Event' name

    The 'Event' name

    I was try to do something like this in my viewModel:

    struct UserEventModel {
    
      let events: Observable<[Event]>
    
    }
    

    It seems the name Event conflict with the Event in RxSwift.

    : (

    opened by Tangdixi 3
  • About the etag in `fetchUserEvents`

    About the etag in `fetchUserEvents`

    Sorry to bother you again @onmyway133 😓
    This method is return an Observable<[Events]> (transform from Observable<Response>)

      public func fetchUserEvents(etag: String? = nil,
                                  offset: Int = 0, perPage: Int = Constant.defaultPerPage) -> Observable<[Event]> {
        if !isAuthenticated {
          return Observable<[Event]>.error(Error.authenticationRequiredError())
        }
    
        let requestDescriptor: RequestDescriptor = construct {
          $0.path = "users/\(user?.login ?? "")/received_events"
          $0.offset = offset
          $0.perPage = perPage
          $0.etag = etag
        }
    
        return enqueue(requestDescriptor).map {
          return Parser.all($0)
        }
      }
    

    So how can I fetch the etag .....

    opened by Tangdixi 2
Owner
Khoa
Check my apps https://onmyway133.com/apps
Khoa
Unofficial Dribbble iOS wrapper allows you to integrate Dribble API into iOS application (Designer, Shot, Comment, User Story, Like, Follow)

DribbbleSDK DribbbleSDK is easy-to-use iOS wrapper for Dribbble SDK. We're working hard to complete the full coverage of available methods and make th

Agilie Team 74 Dec 2, 2020
👤 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
The unofficial Instagram iOS SDK

InstagramKit An extensive Objective C wrapper for the Instagram API, completely compatible with Swift. Here's a quick example to retrieve trending med

Shyam Bhat 955 Dec 12, 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 579 Dec 31, 2022
A Slack API Client for the Perfect Server-Side Swift Framework

PerfectSlackAPIClient is an API Client to access the Slack API from your Perfect Server Side Swift application. It is build on top of PerfectAPIClient

Cap.雪ノ下八幡 2 Dec 1, 2019
Giphy API client for iOS in Objective-C

Giphy-iOS Giphy-iOS is a Giphy API client for iOS in Objective-C. Usage To run the example project, clone the repo, and run pod install from the Examp

alex choi 52 Jul 11, 2019
Swift client for Unsplash

Unsplash API client written in Swift. Unsplash offers 2 APIs: Source API (unlimited requests) Official API JSON API (5000 requests / hour) JSON API is

Modo 188 Nov 12, 2022
A Dropbox v2 client library written in Objective-C

TJDropbox TJDropbox is a Dropbox v2 client library written in Objective-C. When Dropbox originally announced their v2 API they included only a Swift c

Tim Johnsen 61 Dec 21, 2022
A Swift wrapper for Foursquare API. iOS and OSX.

Das Quadrat Das Quadrat is Foursquare API wrapper written in Swift. Features Supports iOS and OSX. Covers all API endpoints. Authorization process imp

Constantine Fry 171 Jun 18, 2022
A swift SDK for Medium's OAuth2 API

Medium SDK - Swift A library to allow access to Medium API for any Swift iOS application. Features Medium.com authorization & token handling Login sta

null 11 Jan 22, 2022