{"id":1893,"url":"https://github.com/shyambhat/InstagramKit","last_synced_at":"2025-08-02T05:32:59.495Z","repository":{"id":9498653,"uuid":"11391086","full_name":"shyambhat/InstagramKit","owner":"shyambhat","description":"The unofficial Instagram iOS SDK","archived":false,"fork":false,"pushed_at":"2020-06-12T05:47:27.000Z","size":1681,"stargazers_count":970,"open_issues_count":30,"forks_count":266,"subscribers_count":44,"default_branch":"master","last_synced_at":"2024-11-29T03:50:49.071Z","etag":null,"topics":["instagram","instagram-sdk","ios","keychain","objectivec"],"latest_commit_sha":null,"homepage":"","language":"Objective-C","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/shyambhat.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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":"2013-07-13T16:59:15.000Z","updated_at":"2024-10-17T01:32:49.000Z","dependencies_parsed_at":"2022-09-20T21:00:50.672Z","dependency_job_id":null,"html_url":"https://github.com/shyambhat/InstagramKit","commit_stats":null,"previous_names":[],"tags_count":23,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shyambhat%2FInstagramKit","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shyambhat%2FInstagramKit/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shyambhat%2FInstagramKit/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shyambhat%2FInstagramKit/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/shyambhat","download_url":"https://codeload.github.com/shyambhat/InstagramKit/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":228443674,"owners_count":17920765,"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":["instagram","instagram-sdk","ios","keychain","objectivec"],"created_at":"2024-01-05T20:15:58.346Z","updated_at":"2024-12-06T09:30:31.978Z","avatar_url":"https://github.com/shyambhat.png","language":"Objective-C","funding_links":[],"categories":["SDK","Unofficial","非官方","Objective-C  Stars 1000以内排名整理","Objective-C","Instagram api"],"sub_categories":["Unofficial","Other free courses"],"readme":"# InstagramKit\n\n[![CI Status](https://img.shields.io/travis/shyambhat/InstagramKit.svg?style=flat)](https://travis-ci.org/shyambhat/InstagramKit)\n[![Version](https://img.shields.io/cocoapods/v/InstagramKit.svg?style=flat)](https://cocoapods.org/pods/InstagramKit)\n[![License](https://img.shields.io/cocoapods/l/InstagramKit.svg?style=flat)](https://cocoapods.org/pods/InstagramKit)\n[![Platform](https://img.shields.io/cocoapods/p/InstagramKit.svg?style=flat)](https://cocoapods.org/pods/InstagramKit)\n\n[![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage)\n[![Apps Using](https://img.shields.io/cocoapods/at/InstagramKit.svg?label=Apps)](http://cocoapods.org/pods/InstagramKit)\n[![Downloads](https://img.shields.io/cocoapods/dt/InstagramKit.svg?label=Downloads)](http://cocoapods.org/pods/InstagramKit)\n[![Twitter: @bhatthead](https://img.shields.io/badge/contact-@bhatthead-blue.svg?style=flat)](https://twitter.com/bhatthead)\n\nAn extensive Objective C wrapper for the Instagram API, completely compatible with Swift.\n\nHere's a quick example to retrieve trending media on Instagram:\n\n```Objective-C\nInstagramEngine *engine = [InstagramEngine sharedEngine];\n[engine getPopularMediaWithSuccess:^(NSArray *media, InstagramPaginationInfo *paginationInfo) {\n// media is an array of InstagramMedia objects\n...\n} failure:^(NSError *error, NSInteger statusCode) {\n...\n}];\n```\n\nThe framework is built atop AFNetworking’s blocks-based architecture and additionally, parses JSON data and creates model objects asynchronously so there’s absolutely no parsing on the main thread.\nIt’s neat, fast and works like a charm.\n\n## Example\n\nTo run the example project, clone the repo, and run `pod install` from the Example directory first.\n\n## Installation\n\nInstagramKit is available through [CocoaPods](https://cocoapods.org). To install\nit, simply add the following line to your Podfile:\n\n```ruby\npod 'InstagramKit'\n```\n\nIf your App uses authorization and you'd like the storage and retrieval of the access token in the Keychain to be automatically handled for you by UICKeyChainStore, include the following lines instead -\n\n\n```ruby\npod 'InstagramKit'\npod 'InstagramKit/UICKeyChainStore'\n```\nInstagramKit uses [UICKeyChainStore](https://github.com/kishikawakatsumi/UICKeyChainStore) as an optional sub-dependency for Keychain access. \nIf you opt to use the optional pod, InstagramKit resumes your authenticated sessions across App launches, without needing any additional code.\n\n\n## Instagram Developer Registration\nHead over to http://instagram.com/developer/clients/manage/ to register your app with Instagram and set the right credentials for ```InstagramAppClientId``` and ```InstagramAppRedirectURL``` in your App's Info.plist file. \n\n```InstagramAppClientId``` is your App's Client Id and ```InstagramAppRedirectURL```, the redirect URI which is obtained on registering your App on Instagram's Developer Dashboard.\nThe redirect URI specifies where Instagram should redirect users after they have chosen whether or not to authenticate your application. \n\n## Instagram Platform Updates\nInstagram frequently updates its APIs and deprecates endpoints that are in use. \nIf you see a 400 or other strange errors from the server response, please check on Instagram's API changelog and create an issue with your findings. \nhttps://www.instagram.com/developer/changelog/\n\n\n## Usage\n\n### Authentication\n\nFor each API call, you will need an Access Token and specific scope permissions. To get the Access Token, the user needs to authenticate your app to access his Instagram account with the specified permissions.\n\nTo do so, redirect the user to ```https://instagram.com/oauth/authorize/?client_id=[Client ID]\u0026redirect_uri=[Redirect URI]\u0026response_type=token``` \nor allow InstagramEngine's helper method do the hard work for you - \n\n```Objective-C\nNSURL *authURL = [[InstagramEngine sharedEngine] authorizationURL];\n[self.webView loadRequest:[NSURLRequest requestWithURL:authURL]];\n```\n\n### Scopes\nAll apps have basic read access by default, but if you plan on asking for extended access such as liking, commenting, or managing friendships, you need to specify these scopes in your authorization request using the InstagramKitScope enum. \n\n_Note that in order to use these extended permissions, first you need to submit your app for review to Instagram._\n\n_For your app to POST or DELETE likes, comments or follows, you must apply to Instagram here : https://www.facebook.com/help/instagram/contact/185819881608116#_\n\n```Objective-C\n// Set scope depending on permissions your App has been granted from Instagram\n// InstagramKitLoginScopeBasic is included by default.\n\nInstagramKitLoginScope scope = InstagramKitLoginScopeRelationships | InstagramKitLoginScopeComments | InstagramKitLoginScopeLikes; \n\nNSURL *authURL = [[InstagramEngine sharedEngine] authorizationURLForScope:scope];\n[self.webView loadRequest:[NSURLRequest requestWithURL:authURL]];\n```\n\nOnce the user grants your app permission, they will be redirected to a url in the form of something like ```http://localhost/#access_token=[access_token]``` and ```[access_token]``` will be split by a period like ```[userID].[rest of access token]```. \nInstagramEngine includes a helper method to validate this token.\n\n##### UIWebView\n```Objective-C\n\n- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType\n{\nNSError *error;\nif ([[InstagramEngine sharedEngine] receivedValidAccessTokenFromURL:request.URL error:\u0026error]) {\n// success!\n...\n}\nreturn YES;\n}\n```\n\n##### WKWebView\n```Objective-C\n\n- (void)webView:(WKWebView *)webView decidePolicyForNavigationAction:(nonnull WKNavigationAction *)navigationAction decisionHandler:(nonnull void (^)(WKNavigationActionPolicy))decisionHandler\n{   \nNSError *error;\nif ([[InstagramEngine sharedEngine] receivedValidAccessTokenFromURL:navigationAction.request.URL error:\u0026error]) {\n// success!\n...\n}    \ndecisionHandler(WKNavigationActionPolicyAllow);\n}\n\n```\n\n### Authenticated Requests\n\nOnce you're authenticated and InstagramKit has been provided an `accessToken`, it will automatically persist it until you call `-logout` on InstagramEngine. An authenticated call looks no different:\n\n```Objective-C\nInstagramEngine *engine = [InstagramEngine sharedEngine];\n[engine getSelfRecentMediaWithSuccess:^(NSArray *media, InstagramPaginationInfo *paginationInfo) {\n// media is an array of InstagramMedia objects\n...\n} failure:^(NSError *error, NSInteger statusCode) {\n...\n}];\n```\n\n### Pagination \nThe `InstagramPaginationInfo` object has everything it needs to make your next pagination call. \n\nIf you need to make fetch a paginated feed of results, use the variation of the method which accepts `count` and `maxId` as parameters.\nFor instance, use `getMediaForUser:count:maxId:withSuccess:failure:` passing the next maxID to the `maxId` parameter each time, obtained from `paginationInfo.nextMaxId` of the newest paginationInfo object.\n\n```Objective-C\n[engine getMediaForUser:user.Id \ncount:15 \nmaxId:self.currentPaginationInfo.nextMaxId \nwithSuccess:^(NSArray *media, InstagramPaginationInfo *paginationInfo) \n{\nif (paginationInfo) {\nself.currentPaginationInfo = paginationInfo;\n}\n...\n} \nfailure:^(NSError *error) \n{\n...\n}];\n```\n\n_The first request will go with `maxId` as nil._\n\n_Each endpoint in the Instagram API that supports pagination, usually supports a count parameter.\nYou can use this method and pass a count parameter to each paginated request.\nYou can also use it in cases where you do not need pagination, but need to specify a feed count to the first request._\n\n\nRead in detail about more ways of implementing Pagination for your requests effortlessly in the [Pagination Wiki](https://github.com/shyambhat/InstagramKit/wiki/Pagination).\n\n\n## Contributions?\n\nGlad you asked. Check out the [open Issues](https://github.com/shyambhat/InstagramKit/issues?state=open) and jump right in.\n\n## Questions?\nThe [Instagram API Documentation](http://instagram.com/developer/endpoints/) is your definitive source of information in case something goes wrong. Please make sure you've read up the documentation before posting issues.\n\n## Author\n\nShyam Bhat, shyambhat@me.com\nTwitter: [@bhatthead](https://twitter.com/bhatthead) \n\n## License\n\nInstagramKit is available under the MIT license. See the LICENSE file for more info.\n\n==================\n\nInstagramKit uses the public Instagram API and is not affiliated with either Instagram or Facebook.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshyambhat%2FInstagramKit","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fshyambhat%2FInstagramKit","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshyambhat%2FInstagramKit/lists"}