Newish to R and I have enjoyed wrangling with problems using documentation but just stuck on this one.
I'm using the httr package and want to send a GET request (or series of requests) to the Open Corporates API based on 150 search terms for Company Officers and receive the results in a single df as the ultimate output.
I understand I would construct a single search term request like this:
#load packages library(httr) library(jsonlite) library(tidyverse) #environment object of base url url <- "https://api.opencorporates.com/v0.4/officers/search" #simple get request test <- GET(url, query=list(q = "Officer Name", "inactive" = FALSE, "jurisdiction_code"="gb"))
Where the following are query parameters or "facets" in the OC API documentation for "GET officers/search":
q= search string
inactive=FALSE = excludes inactive officers
jurisdiction_code=gb= limits search to GB jurisdiction
How might I construct the request so that it would repeat the same process for 150 search terms (the rows of a df or as a list) and output the results in a single df?
I'm assuming the q search term parameter has a character string limit so I need an argument that will send the contents of each row to the q parameter and execute multiple requests and then a second argument to append the results to a single output table.
Grateful for any pointers to the appropriate packages and functions to achieve this
(I'm planning to unwrap the response results with the rawToChar and fromJSON functions.)