Here is how you can send query, replace the api_key with your own below.
# Loading the right libraries
library(httr)
library(jsonlite)
# Parameters list
params = list(
`api_key` = 'XXXXXX',
`q` = "covid",
`gl` = "fr",
`hl` = "fr",
`num` = 20,
`google_domain` = 'google.fr'
)
# q : the search query
# gl : 2 letter country code
# hl : language code
# num : number of result asked
# ask for the data
res <- httr::GET(url = 'https://api.valueserp.com/search', query = params)
# translate to string
res_text <- httr::content(res, "text")
# translate to a more readable format
res_json <- jsonlite::fromJSON(res_text, flatten = TRUE)
You can inspect the result by running this command line
View(res_json)
To make it easier for you, I have created a function that you can copy and paste, just replace the api_key with your own below.
ā ļø By default, VALUE SERP will separate all SERP features. Meaning 'organic result' will exclude the video carousel for example. If you would like all of them flattened into the organic_results array, then you could use āflatten_results=trueā. The flattened āpositionā property will include every SERP features
ā ļø Developer credentials (such as passwords, keys and client IDs) should be kept confidential. ā ļø