Skip to content

Instantly share code, notes, and snippets.

@sckott
Last active August 29, 2015 14:07
Show Gist options
  • Save sckott/f1403260eb92f5dfa7e1 to your computer and use it in GitHub Desktop.
Save sckott/f1403260eb92f5dfa7e1 to your computer and use it in GitHub Desktop.
Querying bitly from R

Querying bitly from R

library('httr')
btoken <- '<token>' # go to https://bitly.com/a/oauth_apps and generate token
args <- list(query='obama', domain='nytimes.com', limit=2, access_token = btoken)
req <- GET("https://api-ssl.bitly.com/v3/search", query=args) 
content(req)
$status_code
[1] 200

$data
$data$results
$data$results[[1]]
$data$results[[1]]$domain
[1] "nytimes.com"

$data$results[[1]]$initial_epoch
[1] "1413326882000"

$data$results[[1]]$h2
[1] "U.S. & Politics"

$data$results[[1]]$h3
$data$results[[1]]$h3[[1]]
[1] "U.S. & Politics"

$data$results[[1]]$h3[[2]]
[1] "Times Minute"

$data$results[[1]]$h3[[3]]
[1] "Retro Report"

$data$results[[1]]$h3[[4]]
[1] "The Last Word"

$data$results[[1]]$h3[[5]]
[1] "By the Numbers"


.... cutoff
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment