How to Make HTTP request using httr package in R Language Last Updated : 04 Jun, 2024 Summarize Comments Improve Suggest changes Share Like Article Like Report In this article, we will learn how to make an HTTP request using the GET method in R Programming Language with httr library. We will be covering basic steps to get you started by making HTTP requests and scrapping all the data from a site in a simple way. You can also use it to scrape data from any website and use it to access API and much more. HTTP requests might be complicated but R language syntax makes it much easier in comparison with other languages. Installationhttr library is used to make http requests in R language as it provides a wrapper for the curl package. Syntax to install httr package: install.packages("httr") Making a simple HTTP requestNow we have httr package installed so we need to import it to make our HTTP request. library(httr) will import httr package. Now to make an HTTP request we will be using GET() of httr package and pass a URL, the GET() will return raw data so we will store it in a variable and then print it using print(). Note: You need not use install.packages() if you have already installed the package once. R # installing packages install.packages("httr") # importing packages library(httr) # GET() method will store the raw data # in response variable response < - GET("https://geeksforgeeks.org") # printing response/data print(response) Output: You might have noticed this output is not exact URL data that's because it is raw data. Convert raw data to char formatTo convert raw data in char format we need to use rawToChar() and pass variable_name$content in it just like we did in this example. R # installing packages install.packages("httr") # importing packages library(httr) # GET() method will store the raw # data in r variable r < - GET("https://geeksforgeeks.org") # rawToChar() will convert raw data # to char and store in response variable response < - rawToChar(r$content) # print response print(response) Output: Comment More infoAdvertise with us Next Article How to Install jsonlite Package in R? V vinamrayadav Follow Improve Article Tags : R Language Geeks Premier League Geeks-Premier-League-2022 Similar Reads How to make an HTTP GET request manually with netcat? Netcat,also known as "nc", is a powerful Unix-networking utility that enables users to interact with network services through a command-line interface (CLI). It uses both TCP and UDP network protocols for communication and is designed to be a reliable back-end tool to instantly provide network conne 6 min read Create An Interactive Web App Using Shiny Package In R Perhaps a quick introduction to what Shiny is would be helpful before moving on. Creating interactive web applications with R Programming Language is simple thanks to the Shiny package. Shiny's advantage is that it enables you to extend your R code to the web, which essentially increases the usabili 4 min read How to Install jsonlite Package in R? The jsonlite package in R is a highly versatile and robust tool designed for handling JSON (JavaScript Object Notation) data. JSON is a lightweight data-interchange format that is easy for humans to read and write, and easy for machines to parse and generate. The jsonlite package simplifies the proc 3 min read Get news from newsapi using R language In this article, we will learn how to create a Rscript to read the latest news. We will be using news API to get news and extract it using httr package in R Programming Language. Modules Needed: install.packages("httr") install.packages("jsonlite") Get news API: To get your API key visit newsapi.org 1 min read Convert curl Code into R via the RCurl Package? In data analysis and web scraping, the curl command is widely used for making HTTP requests, particularly for interacting with APIs, downloading data, or submitting forms. The R programming language offers the RCurl package, which provides functionalities to convert and execute curl commands within 6 min read Building REST API using R Programming REST(Representational state transfer) API is an architectural style that includes specific constraints for building APIs to ensure that they are consistent, efficient, and scalable. REST API is a collection of syntax and constraints which are used in the development and operation of web services tha 3 min read Like