Constructs an httr2::request, optionally signs it, performs it via the supplied
.perform function, and parses the KuCoin JSON response. This is the single
point through which all KuCoin API calls flow.
Usage
kucoin_build_request(
base_url,
endpoint,
method = "GET",
query = list(),
body = NULL,
keys = NULL,
.perform = httr2::req_perform,
.parser = identity,
is_async = FALSE,
timeout = 10,
.get_timestamp_ms = NULL
)Arguments
- base_url
Character; the API base URL.
- endpoint
Character; the API path.
- method
Character; HTTP method. Default
"GET".- query
Named list; query parameters. Default
list().- body
Named list or NULL; request body. Default
NULL.- keys
List or NULL; API credentials. Default
NULL.- .perform
Function; the httr2 perform function. Default
httr2::req_perform.- .parser
Function; post-processing function applied to parsed
$data. Defaultidentity.- is_async
Logical; whether
.performreturns promises. DefaultFALSE.- timeout
Numeric; request timeout in seconds. Default
10.- .get_timestamp_ms
Function or NULL; zero-argument function returning epoch milliseconds for HMAC signing. When
NULL(default), useslubridate::now(). Pass a custom function (e.g. one that fetches KuCoin server time) to avoid clock-drift issues.
Details
Sync vs Async
The .perform argument controls execution mode:
httr2::req_perform(default): synchronous, returns an httr2::response.httr2::req_perform_promise: asynchronous, returns a promises::promise.