{"id":13758545,"url":"https://github.com/Chris-Perkins/SwiftTwitch","last_synced_at":"2025-05-10T08:30:33.229Z","repository":{"id":62456748,"uuid":"163452492","full_name":"Chris-Perkins/SwiftTwitch","owner":"Chris-Perkins","description":"👾 The New Twitch API for iOS; wrapped in Swift goodness 👾","archived":true,"fork":false,"pushed_at":"2020-11-02T16:11:39.000Z","size":901,"stargazers_count":81,"open_issues_count":6,"forks_count":14,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-23T22:15:32.251Z","etag":null,"topics":["cocoapod","helix","helix-api","ios","ios-swift","pod","swift","swift4","twitch","twitch-api","wrapper","wrapper-api"],"latest_commit_sha":null,"homepage":"","language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Chris-Perkins.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-12-28T21:52:19.000Z","updated_at":"2024-11-19T16:49:50.000Z","dependencies_parsed_at":"2022-11-02T00:17:26.468Z","dependency_job_id":null,"html_url":"https://github.com/Chris-Perkins/SwiftTwitch","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Chris-Perkins%2FSwiftTwitch","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Chris-Perkins%2FSwiftTwitch/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Chris-Perkins%2FSwiftTwitch/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Chris-Perkins%2FSwiftTwitch/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Chris-Perkins","download_url":"https://codeload.github.com/Chris-Perkins/SwiftTwitch/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253389432,"owners_count":21900760,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cocoapod","helix","helix-api","ios","ios-swift","pod","swift","swift4","twitch","twitch-api","wrapper","wrapper-api"],"created_at":"2024-08-03T13:00:32.168Z","updated_at":"2025-05-10T08:30:32.001Z","avatar_url":"https://github.com/Chris-Perkins.png","language":"Swift","funding_links":[],"categories":["Libraries"],"sub_categories":["Swift"],"readme":"![](https://github.com/Chris-Perkins/SwiftTwitch/raw/master/Readme_Imgs/SwiftTwitch.jpg)\n\n[![Version](https://img.shields.io/cocoapods/v/SwiftTwitch.svg?style=flat)](https://cocoapods.org/pods/SwiftTwitch)\n[![License](https://img.shields.io/cocoapods/l/SwiftTwitch.svg?style=flat)](https://cocoapods.org/pods/SwiftTwitch)\n[![Platform](https://img.shields.io/cocoapods/p/SwiftTwitch.svg?style=flat)](https://cocoapods.org/pods/SwiftTwitch)\n[![Discord](https://img.shields.io/discord/325552783787032576.svg?label=support)](https://discord.gg/3vj5SnY)\n\n**THIS IS AN UNOFFICIAL, FAN-MADE WRAPPER. IT IS IN NO WAY ENDORSED BY TWITCH.TV**\n\n## What is It?\n\nSwift 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.\nFor example, after a non-empty `Get Videos` call, you can do the following:\n\n```Swift\nlet firstVideoData: VideoData = getVideosData.videoData.first!\nlet title: String = firstVideoData.title\nlet viewCount: Int = firstVideoData.viewCount\n```\n\n❤️ Pull requests are very welcome ❤️\n\n## Available API Calls\n\nYou can run the following API calls:\n\n| API Method | Swift Function |  \n|:-:|:-:|  \nGet Extension Analytics | `Twitch.Analytics.getExtensionAnalytics`\nGet Game Analytics | `Twitch.Analytics.getGameAnalytics`\nGet Bits Leaderboard | `Twitch.Bits.getBitsLeaderboard`\nCreate Clip | `Twitch.Clips.createClip`\nGet Clips | `Twitch.Clips.getClips`\nGet Top Games | `Twitch.Games.getTopGames`\nGet Games | `Twitch.Games.getGames`\nGet Streams | `Twitch.Streams.getStreams`\nGet Streams Metadata | `Twitch.Streams.getStreamsMetadata`\nCreate Stream Marker | `Twitch.Streams.createStreamMarker`\nGet Stream Markers | `Twitch.Streams.getStreamMarkers`\nGet Users | `Twitch.Users.getUsers`\nGet Users Follows | `Twitch.Users.getUsersFollows`\nUpdate User | `Twitch.Users.updateUser`\nGet User Extensions | `Twitch.Users.getUserExtensions`\nGet Videos | `Twitch.Videos.getVideos`\n\n### Documentation\n\n[New Twitch API (Helix) Documentation](https://dev.twitch.tv/docs/api/reference/)\n\n[Swift Twitch Documentation](https://htmlpreview.github.io/?https://github.com/Chris-Perkins/SwiftTwitch/blob/master/docs/index.html)\n\n* If the above link is not working, clone this repo and open `docs/index.html`\n\n### Example Usage\n\n\u003cdetails\u003e  \n\u003csummary\u003eHow to check if a user is following another user\u003c/summary\u003e  \n\n```Swift\nimport SwiftTwitch\n\nclass AwesomeClass {\n    func spectacularFunction() {\n        TwitchTokenManager.shared.accessToken = \"$SomeValidToken\"\n        TwitchTokenManager.shared.clientID = \"$ClientIDForAccessToken\"\n\n        let user1Id = \"1234\"\n        let user2Id = \"5678\"\n        Twitch.Users.getUsersFollows(followerId: user1Id, followedId: user2Id) { result in \n            switch result {\n            case .success(let getUsersFollowsData):\n                /* If the total = 1, we know that user1 is following user2 \n                   as it is documented in the Twitch API docs. */\n                if getUsersFollowsData.total == 1 {\n                    print(\"User \\(user1Id) is following user \\(user2Id)!\")\n                } else {\n                    print(\"User \\(user1Id) is not following user \\(user2Id)\")\n                }\n            case .failure(let data, let response, let error):\n                print(\"The API call failed! Unable to determine relationship.\")\n            }\n        }\n    }\n}\n\n```\n\u003c/details\u003e\n\n## Get Started\n\n### I don't have an access token!\n\nIn 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](https://glass.twitch.tv/console/apps/create). After this step, there are two methods to retrieving API keys.\n\n#### Manually Retrieve Access Token\n\n[To manually retrieve an access token, please utilize this guide by Twitch.](https://dev.twitch.tv/docs/authentication/getting-tokens-oauth/#oauth-implicit-code-flow)\n\n#### Automatically Retrieve Access Token\n\nIf you need an access token generated by the user, you have a few options:\n\n1. Create a custom OAuth token retriever. This can be done using Web Views to the OAuth token portal.  \n1. Use a library to do it for you! There's a few OAuth libraries out there.\n    1. [OAuthSwift](https://github.com/OAuthSwift/OAuthSwift)\n    1. [OAuth2](https://github.com/p2/OAuth2)\n\n### I have my access token, now what?\n\nNow that you have an access token, you can provide it to the application in the following manner:\n\n```Swift\nTwitchTokenManager.shared.accessToken = \"$Your_Token\"\nTwitchTokenManager.shared.clientID = \"$Client_ID_Used_To_Get_Token\"\n```\n\nOnce this command is run, all of your API calls are now automatically authenticated! Now go make some API calls. :)\n\n### I want to embed a Twitch Stream/Clip/Video in my app!\n\nI made a separate library for that! Please see [TwitchPlayer](https://github.com/Chris-Perkins/TwitchPlayer)!\n\n### I still have questions!\n\nFor Twitch Swift support, feel free to open up an issue or email me at `chris@chrisperkins.me`. For API-based support, please visit [The Twitch Developer Forums](https://discuss.dev.twitch.tv/)\n\n## Installation\n\n1. Install [CocoaPods](https://cocoapods.org)\n1. Add this repo to your `Podfile`\n\n\t```ruby\n\ttarget 'Example' do\n\t\t# IMPORTANT: Make sure use_frameworks! is included at the top of the file\n\t\tuse_frameworks!\n\n\t\tpod 'SwiftTwitch'\n\tend\n\t```\n1. Run `pod install` in the podfile directory from your terminal\n1. Open up the `.xcworkspace` that CocoaPods created\n1. Done!\n\n## Example Project\n\n![](https://github.com/Chris-Perkins/SwiftTwitch/raw/master/Readme_Imgs/ExampleProject)\n\nTo 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!\n\nThe 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. \n\n## Contributing\n\nThank you so much for wanting to contribute! There are a couple of things you can do if you want to help out the project.\n\n\u003cdetails\u003e\n\u003csummary\u003eLayout of helpful contributions\u003c/summary\u003e\n\n- Helper functions for verbosity\n\n\tExamples: \n\t* `getUserWithIDFollowers(_ userId: String)` to get the users that are following the user\n\t* `getUserWithIDFollowings(_ userId: String)` to get the users that are being followed by the user  \n\t\n\tBoth of these functions are just wrapped around my pre-existing `getUsersFollows` method, but they make the code that uses them more explicit.\n- Additional Documentation\n\t* 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.\n- Missing functions\n\t* Currently, we're missing the following Twitch API functions:\n\t\t* [Get User Active Extensions](https://dev.twitch.tv/docs/api/reference/#get-user-active-extensions)\n\t\t* [Update User Active Extensions](https://dev.twitch.tv/docs/api/reference/#update-user-extensions)\n\n\t\tI was actually unsure how to implement these nicely due to their weird way of indexing. If you know what to do, you would be an amazing help.\n\n- Anything you think would be nice! I'll most likely agree with the user (you). 😊\n\n\u003c/details\u003e\n\n## License\n\nSwiftTwitch is available under the MIT license. See the LICENSE file for more info.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FChris-Perkins%2FSwiftTwitch","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FChris-Perkins%2FSwiftTwitch","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FChris-Perkins%2FSwiftTwitch/lists"}