Using httr package how can I send multiple GET requests to an API based on a list of 150 search terms in rows?

Hi there,
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

#environment object of base url
url <- ""

#simple get request
test  <- GET(url, query=list(q = "Officer Name",
                           "inactive" = FALSE,

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 :slight_smile:

(I'm planning to unwrap the response results with the rawToChar and fromJSON functions.)

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.