🖼 A minimal R client for interacting with Instagram’s public API.
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
## get your instagram data
me <- ig_users_self()
## view data
ig_as_tbl(me)
#> $ meta
#> $ code: 200
#> $ data
#> $ class: list
#> $ dims: 8
#> # A tibble: 1 x 7
#> id username profile_picture full_name bio website is_business
#> <chr> <chr> <chr> <chr> <chr> <chr> <lgl>
#> 1 17517… mike_way… https://scontent.c… Mike Kea… "" "" FALSE
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
To send requests to additional endpoints, supply the path and any relevant query parameters to either ig_api_get()
or ig_api_post()
.
## make custom request to locations/search endpoint
ig_locs <- ig_api_get("locations/search", lat = 48.858844, lng = 2.294351)
## view data
ig_as_tbl(ig_locs)
#> $ meta
#> $ code: 200
#> $ data
#> $ class: data.frame
#> $ dims: 20 obs x 4 vars
#> # A tibble: 20 x 4
#> id name latitude longitude
#> * <chr> <chr> <dbl> <dbl>
#> 1 2593354 Tour Eiffel 48.9 2.29
#> 2 104259689917… Effile Tower Paris 48.9 2.30
#> 3 6889842 Paris, France 48.9 2.35
#> 4 6889842 Paris, France 48.9 2.35
#> 5 767158323476… Eiffel Tower, Paris 48.9 2.30
#> 6 389164438201… Tour Eiffel France. 48.9 2.29
#> 7 213790743 58 Tour Eiffel 48.9 2.29
#> 8 151174985 Avenue des Champs-Élysées 48.9 2.30
#> 9 372828359 Ile-de-France, France 48.7 2.71
#> 10 117355320610… Berges de Seine 48.9 2.29
#> 11 299133962 Omaha Beach France 48.9 2.29
#> 12 32251308 Champs Elysees Paris 48.9 2.30
#> 13 791265207706… Torre Eiffel 48.9 2.30
#> 14 191378744556… Torre Eiffel, Paris 48.9 2.32
#> 15 299202480461… Le Jules Verné Michelin Paris 48.9 2.29
#> 16 521850351502… Torre eiffel 48.9 2.30
#> 17 467705676894… Le Jules Verne Par Alain Ducasse, Tou… 48.9 2.30
#> 18 432536411 Dinner At 58 Tour Eiffel Tower, Paris… 48.9 2.29
#> 19 256703907 Boat Ride Down The Seine River 48.9 2.29
#> 20 375269519489… Paris -20.2 -70.2
1NOTE: All keys provided in examples are fake but are otherwise designed to appear similar to the actual keys assigned by Instagram.