Package Instar': R Topics Documented
Package Instar': R Topics Documented
URL https://github.com/pablobarbera/instaR
BugReports https://github.com/pablobarbera/instaR/issues
Depends R (>= 2.12.0), httr, jsonlite
License GPL-2
Collate 'getFollowers.R' 'getFollows.R' 'getUser.R' 'getUserMedia.R'
'instaOAuth.R' 'searchInstagram.R' 'utils.R' 'getTagCount.R'
'getComments.R' 'getLikes.R' 'getPopular.R' 'getLocation.R'
RoxygenNote 5.0.1
NeedsCompilation no
Repository CRAN
Date/Publication 2016-08-17 10:40:32
R topics documented:
getComments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
getFollowers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
getFollows . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
getLikes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
getLocation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
getPopular . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
getTagCount . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
getUser . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
1
2 getComments
getUserMedia . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
instaOAuth . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
searchInstagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
Index 13
Description
getComments retrieves up to 150 recent comments on an instagram post, including text, author and
date.
Usage
getComments(id, token, verbose = TRUE)
Arguments
id String, id of instagram post.
token An OAuth token created with instaOAuth.
verbose If TRUE (default), outputs details about progress of function on the console.
Details
IMPORTANT: After June 1st, 2016 only applications that have passed permission review by In-
stagram will be allowed to access data for users other than the authenticated user. See https:
//www.instagram.com/developer/review/ for more information.
Author(s)
Pablo Barbera <[email protected]>
Examples
## Not run:
## See examples for instaOAuth to know how token was created.
## Downloading list of followers of @senjohnmccain
load("my_oauth")
obama <- getUserMedia( username="barackobama", token=my_oauth )
comments <- getComments( obama$id[1], token=my_oauth )
## End(Not run)
getFollowers 3
Description
getFollowers retrieves the list of users that follow a given user, as well as basic information about
all of them.
Usage
Arguments
Details
IMPORTANT: After June 1st, 2016 only applications that have passed permission review by In-
stagram will be allowed to access data for users other than the authenticated user. See https:
//www.instagram.com/developer/review/ for more information.
Author(s)
Examples
## Not run:
## See examples for instaOAuth to know how token was created.
## Downloading list of followers of @senjohnmccain
load("my_oauth")
mccain <- getFollowers( username="senjohnmccain", token=my_oauth )
## End(Not run)
4 getFollows
Description
getFollows retrieves the list of users that a given user follows, as well as basic information about
all of them.
Usage
Arguments
Details
IMPORTANT: After June 1st, 2016 only applications that have passed permission review by In-
stagram will be allowed to access data for users other than the authenticated user. See https:
//www.instagram.com/developer/review/ for more information.
Author(s)
Examples
## Not run:
## See examples for instaOAuth to know how token was created.
## Downloading list of users that @senjohnmccain follows
load("my_oauth")
mccain <- getFollows( username="senjohnmccain", token=my_oauth )
## End(Not run)
getLikes 5
Description
Usage
Arguments
id Numeric ID of photo.
token An OAuth token created with instaOAuth.
verbose If TRUE (default), outputs details about progress of function on the console.
Details
IMPORTANT: After June 1st, 2016 only applications that have passed permission review by In-
stagram will be allowed to access data for users other than the authenticated user. See https:
//www.instagram.com/developer/review/ for more information.
Author(s)
Examples
## Not run:
## See examples for instaOAuth to know how token was created.
## Downloading list of users who liked @barackobama's most recent photo
load("my_oauth")
obama <- getUserMedia( username="barackobama", token=my_oauth, n=1)
likes <- getLikes(obama$id[1], token=my_oauth)
## End(Not run)
6 getPopular
Description
getLocation retrieves location information
Usage
getLocation(location_id, token)
Arguments
location_id numeric, location id.
token An OAuth token created with instaOAuth.
Author(s)
Jonne Guyt <[email protected]>
Examples
## Not run:
## See examples for instaOAuth to know how token was created.
## Capturing information about a location
load("my_oauth")
loc_id_info <- getLocation( location_id=423423, token=my_oauth)
## End(Not run)
Description
getPopular retrieves up to 24 popular instagram posts
Usage
getPopular(token, verbose = TRUE)
Arguments
token An OAuth token created with instaOAuth.
verbose If TRUE (default), outputs details about progress of function on the console.
getTagCount 7
Details
IMPORTANT: After June 1st, 2016 only applications that have passed permission review by In-
stagram will be allowed to access data for users other than the authenticated user. See https:
//www.instagram.com/developer/review/ for more information.
Author(s)
Examples
## Not run:
## See examples for instaOAuth to know how token was created.
## Downloading list of popular instagram posts
load("my_oauth")
popular_posts <- getPopular(token=my_oauth )
## End(Not run)
Description
getTagCount retrieves a count of the number of times a tag has been used in comments to a picture
or video.
Usage
getTagCount(tag, token)
Arguments
Author(s)
Description
Usage
Arguments
Details
IMPORTANT: After June 1st, 2016 only applications that have passed permission review by In-
stagram will be allowed to access data for users other than the authenticated user. See https:
//www.instagram.com/developer/review/ for more information.
Author(s)
Examples
## Not run:
## See examples for instaOAuth to know how token was created.
## Capturing information about @barackobama
load("my_oauth")
obama <- getUser( username="barackobama", token=my_oauth,)
## End(Not run)
getUserMedia 9
Description
getUserMedia retrieves public media from a given user and, optionally, downloads recent pictures
to a specified folder.
IMPORTANT: After June 1st, 2016 only applications that have passed permission review by In-
stagram will be allowed to access data for users other than the authenticated user. See https:
//www.instagram.com/developer/review/ for more information.
Usage
Arguments
Author(s)
Examples
## Not run:
## See examples for instaOAuth to know how token was created.
## Capturing information about 50 most recent pictures by @barackobama
load("my_oauth")
obama <- getUserMedia( username="barackobama", token=my_oauth, n=50, folder="barackobama")
## End(Not run)
10 instaOAuth
Description
instaOAuth creates an OAuth access token that enables R to make authenticated calls to the Insta-
gram API. The token can be saved as a file in disk to be re-used in future sessions. This function
relies on the httr package to create the OAuth token, and is a simplified version of one of its
examples.
Usage
instaOAuth(app_id, app_secret, scope = c("basic", "public_content"))
Arguments
app_id numeric, Client ID of application to be used to create OAUth token. Available
at http://instagram.com/developer
app_secret string, Client Secret of application to be used to create OAUth token. Available
at http://instagram.com/developer.
scope string, specifies scope of access to the authenticated user data. See http://
instagram.com/developer/authentication/#scope for available options.
Details
To obtan your app_id and app_secret, do the following steps. First, go to http://instagram.
com/developer/ and register your application with any name. Then, run the instaOAuth function
with your "Client ID" and "Client Secret" as arguments. It will return a URL, which you will need to
paste into the field "OAuth redirect_uri" in your application settings on Instagram. After changing
it, press Enter in R. A new browser window will open and sign the token. If everything works works
well, you will get a message that says you can return to R.
Author(s)
Pablo Barbera <[email protected]>
See Also
searchInstagram
Examples
## Not run:
## an example of an authenticated request after creating the OAuth token
## where app_id and app_secret are fictitious, and token is saved for
## future sessions
my_oauth <- instaOAuth(app_id="123456789", app_secret="1A2B3C4D")
save(my_oauth, file="my_oauth")
searchInstagram 11
load("my_oauth")
obama <- searchInstagram(tag="obama", token=my_oauth)
## End(Not run)
searchInstagram Search public media that mention a specific hashtag, or that were sent
from a given area
Description
searchInstagram retrieves public pictures and video whose caption mentions a given hashtag, or
that were sent within a given area, delimited by a set of coordinates and a radius. It returns a data
frame with information about each picture or video, and optionally will download all pictures to a
specific folder
Usage
searchInstagram(tag = NULL, token, n = 100, lat = NULL, lng = NULL,
distance = NULL, folder = NULL, mindate = NULL, maxdate = NULL,
verbose = TRUE, sleep = 0)
Arguments
tag Hashtag used to filter media. It is only possible for a single hashtag.
token An OAuth token created with instaOAuth.
n Maximum number of media to return.
lat Latitude of the center search coordinate
lng Longitude of the center search coordinate
distance Default is 1km (distance=1000), max distance is 5km.
folder If different than NULL, will download all pictures to this folder.
mindate Minimum date for search period
maxdate Maximum date for search period
verbose If TRUE (default), outputs details about progress of function on the console.
sleep Number of seconds between API calls (default is 0).
Details
It is only possible to apply one filter at a time: either search by hashtag OR search by coordinates.
The mindate and maxdata search parameters only work when searching by location, not when
searching by tag.
IMPORTANT: After June 1st, 2016 only applications that have passed permission review by Insta-
gram will be allowed to access this API endpoint. See https://www.instagram.com/developer/
review/ for more information.
12 searchInstagram
Author(s)
Pablo Barbera <[email protected]>
See Also
instaOAuth
Examples
## Not run:
## See examples for instaOAuth to know how token was created.
## Searching and downloading 100 public media that mention #obama
load("my_oauth")
obama <- searchInstagram( tag="obama", token=my_oauth, n=100, folder="obama")
## Searching and downloading pictures sent from Times Square with a minimum date
## of 2013-12-31 and a maximum date of 2014-01-01
tsq <- searchInstagram( lat=40.7577, lng=-73.9857, distance=500,
token=my_oauth, n=500, folder="timessquare",
mindate="2014-12-31", maxdate="2014-01-01")
## End(Not run)
Index
getComments, 2
getFollowers, 3
getFollows, 4
getLikes, 5
getLocation, 6
getPopular, 6
getTagCount, 7
getUser, 8
getUserMedia, 9
instaOAuth, 10, 12
searchInstagram, 10, 11
13