{"id":13465337,"url":"https://github.com/sonsongithub/reddift","last_synced_at":"2025-10-12T19:31:28.647Z","repository":{"id":30153712,"uuid":"33703942","full_name":"sonsongithub/reddift","owner":"sonsongithub","description":"Swift Reddit API Wrapper","archived":true,"fork":false,"pushed_at":"2020-03-07T18:33:51.000Z","size":3818,"stargazers_count":238,"open_issues_count":7,"forks_count":52,"subscribers_count":9,"default_branch":"master","last_synced_at":"2025-10-02T03:27:38.617Z","etag":null,"topics":["oauth","playground","reddit","swift"],"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/sonsongithub.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":"2015-04-10T02:28:14.000Z","updated_at":"2025-09-04T11:38:51.000Z","dependencies_parsed_at":"2022-08-21T05:20:31.801Z","dependency_job_id":null,"html_url":"https://github.com/sonsongithub/reddift","commit_stats":null,"previous_names":[],"tags_count":14,"template":false,"template_full_name":null,"purl":"pkg:github/sonsongithub/reddift","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sonsongithub%2Freddift","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sonsongithub%2Freddift/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sonsongithub%2Freddift/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sonsongithub%2Freddift/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sonsongithub","download_url":"https://codeload.github.com/sonsongithub/reddift/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sonsongithub%2Freddift/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279012668,"owners_count":26085159,"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","status":"online","status_checked_at":"2025-10-12T02:00:06.719Z","response_time":53,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["oauth","playground","reddit","swift"],"created_at":"2024-07-31T15:00:27.723Z","updated_at":"2025-10-12T19:31:28.062Z","avatar_url":"https://github.com/sonsongithub.png","language":"Swift","funding_links":[],"categories":["Libs","News","API [🔝](#readme)","Networking"],"sub_categories":["API","Video"],"readme":"[![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage)\n[![Version](http://img.shields.io/cocoapods/v/reddift.svg?style=flat)](http://cocoadocs.org/docsets/reddift)\n[![License](https://img.shields.io/cocoapods/l/reddift.svg?style=flat)](http://cocoadocs.org/docsets/reddift)\n[![Platform](https://img.shields.io/cocoapods/p/reddift.svg?style=flat)](http://cocoadocs.org/docsets/reddift)\n[![Build Status](https://travis-ci.org/sonsongithub/reddift.svg?branch=master)](https://travis-ci.org/sonsongithub/reddift)\n\n# reddift\nreddift is Swift Reddit API Wrapper framework, and includes a browser is developed using the framework.\n\n * Supports OAuth2(is not supported on tvOS currently).\n * Supports multi-accounts.\n * Includes a sample application(iOS only).\n\n## Browser\n\n * It's a typical browser of reddit.com.\n * This application uses \"reddift framework\" in order to access reddit.com.\n * Includes almost all of functions, such as image thumbnails, browsing comments, search subreddits and so on.\n * If you need more features to this, please send pull requests to me.\n\n![reddift-comments](https://cloud.githubusercontent.com/assets/33768/22405496/0c84f384-e687-11e6-9658-5ebf9d39a082.gif) \n![reddift-images](https://cloud.githubusercontent.com/assets/33768/22405518/62246ed2-e687-11e6-9f4a-ce45c1d5bd71.gif)\n\n## Document\n\n* See [cocoapods](http://cocoadocs.org/docsets/reddift/).\n* [List of not implemented APIs](https://github.com/sonsongithub/reddift/wiki/Not-implemented-APIs)\n\n## How to build\n\nNow, it's under developing.\nYou have to pay attention to use this library.\n\n#### 1. Check out source code.\n\n```\n# check out reddift and its submodules.\n\u003e git clone --recursive https://github.com/sonsongithub/reddift.git\n```\n\nCheck that these libraries are checked out at each path correctly.\n\n```\n/framework/vendor/HTMLSpecialCharacters\n/framework/vendor/MiniKeychain\n```\n\n#### 2. Create application(installed app) at reddit.com\n\nCreate new installed app via preference page at reddit.com.\nAnd then, check your app's ```cliend_id``` and fill out ```redirect_uri``` for OAuth2.\nFor example, ```redirect_uri``` is set to ```myapp://response```.\nIn following sample, ```redirect_uri``` is set to ```reddift://response```.\n\n![installedapp](https://cloud.githubusercontent.com/assets/33768/7569703/7aa0cd84-f845-11e4-8860-2c953c9522a2.png)\n\n\n#### 3. Set up ````reddift_config.json````\n\nThis JSON file saves application information to use OAuth.\nRename ```reddift_config.json.sample``` to ```reddift_config.json```.\nAnd fill out ```DeveloperName```, ```redirect_uri``` and ```client_id```.\n```redirect_uri``` must be same one you registered at reddit.com.\nYou can check ```client_id``` at application tab.\nreddift generates http's user-agent property using this JSON and application's info.plist.\n\n    {\n      \"DeveloperName\": \"\u003cYOUR NAME\u003e\",\n      \"redirect_uri\": \"\u003cYOUR REDIRECT URI\u003e\",\n      \"client_id\": \"\u003cYOUR ID\u003e\"\n    }\n\n#### 4. Set up your URI on Xcode\n\nIn Xcode, set up URL Types in order to receive call back from Safari.\nSet ```URL Schemes``` to ```redirect_uri``` that you set at reddit.com. \nYou don't have to include ```://response``` to this form.\nThese URI must be identical.\nIf they are not identical, reddit.com does not authorize your OAuth request.\nIn following sample, ```URL Schemes``` is set to ```reddift```.\n\n![reddit2](https://cloud.githubusercontent.com/assets/33768/7277677/52a1d1f0-e94c-11e4-9125-18c3acf13c0b.png)\n\n## How to build test\n\n#### 1. Register user script app\n\nTest uses Application Only OAuth to remove user interaction from test process.\nIf you want to run tests of reddift, you have to create another \"Script\" type application(personal use script) at reddit.com.\n\n![userscript](https://cloud.githubusercontent.com/assets/33768/7569704/7ad7bf10-f845-11e4-8e10-89487a65d5d4.png)\n\n#### 2. Fill out ````test_config.json````\n\nAt first, rename ````test_config.json.sample```` to ````test_config.json````.\nFill each following value using above preference pain of reddit.com.\n\n    {\n      \"username\": \"test user account\",\n      \"password\": \"test user password\",\n      \"client_id\": \"test app client ID(must be script type app)\",\n      \"secret\": \"test app secret\"\n    }\n\n#### 3. Start test\n\nCmd + U.\n\n## How to build browser sample\n\nYou have to build dependent frameworks using `carthage` before building a sample application using Xcode.\n\n    # before open xcode project file.\n    \u003e carthage update --platform iOS\n\n`carthage` works corretly, you can get following frameworks at each path.\n    \n```\n/Carthage/Build/iOS/FLAnimatedImage.framework\n/Carthage/Build/iOS/YouTubeGetVideoInfoAPIParser.framework\n/Carthage/Build/iOS/UZTextView.framework\n```\n    \nAnd, you get to edit URI types and reddift_config.json as same as the framework.\n\n## Create you app.\n\n#### Get something \u0026 Error handling\n\nreddift returns ```Result\u003cT\u003e``` object as a result.\nGet the value or error from ```Result\u003cT\u003e``` object.\nConcretely, you can access either value evaluating enum state like a following code.\n\n\n    // do not use \"!\" in your code\n    switch(result) {\n    case .failure(let error):\n        println(error)\n    case .success(let listing):\n        // do something to listing\n    }\n\nIn more detail about this coding style, see \"[Efficient JSON in Swift with Functional Concepts and Generics](https://robots.thoughtbot.com/efficient-json-in-swift-with-functional-concepts-and-generics)\".\n\n#### Create session\n\nAt first, you have to implement codes to receive the response of OAuth2 in ```UIAppDelegate```.\nreddift let you save tokens as a specified name into KeyChain.\nSpecifically, following sample code saves token as user name at reddit.com.\n\n    func application(application: UIApplication, openURL url: NSURL, sourceApplication: String?, annotation: AnyObject) -\u003e Bool {\n        return OAuth2Authorizer.sharedInstance.receiveRedirect(url, completion:{(result) -\u003e Void in\n            switch result {\n            case .failure(let error):\n                print(error)\n            case .success(let token):\n                dispatch_async(dispatch_get_main_queue(), { () -\u003e Void in\n                    OAuth2TokenRepository.saveIntoKeychainToken(token, name:token.name)\n                })\n            }\n        })\n    }\n\nTo communicate with reddit.com via OAuth2, you have to create ```Session``` object.\nSee following section about getting response or error handling.\n\n\tlet result = OAuth2TokenRepository.restoreFromKeychainWithName(name)\n\tswitch result {\n\tcase .failure(let error):\n\t    print(error.description)\n\tcase .success(let token):\n\t    con.session = Session(token: token)\n\t}\n\nYou can get contents from reddit via ```Session``` object like following codes.\n\n    session?.getList(paginator, subreddit:subreddit, sort:sortTypes[seg.selectedSegmentIndex], timeFilterWithin:.All, completion: { (result) in\n        switch result {\n        case .failure(let error):\n            print(error)\n        case .success(let listing):\n            self.links.appendContentsOf(listing.children.flatMap{$0 as? Link})\n        }\n    })\n\n#### Use Application Only OAuth\n\nYou can use ```OAuth2AppOnlyToken``` when you want to write a code for test or personal script tool(such as CLI).\n```OAuth2AppOnlyToken``` enabled to access reddit without human action in order to authorize in web browser apps.\nDo not use ```Oauth2AppOnlyToken``` in installed app in terms of security.\n\n    OAuth2AppOnlyToken.getOAuth2AppOnlyToken(\n        username: username,\n        password: password,\n        clientID: clientID,\n        secret: secret,\n        completion:( { (result) -\u003e Void in\n        switch result {\n        case .failure(let error):\n            print(error)\n        case .success(let token):\n            self.session = Session(token: token)\n        }\n    }))\n\n#### Further more,\n\nIn more detail, See my sample application, test code or Playground code included in this repository.\n\n## Playground\n\nYou can play with reddift in Playground.\nIn more detail, check reddift.playground package.\nBefore using, you have to copy ```test_config.json``` into ```./reddift.playground/Resources``` in order to specify user account and your application informatin because reddift on Playground uses \"Application Only OAuth\".\n\n![playground](https://cloud.githubusercontent.com/assets/33768/21675684/01d132d2-d376-11e6-9c12-77c034a74c9d.png)\n\n## Dependency\n\n* reddift depends on [MiniKeychain](https://github.com/sonsongithub/MiniKeychain) for saving access tokens.\n* Sample application depends on [UZTextView](https://github.com/sonsongithub/UZTextView.git).\n\n## License\n\nMIT License.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsonsongithub%2Freddift","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsonsongithub%2Freddift","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsonsongithub%2Freddift/lists"}