View source: R/request_and_response.R
| query_epigraphdb | R Documentation | 
This is a general purpose function to send data request
which can be used when there has not been an R equivalent package function
to an API endpoint.
Underneath this is a wrapper around httr functions with better handling of
returned status.
query_epigraphdb(
  route,
  params = NULL,
  mode = c("raw", "table"),
  method = c("GET", "POST"),
  retry_times = 3,
  retry_pause_min = 1
)
| route | An EpiGraphDB API endpoint route, e.g.  | 
| params | A list of parameters associated with the query endpoint. | 
| mode | 
 | 
| method | Type of HTTP (GET, POST, PUT, etc.) method. NOTE: When sending a POST request where a specific parameter is specified as a list on the API,
and if the equivalent in R is a vector of length 1, you should wrap this parameter
in  | 
| retry_times | Number of times the function will retry the request to the API. | 
| retry_pause_min | Minimum number of seconds to wait for the next retry. | 
Data from an EpiGraphDB API endpoint.
# GET /mr
# equivalent to `mr(exposure_trait = "Body mass index", outcome_trait = "Coronary heart disease")`
## Not run: 
query_epigraphdb(
  route = "/mr",
  params = list(
    exposure_trait = "Body mass index",
    outcome_trait = "Coronary heart disease"
  ),
  mode = "table"
)
## End(Not run)
# GET /meta/nodes/Gwas/list
## Not run: 
query_epigraphdb(
  route = "/meta/nodes/Gwas/list",
  params = list(
    limit = 5,
    offset = 0
  )
) %>% str(1)
## End(Not run)
# POST /protein/ppi
## Not run: 
query_epigraphdb(
  route = "/protein/ppi",
  params = list(
    uniprot_id_list = c("P30793", "Q9NZM1", "O95236")
  ),
  method = "POST"
)
## End(Not run)
# error handling
## Not run: 
tryCatch(
  query_epigraphdb(
    route = "/mr",
    params = list(
      exposure_trait = NULL,
      outcome_trait = NULL
    ),
    retry_times = 0
  ),
  error = function(e) {
    message(e)
  }
)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.