Skip to content

Instantly share code, notes, and snippets.

@j450h1
Forked from jennybc/catfacts.R
Created October 2, 2016 00:41
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 j450h1/97c94da70c8e5d9738dd9e622a53f9b0 to your computer and use it in GitHub Desktop.
Save j450h1/97c94da70c8e5d9738dd9e622a53f9b0 to your computer and use it in GitHub Desktop.
Goofing around with the catfacts API
httr::GET("http://catfacts-api.appspot.com/api/facts",
          query = list(number = 5)) %>% 
  httr::content(as = "text", encoding = "UTF-8") %>% 
  jsonlite::fromJSON()
#> $facts
#> [1] "The catnip plant contains an oil called hepetalactone which does for cats what marijuana does to some people. Not all cats react to it those that do appear to enter a trancelike state. A positive reaction takes the form of the cat sniffing the catnip, then licking, biting, chewing it, rub & rolling on it repeatedly, purring, meowing & even leaping in the air."
#> [2] "A cat's appetite is the barometer of its health. Any cat that does not eat or drink for more than two days should be taken to a vet."                                                                                                                                                                                                                                     
#> [3] "Almost 10% of a cat's bones are in its tail, and the tail is used to maintain balance."                                                                                                                                                                                                                                                                                   
#> [4] "Tigers have been hunted for their skin, bones, and other body parts, used in traditional Chinese medicine."                                                                                                                                                                                                                                                               
#> [5] "Cat families usually play best in even numbers. Cats and kittens should be aquired in pairs whenever possible."                                                                                                                                                                                                                                                           
#> 
#> $success
#> [1] "true"
httr::GET("http://catfacts-api.appspot.com/api/facts",
query = list(number = 5)) %>%
httr::content(as = "text", encoding = "UTF-8") %>%
jsonlite::fromJSON()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment