Skip to contents

Performs an API call to a Neon Database server and returns the response as a list.

Usage

api(
  path,
  method = c("GET", "CONNECT", "DELETE", "HEAD", "OPTIONS", "PATCH", "POST", "PUT",
    "TRACE"),
  origin = funky::config_val("origin"),
  api_key = funky::config_val("api_key"),
  max_tries = 3L
)

Arguments

path

character(1)
Neon API endpoint path.

method

character(1)
HTTP request method. One of "GET", "CONNECT", "DELETE", "HEAD", "OPTIONS", "PATCH", "POST", "PUT" or "TRACE".

origin

character(1)
Neon server origin.

api_key

character(1)
API key with sufficient access to the Neon project_id.

max_tries

Maximum number of request attempts in case of an HTTP error. An integerish scalar. Retries are performed using exponential backoff and jitter, see httr2::req_retry() for details.

Value

The API's JSON response converted to a list.

Details

For full control over the performed HTTP request, resort to the lower-level req_basic().

See also

Other common functions: req_basic()