Here is how you can send query, replace the api_key with your own below.
# Loading the right librarieslibrary(httr)library(jsonlite)# Parameters listparams =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 datares <- httr::GET(url ='https://api.valueserp.com/search', query = params)# translate to stringres_text <- httr::content(res, "text")# translate to a more readable formatres_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