Access outbreak.info Research Library API

getResourcesResponse(
  queryString = NULL,
  size = 10,
  fetchAll = FALSE,
  fields = NULL,
  sort = NULL,
  facets = NULL,
  facet_size = 10,
  queryStub = "https://api.outbreak.info/resources/query?"
)

Arguments

size

(optional) number of records to return (default = 10)

fetchAll

(optional) Boolean whether to return all results for the query

fields

(optional) vector specifying which fields to return. Returns all by default

sort

(optional) field to sort by. Add `-` to sort in descending order

facets

(optional) field by which to aggregate (count) their frequency

facet_size

(optional) how many facet groups to include in the facet total (default = 10, max = 1000)

query

(optional) constructs a query over ALL fields, or a fielded query searching within specific fields. Fielded query terms should be separated by ` AND ` or ` OR `. See Elasticserach query strings for more info.

Value

dataframe or list (for facetted queries) containing the response of the API query

Examples

# Return only the first 10 hits for "ivermectin"
df = getResourcesResponse("ivermectin", size = 10)

# Find the first 10 results which contain the variable `topicCategory`  
df = getResourcesResponse("_exists_:topicCategory", size = 10)

# Get `date`/`name` from the first 10 hits for the query "ivermectin" plus a count of the `@type` field for ALL results
df = getResourcesResponse("ivermectin", size = 10, facets="@type", fields=c("date", "name"))