Home / Cost tools / cURL converter / R
cURL to R converter
Paste a cURL command and get the same request in R, using httr. It converts in your browser; nothing you paste is sent anywhere.
Converted in your browser. Nothing you paste is stored or sent, so a command with your API key in it stays on your machine.
library(httr)
headers <- c(
"Authorization" = "Bearer YOUR_API_KEY"
)
response <- GET("https://api.scraper.example/v1/scrape?url=https%3A%2F%2Fshop.example.com%2Fproducts%3Fpage%3D2&render_js=true&country=us", add_headers(.headers = headers))
print(status_code(response))
cat(content(response, "text")) Install first: install.packages("httr")
Running the code
Install httr from CRAN and run it in R or RStudio. The headers go in add_headers, basic authentication in authenticate and a timeout in seconds in timeout.
Where httr differs from curl
httr returns any HTTP status as a response; use stop_for_status or check status_code before reading content, which the code prints as text.
What calls like this one cost
The example is a scraping API call with JavaScript rendering on and a country chosen. 100,000 of them a month cost from $49.00 on ScrapeBadger, and the same pages without rendering from $19.00 on BrowserCloud, the cheapest complete bills across 27 web scraping APIs this site prices from their own pages. What rendering adds on each API