Instagram API client written in Swift

Overview

SwiftInstagram Logo

Platforms Swift 4.0 Travis Codebeat Documentation License

CocoaPods compatible Carthage compatible Swift Package Manager


SwiftInstagram is a wrapper for the Instagram API written in Swift. It allows you to authenticate users and request data from Instagram effortlessly.

Features

  • Effortless and straightforward use.
  • Up-to-date with the latest Instagram API features.
  • Secure access token storing, thanks to keychain-swift.
  • Client-Side authentication.
  • 100% documented code.
  • Use of Swift 4 Decodable.
  • Up-to-date with the latest Apple technologies (Swift 4, Xcode 9, etc).

Upcoming features

Requirements

  • iOS 9.0+
  • Xcode 9.0+

Usage

I've prepared a wiki page where you can find tons of useful things.

Contributing

If you have feature requests or bug reports, feel free to help out by sending pull requests or by creating new issues. Please take a moment to review the CONTRIBUTING guidelines.

Credits

SwiftInstagram is brought to you by Ander Goig and contributors to the project. If you're using SwiftInstagram in your project, attribution would be very appreciated.

Companion libraries

SwiftInstagram uses keychain-swift by @evgenyneu to safely store the access token retrieved by the authentication process.

License

SwiftInstagram is released under the MIT license. See LICENSE for details.

Author

Ander Goig, [email protected]

https://github.com/AnderGoig/SwiftInstagram

Comments
  • Instagram authentication not working properly

    Instagram authentication not working properly

    Checklist

    Expected Behavior

    When I am prompted the instagram login screen, and I push 'Log in', the success or failure callback should be triggered.

    Actual Behavior

    When I am prompted the instagram login screen, and i push 'Log in', I am routed to a Instagram branded, 'page not found' page. None of the callbacks are called and I don't receive an access token.

    I inspected the traffic and it looks like the following POST call is resulting in a 404, regardless whether the username or password is correct: https://www.instagram.com/accounts/login/?force_classic_login=&next=/oauth/authorize%3Fclient_id%CLIENT_ID%26redirect_uri%3DREDIRECT_URI%26response_type%3Dtoken%26scope%3Dbasic

    I think the issue may be around this.

    Steps to Reproduce the Problem

    1. Ensure user is logged out. Just call this method to bring up the instagram login screen.
    Instagram.shared.login(from: self.navigationController!, success: {
                        print("Success")
                    }, failure: { error in
                        print(error.localizedDescription)
                    })
    

    Specifications

    • iOS Version: 11.2
    • Device(s): iPhone 7
    opened by elementsrtyte 6
  • Most endpoints have been immediately deprecated

    Most endpoints have been immediately deprecated

    Checklist

    Expected Behavior

    Receiving data from Instagram

    Actual Behavior

    Not receiving data, most of the endpoints have been deprecated. https://www.instagram.com/developer/changelog/

    Steps to Reproduce the Problem

    Use .userFollowers request

    Specifications

    • iOS Version: any
    • Device(s): any
    opened by havebeenfitz 5
  • Cannot login

    Cannot login

    Checklist

    Expected Behavior

    Should login succesfully.

    Actual Behavior

    Not login succesfully. Received an Error in webview. screen shot 2018-05-25 at 17 54 11 (see attached screenshot)

    Steps to Reproduce the Problem

    1. Added pod to Podfile and install
    2. Added to Info.plist keys from 'SwiftInstagram authentication' section
    3. Added sample code for login

    Specifications

    • iOS Version: 11.0
    • Device(s): Simulator / iPhone 6
    opened by thedoubler 4
  • SwiftInstagram.InstagramError error 0

    SwiftInstagram.InstagramError error 0

    As of today, I keep getting this error message when I call recentMedia(fromUser: "self".... This error was non-existent up until today. Here's what gets printed in the console:

    The operation couldn’t be completed. (SwiftInstagram.InstagramError error 0.)

    I am still able to login and logout. This error only occurs when I call api.recentMedia(fromUser: "self"....

    Another thing to note is that when I enter this link in my web browser "https://api.instagram.com/v1/users/self/media/recent?access_token=MYTOKEN", I am able to get a response from Instagram, which proves it is not a problem on Instagrams end. It is possible that they have slightly changed the response as of today, which might be causing problems with this api, but I am not too sure about that.

    UPDATE: After digging in further, I have located where the error occurs. Still not sure why it throws an error. After running line 139 (refer to the image below), the app then catches an error and then runs line 156. Please help me fix this problem, thanks!

    screen shot 2018-04-06 at 1 18 31 am Priority: Medium Status: In Progress Type: Bug 
    opened by ryandailey100 4
  • compile error: success and failure are inaccessible due to 'private' protection level

    compile error: success and failure are inaccessible due to 'private' protection level

    Checklist

    Expected Behavior

    There should be no compile errors.

    Actual Behavior

    Compile errors in InstagramLoginViewController: 'success' is inaccessible due to 'private' protection level 'failure' is inaccessible due to 'private' protection level

    Steps to Reproduce the Problem

    1. pod install 'SwiftInstagram', '~> 1.0.5'
    2. build project
    3. there are compile errors mentioned above.

    Specifications

    • xCode Version: Version 9.0.1 (9A1004)
    • macOS Version: Sierra 10.12.6 (16G29)
    • iOS Version: Generic iOS Device
    • Device(s):
    Priority: Medium Status: Completed Type: Bug 
    opened by ghost 4
  • authentication not working

    authentication not working

    let igLoginManager = Instagram.shared igLoginManager.login(from: vc, success: { // not callback (success) }) { (error) in // not callback (error) }

    I do not get any answers. Disable implicit OAuth: uncheck InstagramClientId: my details InstagramRedirectURI: my details

    I get successfully to my page and do not get any response. Please tell me what could be wrong

    opened by blajivskiy 3
  • Invalid Media ID

    Invalid Media ID

    Checklist

    Expected Behavior

    I should get Media data as Instagram Documentation like this Instagram media

    Actual Behavior

    I have already Authentication then get media data Auth -> Fetch Data (Media) but i got an error like this [invalidRequest] - invalid media id

    Steps to Reproduce the Problem

    1. Auth
    2. Fetch with this shortcode Ba6NSWUFLfj

    Specifications

    • iOS Version: iOS 100
    • Device(s): Simulator iPhone 8 Plus
    Status: Completed Type: Question 
    opened by black-lotus 3
  • createComment return error

    createComment return error

    Checklist

    Expected Behavior

    Add a comment to a media

    Actual Behavior

    Return error "Missing "text" attribute"

    Steps to Reproduce the Problem

    1. Login using the API with scope .comment .publicContent
    2. Call createComment

    Specifications

    • iOS Version: 11.2
    • Device(s): iPhone X
    Priority: High Status: Completed Type: Bug 
    opened by FrancescoZ 3
  • mediaList property gives only string instead of array value

    mediaList property gives only string instead of array value

    Checklist

    Expected Behavior

    I'm expecting to get URL array instead of one string value. In recentMedia(fromUser:success:failure:) method

    Actual Behavior

    It's gives only one string value it contains 20 recent media URLs

    Steps to Reproduce the Problem

    1. Authenticate
    2. Call recentMedia(fromUser:success:failure:) method
    3. In success block API gives [InstagramMedia] and its images property is not array value.
    Status: Completed Type: Question 
    opened by serhatsezer 3
  • Getting list of follows or followers by user ID

    Getting list of follows or followers by user ID

    Checklist

    Expected Behavior

    Is it possible to get list of followers or follows by userID not self only ? p.s : I'm still in sandbox mode

    Actual Behavior

    The actual is get list of my followers and follows

    Specifications

    • iOS Version: 11.2
    • Device(s): iphone 6s plus
    Status: Completed Type: Question 
    opened by TaoufikBouabid 3
  • Example Project does not log in successfully

    Example Project does not log in successfully

    Checklist

    Expected Behavior

    Clicking the login button, the example project logs in

    Actual Behavior

    After entering all my data into instagram, the view controller returned with an error message

    Steps to Reproduce the Problem

    1. Run example app InstagramLogin-Example
    2. Try to log in

    Specifications

    • iOS Version: iOS 11.4
    • Device(s): Simulator - iPhone 6s
    image
    opened by n13 2
  • Unable to make requests

    Unable to make requests

    Checklist

    Expected Behavior

    Being able to make any request after login. Can't initialize data in request() -> urlSession.dataTask

    Actual Behavior

    Error when invoking api.userFollows(...): Thread 1: Fatal error: Unexpectedly found nil while unwrapping an Optional value Error when invoking getInstagramData()=api.user(...): decoding(message: "The data couldn’t be read because it is missing.") The operation couldn’t be completed. (SwiftInstagram.InstagramError error 0.)

    Steps to Reproduce the Problem

    1. Login button action

    ` static func loginInstagram(from: UINavigationController, completion: @escaping (Error?) -> Void){ let api = Instagram.shared

        // Login
        //print("Instragam Login")
        api.login(from: from, withScopes: [.basic, .publicContent], success: {
            completion(nil)
        }, failure: { error in
            print(error.localizedDescription)
        })
    

    } ` 2. Get data button action

    ` static func getInstagramData() { let api = Instagram.shared

        api.user("self", success: { userList in
            print(SwiftyJSON.JSON(userList))
        }, failure: { error in
            print(error)
            print(error.localizedDescription)
        })
    

    } `

    However this works: Alamofire.request("https://api.instagram.com/v1/users/self?access_token="+api.retrieveAccessToken()!).responseJSON(completionHandler: { response in if let result = response.result.value { let swiftyJSON = JSON(result) print(swiftyJSON) }

    Specifications

    • iOS Version:latest
    • Device(s):all iOS devices
    opened by blackwiz4rd 0
  • Added response type

    Added response type

    Checklist

    Proposed Changes

    You need to update the first screenshot: https://github.com/AnderGoig/SwiftInstagram/wiki/Authentication. Add "InstagramResponseType"

    opened by ArmyXomuiL 0
  • Is this api suitable for developing MacOS app ?

    Is this api suitable for developing MacOS app ?

    Checklist

    Expected Behavior

    This Api can be used on Cocoa development

    Actual Behavior

    None

    Steps to Reproduce the Problem

    1. As the title

    Specifications

    • iOS Version:
    • Device(s):
    opened by davidhsu1115 1
  • error 3 bad request error.

    error 3 bad request error.

    Checklist

    Expected Behavior

    authentication

    Actual Behavior

    bad request error 3 with authentication

    Steps to Reproduce the Problem

    1.I will use client side only there is no backend. 2.What should I wrote instagram API's redirect url? Because there is no website or backend. 3.I wrote incorrect url because of this.

    Specifications

    • iOS Version:11.4
    • Device(s):6s
    opened by yildirimatcioglu 1
  • Getting nil while calling the login method.

    Getting nil while calling the login method.

    Checklist

    Expected Behavior

    1. Should not crash at the starting only when calling the login method.

    Actual Behavior

    1. Getting crash on calling this - api.login(from: navigationController!, success: { // Do your stuff here ... }, failure: { error in print(error.localizedDescription) }) Error - Thread 1: EXC_BAD_INSTRUCTION (code=EXC_I386_INVOP, subcode=0x0)

    Steps to Reproduce the Problem

    1. Just call this :- let api = Instagram.shared

      // Login api.login(from: navigationController!, success: { // Do your stuff here ... }, failure: { error in print(error.localizedDescription) })

    Specifications

    • iOS Version: 11.3
    • Device(s): iPhone6+
    opened by ambujshukla-cdn 2
Releases(v1.1.2)
Owner
Ander Goig
👨🏻‍🎓Computer Science graduate 👨🏻‍💻 iOS Developer 🧡 Swift lover 🍎 Apple fanboy
Ander Goig
Wanikani-swift - Unofficial Swift client for the WaniKani API

WaniKani A Swift library and client for the WaniKani REST API. It currently supp

Aaron Sky 5 Oct 28, 2022
Unofficial GitHub API client in Swift

Github.swift ❤️ Support my apps ❤️ Push Hero - pure Swift native macOS application to test push notifications PastePal - Pasteboard, note and shortcut

Khoa 184 Nov 25, 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
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
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

Dalton Hinterscher 107 Nov 8, 2022
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

Eli Slade 2 Mar 15, 2022
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 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
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

Saeid 8 Apr 5, 2021
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

Satyam Ghodasara 163 Jul 26, 2022
Endless-Api-OP - A swift server for Endless

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

Underthestars-zhy 1 Jan 30, 2022
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

MBLA 6 Sep 23, 2022
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

Nicolas Seriot 1k Nov 30, 2022
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

Nathaniel Symer 213 Jul 8, 2022
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

Sachin Kesiraju 95 Jun 30, 2022
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
ObjectiveFlickr, a Flickr API framework for Objective-C

ObjectiveFlickr ObjectiveFlickr is a Flickr API framework designed for Mac and iPhone apps. OAuth Support ObjectiveFlickr now supports Flickr's new OA

Lukhnos Liu 714 Jan 9, 2023