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
A Swift client for the OpenAI API.

OpenAI A Swift client for the OpenAI API. Requirements Swift 5.3+ An OpenAI API Key Example Usage Completions import OpenAI

Mattt 161 Dec 26, 2022
Fetch Multiple Rest API using Swift 5.5 Async Await with Task, TaskGroup, Continuation API

Source code for Tutorial on experimenting with Swift Async Await to fetch multiple REST API endpoints and eliminate Pyramid of Doom callback hell to improve code readability and maintanability

Alfian Losari 14 Dec 7, 2022
Google Directions API helper for iOS, written in Swift

PXGoogleDirections Google Directions API SDK for iOS, entirely written in Swift. ?? Features Supports all features from the Google Directions API as o

Romain L 268 Aug 18, 2022
Swift client for Kubernetes

Table of contents Overview Compatibility Matrix Examples Usage Creating a client Configuring a client Client authentication Client DSL Advanced usage

Swiftkube 94 Dec 14, 2022
A (really) native and powerful macOS Telegram client built using SwiftUI, optimized for moderating large communities and personal use.

Moc A (really) native and powerful macOS Telegram client, optimized for moderating large communities and personal use. This client is currently in dev

GGorAA 84 Jan 2, 2023
Swift implementation of Github REST API v3

GitHubAPI Swift implementation of GitHub REST api v3. Library support Swift 4.2. Work is in progress. Currently supported: Issues API. Activity API(Fe

Serhii Londar 77 Jan 7, 2023
Swift Reddit API Wrapper

reddift reddift is Swift Reddit API Wrapper framework, and includes a browser is developed using the framework. Supports OAuth2(is not supported on tv

sonson 236 Dec 28, 2022
Swift Bot with Vapor for Telegram Bot Api

Telegram Vapor Bot Please support Swift Telegram Vapor Bot Lib development by giving a ⭐️ Telegram Bot based on Swift Vapor. Swift Server Side Communi

OleG. 104 Jan 6, 2023
Swift library for the Twitter API v1 and v2

Swift library for the Twitter API v1 and v2

mironal 96 Dec 30, 2022
Backport of iOS 15 formatting api

This is a back-port of the .formatted API in Foundation that was introduced at WWDC '21 for iOS 15, macOS 12.0, tvOS 15.0, and watchOS 8.0.

Simon Salomons 9 Jul 22, 2022
Unofficial iOS/macOS SDK for the Notion API.

NotionClient: a Notion SDK for iOS & macOS Unofficial Notion API SDK for iOS & macOS. This is an alpha version and still work in progress. TODO Featur

David De Bels 15 Aug 4, 2022
Swifter - A Twitter framework for iOS & OS X written in Swift

Getting Started Installation If you're using Xcode 6 and above, Swifter can be installed by simply dragging the Swifter Xcode project into your own pr

Matt Donnelly 2.4k Dec 26, 2022
Telegram Bot Framework written in Swift 5.1 with SwiftNIO network framework

Telegrammer is open-source framework for Telegram Bots developers. It was built on top of Apple/SwiftNIO

Pataridze Givi 279 Jan 4, 2023
👤 Framework to Generate Random Users - An Unofficial Swift SDK for randomuser.me

RandomUserSwift is an easy to use Swift framework that provides the ability to generate random users and their accompanying data for your Swift applic

Wilson Ding 95 Sep 9, 2022
SDK for creating Telegram Bots in Swift.

Chat • Changelog • Prerequisites • Getting started • Creating a new bot • Generating Xcode project • API overview • Debugging notes • Examples • Docum

Rapier 349 Dec 20, 2022
Solana + RxSolana This is a open source library on pure swift for Solana protocol

The objective is to create a cross platform, fully functional, highly tested and less depencies as posible. The project is still at initial stage. Lots of changes chan happen to the exposed api.

Arturo Jamaica 138 Dec 15, 2022
QuoteKit is a Swift framework to use the free APIs provided by Quotable created by Luke Peavey.

QuoteKit The QuoteKit is a Swift framework to use the free APIs provided by Quotable created by Luke Peavey.

Rudrank Riyam 17 Jun 23, 2022
Instagram API client written in Swift

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

Ander Goig 579 Dec 31, 2022
Instagram clone, the main focus of the app is the seamless swipe between views that we see on instagram

InstaSwipe Instagram clone, the main focus of the app is the seamless swipe betw

Stavros Pachoundakis 1 Dec 15, 2022
Swift iPhone and iPad Client for Polls API, using Hyperdrive API client

Polls Client This is a Swift iPhone and iPad client for the Polls API - a simple application allowing users to view polls and vote in them. Polls is a

Apiary 34 Jul 15, 2022