R can fetch and interact with web APIs using packages like httr
or jsonlite
. This is super useful for getting data from online sources.
install.packages("httr")
and install.packages("jsonlite")
.
GET()
- Sends a GET request to an API endpointcontent()
- Extracts content from the responsefromJSON()
- Converts JSON text to an R objectPOST()
- Sends data to an API endpointstatus_code()
- Gets the HTTP status code