Processes an HTTP response from a KuCoin API request, validating its HTTP status and API-specific response code, returning the parsed JSON object if successful or aborting with an error otherwise.
Arguments
- response
HTTP response object (e.g., from
httr::GET()
).- url
Character string representing the requested URL, used for error messages.
Value
List representing the parsed JSON response; users should extract fields like "data"
as required.
Details
Workflow Overview
Check HTTP Status: Confirms the status code is 200, aborting if not.
Parse JSON: Extracts the response content as text and parses it into a JSON object using
jsonlite::fromJSON()
.Validate Structure: Verifies the
"code"
field exists, aborting if absent.Check Success: Ensures the
"code"
is"200000"
, retrieving an error message from"msg"
and aborting if not successful.