Package 'instaR'

Title: Access to Instagram API via R
Description: Provides an interface to the Instagram API <https://instagram.com/ developer/>, which allows R users to download public pictures filtered by hashtag, popularity, user or location, and to access public users' profile data.
Authors: Pablo Barbera [aut, cre], Tiago Dantas [ctb], Jonne Guyt [ctb]
Maintainer: Pablo Barbera <[email protected]>
License: GPL-2
Version: 0.2.5
Built: 2024-11-23 02:46:04 UTC
Source: https://github.com/pablobarbera/instar

Help Index


Returns up to 150 comments on an instagram post

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 Instagram 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)

Get the list of users this user is followed by.

Description

getFollowers retrieves the list of users that follow a given user, as well as basic information about all of them.

Usage

getFollowers(username, token, userid = NULL, verbose = TRUE)

Arguments

username

String, screen name of user.

token

An OAuth token created with instaOAuth.

userid

Numeric ID of user.

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 Instagram 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")
 mccain <- getFollowers( username="senjohnmccain", token=my_oauth )

## End(Not run)

Get the list of users a user follows.

Description

getFollows retrieves the list of users that a given user follows, as well as basic information about all of them.

Usage

getFollows(username, token, userid = NULL, verbose = TRUE)

Arguments

username

String, screen name of user.

token

An OAuth token created with instaOAuth.

userid

Numeric ID of user.

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 Instagram 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 users that @senjohnmccain follows
 load("my_oauth")
 mccain <- getFollows( username="senjohnmccain", token=my_oauth )

## End(Not run)

Get the list of users who liked a photo.

Description

getLikes retrieves the list of users who liked a photo.

Usage

getLikes(id, token, verbose = TRUE)

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 Instagram 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)

Tiago Dantas [email protected]

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)

Get basic information about a location using a location ID

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)

Returns 24 popular instagram posts information

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.

Details

IMPORTANT: After June 1st, 2016 only applications that have passed permission review by Instagram 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)

Jonne Guyt [email protected]

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)

Get number of times a tag has been used

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

tag

Hashtag used to filter media.

token

An OAuth token created with instaOAuth.

Author(s)

Pablo Barbera [email protected]

Examples

## Not run: 
## See examples for instaOAuth to know how token was created.
## Capturing information about #nofilter
 load("my_oauth")
 getTagCount( tag="nofilter", token=my_oauth,)

## End(Not run)

Get basic information about a user

Description

getUser retrieves public information about Instagram user

Usage

getUser(username, token, userid = NULL)

Arguments

username

String, screen name of user.

token

An OAuth token created with instaOAuth.

userid

Numeric ID of user.

Details

IMPORTANT: After June 1st, 2016 only applications that have passed permission review by Instagram 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.
## Capturing information about @barackobama
 load("my_oauth")
 obama <- getUser( username="barackobama", token=my_oauth,)

## End(Not run)

Extract recent media published by a user.

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 Instagram will be allowed to access data for users other than the authenticated user. See https://www.instagram.com/developer/review/ for more information.

Usage

getUserMedia(username, token, n = 30, folder = NULL, userid = NULL,
  verbose = TRUE)

Arguments

username

String, screen name of user.

token

An OAuth token created with instaOAuth.

n

Maximum number of media to return. Currently it is only possible to download the 20 most recent pictures or videos on the authenticated user's profile, unless Instagram has approved the application.

folder

If different than NULL, will download all pictures to this folder.

userid

Numeric ID of user.

verbose

If TRUE (default), outputs details about progress of function on the console.

Author(s)

Pablo Barbera [email protected]

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)

Create OAuth token to Intagram R session

Description

instaOAuth creates an OAuth access token that enables R to make authenticated calls to the Instagram 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 obtain 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")
 load("my_oauth")
 obama <- searchInstagram(tag="obama", token=my_oauth)

## End(Not run)

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 Instagram will be allowed to access this API endpoint. See https://www.instagram.com/developer/review/ for more information.

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)