Skip to content

Instantly share code, notes, and snippets.

@hadley
Created July 3, 2012 18:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hadley/3041520 to your computer and use it in GitHub Desktop.
Save hadley/3041520 to your computer and use it in GitHub Desktop.
library(httr)
library(plyr)
# stackexchange(ids = 16632)
stackexchange <- function(page = NULL, pagesize = NULL, fromdate = NULL, todate = NULL, order = NULL, min = NULL, max = NULL, sort = NULL, ids,
url = "https://api.stackexchange.com/2.0/users/")
{
query <- compact(list(page = page, pagesize = pagesize, fromdate = fromdate,
todate = todate, order = order, min = min, max = max, sort = sort,
site = "stackoverflow"))
res <- GET(paste0(url, ids), query = query)
json <- parsed_content(res)
lapply(json$items, "[",
c("user_id", "display_name", "reputation", "badge_counts"))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment