All Projects → Chris-Perkins → Swifttwitch

Chris-Perkins / Swifttwitch

Licence: mit
👾 The New Twitch API for iOS; wrapped in Swift goodness 👾

Programming Languages

swift
15916 projects
swift4
162 projects

Projects that are alternatives of or similar to Swifttwitch

Python Twitch Client
Python wrapper for Twitch API
Stars: ✭ 137 (+90.28%)
Mutual labels:  wrapper, twitch
Rsformview
A Cocoapods library designed to easily create forms with multiple data entry fields
Stars: ✭ 84 (+16.67%)
Mutual labels:  pod, cocoapod
Numericaltextentry
An iOS library for beautiful number entry fields. iPad friendly. Written in Swift.
Stars: ✭ 16 (-77.78%)
Mutual labels:  pod, cocoapod
Abexpandableview
Expandable, collapsible, filterable and single/multi selectable table view.
Stars: ✭ 138 (+91.67%)
Mutual labels:  pod, cocoapod
Modernavplayer
ModernAVPlayer is a persistence AVPlayer wrapper
Stars: ✭ 179 (+148.61%)
Mutual labels:  wrapper, pod
Twitchio
TwitchIO - An Async Bot/API wrapper for Twitch made in Python.
Stars: ✭ 268 (+272.22%)
Mutual labels:  wrapper, twitch
Twitchcsharp
Twitch C# Wrapper for the Twitch v3 REST API
Stars: ✭ 36 (-50%)
Mutual labels:  wrapper, twitch
Nodeactyl
A NodeJS API for Pterodactyl panel, this was originally designed for discord.js (Discord bots)
Stars: ✭ 55 (-23.61%)
Mutual labels:  wrapper
Devchatterbot
Stars: ✭ 60 (-16.67%)
Mutual labels:  twitch
Retc
An application used to convert razer effects to multiple output sdks.
Stars: ✭ 54 (-25%)
Mutual labels:  wrapper
Mailjet Apiv3 Java
[API v3] Mailjet Java API Wrapper
Stars: ✭ 53 (-26.39%)
Mutual labels:  wrapper
Gwt Ol
GWT wrapper for OpenLayers 3+ using JSInterop
Stars: ✭ 57 (-20.83%)
Mutual labels:  wrapper
Remodel
Data and class remodeling library
Stars: ✭ 63 (-12.5%)
Mutual labels:  wrapper
Objcxx
Stars: ✭ 54 (-25%)
Mutual labels:  wrapper
Thpdfkit
PDF viewer component on top of Apples PDFKit
Stars: ✭ 68 (-5.56%)
Mutual labels:  pod
Pykcs11
PKCS#11 Wrapper for Python
Stars: ✭ 53 (-26.39%)
Mutual labels:  wrapper
Uglifyjs Online
JavaScript minifier in the browser
Stars: ✭ 71 (-1.39%)
Mutual labels:  wrapper
D2sqlite3
A small wrapper around SQLite for the D programming language
Stars: ✭ 67 (-6.94%)
Mutual labels:  wrapper
Rt Thread Wrapper Of Ucos Iii
RT-Thread操作系统的uCOS-III兼容层:让基于uC/OS-III操作系统开发的应用层无感地迁移到RT-Thread操作系统 | A wrapper which can make codes developed by uCOS-III APIs directly run on RT-Thread
Stars: ✭ 60 (-16.67%)
Mutual labels:  wrapper
Whc pageviewkit
iOS平台轻量级的PageView组件,其中TitleBar拥有30多种UI样式
Stars: ✭ 59 (-18.06%)
Mutual labels:  pod

Version License Platform Discord

THIS IS AN UNOFFICIAL, FAN-MADE WRAPPER. IT IS IN NO WAY ENDORSED BY TWITCH.TV

What is It?

Swift Twitch is a library intended for client-facing applications interaction with the New Twitch API, Helix. This library aims to ease API interaction by returning typed data values to help you finish your application without headaches. For example, after a non-empty Get Videos call, you can do the following:

let firstVideoData: VideoData = getVideosData.videoData.first!
let title: String = firstVideoData.title
let viewCount: Int = firstVideoData.viewCount

❤️ Pull requests are very welcome ❤️

Available API Calls

You can run the following API calls:

API Method Swift Function
Get Extension Analytics Twitch.Analytics.getExtensionAnalytics
Get Game Analytics Twitch.Analytics.getGameAnalytics
Get Bits Leaderboard Twitch.Bits.getBitsLeaderboard
Create Clip Twitch.Clips.createClip
Get Clips Twitch.Clips.getClips
Get Top Games Twitch.Games.getTopGames
Get Games Twitch.Games.getGames
Get Streams Twitch.Streams.getStreams
Get Streams Metadata Twitch.Streams.getStreamsMetadata
Create Stream Marker Twitch.Streams.createStreamMarker
Get Stream Markers Twitch.Streams.getStreamMarkers
Get Users Twitch.Users.getUsers
Get Users Follows Twitch.Users.getUsersFollows
Update User Twitch.Users.updateUser
Get User Extensions Twitch.Users.getUserExtensions
Get Videos Twitch.Videos.getVideos

Documentation

New Twitch API (Helix) Documentation

Swift Twitch Documentation

  • If the above link is not working, clone this repo and open docs/index.html

Example Usage

How to check if a user is following another user
import SwiftTwitch

class AwesomeClass {
    func spectacularFunction() {
        TwitchTokenManager.shared.accessToken = "$SomeValidToken"
        TwitchTokenManager.shared.clientID = "$ClientIDForAccessToken"

        let user1Id = "1234"
        let user2Id = "5678"
        Twitch.Users.getUsersFollows(followerId: user1Id, followedId: user2Id) { result in 
            switch result {
            case .success(let getUsersFollowsData):
                /* If the total = 1, we know that user1 is following user2 
                   as it is documented in the Twitch API docs. */
                if getUsersFollowsData.total == 1 {
                    print("User \(user1Id) is following user \(user2Id)!")
                } else {
                    print("User \(user1Id) is not following user \(user2Id)")
                }
            case .failure(let data, let response, let error):
                print("The API call failed! Unable to determine relationship.")
            }
        }
    }
}

Get Started

I don't have an access token!

In order to use this library, you must first have an application register on the Twitch Developer portal. You can register your application quickly on Twitch's official application creation dashboard. After this step, there are two methods to retrieving API keys.

Manually Retrieve Access Token

To manually retrieve an access token, please utilize this guide by Twitch.

Automatically Retrieve Access Token

If you need an access token generated by the user, you have a few options:

  1. Create a custom OAuth token retriever. This can be done using Web Views to the OAuth token portal.
  2. Use a library to do it for you! There's a few OAuth libraries out there.
    1. OAuthSwift
    2. OAuth2

I have my access token, now what?

Now that you have an access token, you can provide it to the application in the following manner:

TwitchTokenManager.shared.accessToken = "$Your_Token"
TwitchTokenManager.shared.clientID = "$Client_ID_Used_To_Get_Token"

Once this command is run, all of your API calls are now automatically authenticated! Now go make some API calls. :)

I want to embed a Twitch Stream/Clip/Video in my app!

I made a separate library for that! Please see TwitchPlayer!

I still have questions!

For Twitch Swift support, feel free to open up an issue or email me at [email protected]. For API-based support, please visit The Twitch Developer Forums

Installation

  1. Install CocoaPods

  2. Add this repo to your Podfile

    target 'Example' do
    	# IMPORTANT: Make sure use_frameworks! is included at the top of the file
    	use_frameworks!
    
    	pod 'SwiftTwitch'
    end
    
  3. Run pod install in the podfile directory from your terminal

  4. Open up the .xcworkspace that CocoaPods created

  5. Done!

Example Project

To run the example project, clone the repo, and run pod install from the Example directory. After that, open the resulting .xcworkspace file and go nuts!

The example project is a simple Videos browser for a pre-selected user on Twitch. To run the example project properly, you will need an access token. Set this access token in TwitchVideosTableViewController's viewDidLoad method.

Contributing

Thank you so much for wanting to contribute! There are a couple of things you can do if you want to help out the project.

Layout of helpful contributions
  • Helper functions for verbosity

    Examples:

    • getUserWithIDFollowers(_ userId: String) to get the users that are following the user
    • getUserWithIDFollowings(_ userId: String) to get the users that are being followed by the user

    Both of these functions are just wrapped around my pre-existing getUsersFollows method, but they make the code that uses them more explicit.

  • Additional Documentation

    • Some documentation regarding the Helix API in this library is lacking. It would be awesome to have someone go back and double-check the functions as they use the library.
  • Missing functions

  • Anything you think would be nice! I'll most likely agree with the user (you). 😊

License

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

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].