Skip to content

Instantly share code, notes, and snippets.

@leeper
Created February 19, 2014 20:25
Show Gist options
  • Save leeper/9100775 to your computer and use it in GitHub Desktop.
Save leeper/9100775 to your computer and use it in GitHub Desktop.
Get specified number of cat facts from the Cat Facts API (http://catfacts-api.appspot.com/)
library("RCurl")
library("RJSONIO")
catfacts <- function(number=1){
if(is.null(number) || is.na(as.numeric(number)) || number < 1)
stop("'number' must be a positive integer")
fromJSON(getURL(paste('http://catfacts-api.appspot.com/api/facts?number=', number, sep='')))$facts
}
# Some examples
catfacts()
catfacts(5)
# ASCII cat saying cat facts
library("cowsay")
say(catfacts(),'cat')
@lucasvieites
Copy link

Hi, the API seems to be unavailable. This is the error message:
"Python 2.5 is no longer available. Please refer to https://goo.gl/aESk5L for more information."
I can't find any info about the owner of the API so can't "complain" to them directly. I hope you have more info...
Cheers,
Lucas

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