Skip to content

Instantly share code, notes, and snippets.

@aojea
Created August 26, 2014 10:36
Show Gist options
  • Save aojea/36e5de369f72778c1a8d to your computer and use it in GitHub Desktop.
Save aojea/36e5de369f72778c1a8d to your computer and use it in GitHub Desktop.
R functions to use the RIPEStat API
library("jsonlite")
# Function that returns the country code of a IP address
geoloc<-function(x){
return(fromJSON(paste0("https://stat.ripe.net/data/geoloc/data.json?resource=",x))$data$locations$country)
}
# Function that returns the ASN of a IP address
getasn<-function(x){
return(fromJSON(paste0("https://stat.ripe.net/data/network-info/data.json?resource=",x))$data$asns[1])
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment