🖼 A minimal R client for interacting with Instagram’s public API.

Installation

You can install {ig} from Github with:

Authorization

To become authorized to interact with Instagram’s API, users must first go here and create an Instagram app. Once you’ve created an app, copy the Client ID and Client Secret keys1 from the app’s page and pass them along to ig_create_token().

It’s not necessary to specify your token in each request (ig functions actually do that in the background for you), but if you’d like to view your access token, use ig_token().

The rest of the token process is automated for you (you don’t need to reference it again).

Endpoints

There are numerous API endpoints, but thanks to recent changes by Instagram, most users won’t get access to large amounts of public data (at least not without first going through a strict submission process). Here are some that should still work though:

users/self/media/recent

## get your media data
my_media <- ig_users_self_media_recent()

## view data
ig_as_tbl(my_media)
#>  $ pagination
#>    $ :
#>  $ meta
#>    $ code: 200
#>  $ data
#>    $ class: data.frame
#>    $ dims: 20 obs x 17 vars
#> # A tibble: 20 x 7
#>    id      created_time user_has_liked filter  type  link      attribution
#>  * <chr>   <chr>        <lgl>          <chr>   <chr> <chr>     <lgl>      
#>  1 185256… 1535062605   FALSE          Mayfair video https://… NA         
#>  2 180444… 1529326616   FALSE          Mayfair image https://… NA         
#>  3 179014… 1527621830   FALSE          Normal  caro… https://… NA         
#>  4 179013… 1527620656   FALSE          Aden    image https://… NA         
#>  5 178929… 1527520024   FALSE          Normal  caro… https://… NA         
#>  6 176788… 1524968858   FALSE          Normal  caro… https://… NA         
#>  7 176336… 1524428978   FALSE          Reyes   image https://… NA         
#>  8 175704… 1523676268   FALSE          Crema   image https://… NA         
#>  9 175306… 1523201331   FALSE          Normal  image https://… NA         
#> 10 174821… 1522623997   FALSE          X-Pro … image https://… NA         
#> 11 174766… 1522558145   FALSE          X-Pro … image https://… NA         
#> 12 174614… 1522376529   FALSE          Normal  image https://… NA         
#> 13 174610… 1522372473   FALSE          Crema   image https://… NA         
#> 14 174289… 1521989375   FALSE          Normal  caro… https://… NA         
#> 15 157920… 1502475629   FALSE          Hudson  image https://… NA         
#> 16 157561… 1502047616   FALSE          Normal  image https://… NA         
#> 17 156859… 1501210853   FALSE          Juno    image https://… NA         
#> 18 151477… 1494795791   FALSE          Sierra  video https://… NA         
#> 19 139544… 1480569623   FALSE          X-Pro … image https://… NA         
#> 20 134541… 1474605839   FALSE          Sierra  image https://… NA

Additional endpoints

To send requests to additional endpoints, supply the path and any relevant query parameters to either ig_api_get() or ig_api_post().

1NOTE: All keys provided in examples are fake but are otherwise designed to appear similar to the actual keys assigned by Instagram.