Skip to contents

Retrieves a paginated list of deposit history entries from KuCoin asynchronously by sending a GET request to the /api/v1/deposits endpoint. This internal function is designed for use within an R6 class and is not intended for direct end-user consumption. Deposits are sorted to show the latest first, with pagination handled automatically.

Usage

get_deposit_history_impl(
  keys = get_api_keys(),
  base_url = get_base_url(),
  currency,
  status = NULL,
  startAt = NULL,
  endAt = NULL,
  page_size = 50,
  max_pages = Inf,
  .__coro_env_parent__ = <environment>
)

Arguments

keys

List containing API configuration parameters from get_api_keys(), including:

  • api_key: Character string; your KuCoin API key.

  • api_secret: Character string; your KuCoin API secret.

  • api_passphrase: Character string; your KuCoin API passphrase.

  • key_version: Character string; API key version (e.g., "2"). Defaults to get_api_keys().

base_url

Character string representing the base URL for the API. Defaults to get_base_url().

currency

Character string; the currency to filter deposits by (e.g., "BTC", "ETH", "USDT").

status

Character string (optional); the status to filter by ("PROCESSING", "SUCCESS", "FAILURE"). If not provided, all statuses are included.

startAt

Integer (optional); start time in milliseconds to filter deposits (e.g., 1728663338000).

endAt

Integer (optional); end time in milliseconds to filter deposits (e.g., 1728692138000).

page_size

Integer; number of results per page (minimum 10, maximum 500). Defaults to 50.

max_pages

Numeric; maximum number of pages to fetch (defaults to Inf, fetching all available pages).

Value

Promise resolving to a data.table containing the deposit history, with columns including:

  • currency (character): The currency of the deposit (e.g., "USDT").

  • chain (character): The chain identifier (may be empty).

  • status (character): Deposit status ("PROCESSING", "SUCCESS", "FAILURE").

  • address (character): Deposit address or identifier.

  • memo (character): Address remark (may be empty).

  • isInner (logical): Whether the deposit is internal to KuCoin.

  • amount (character): Deposit amount.

  • fee (character): Fee charged for the deposit.

  • walletTxId (character or NULL): Wallet transaction ID (if applicable).

  • createdAt (integer): Creation timestamp in milliseconds.

  • createdAtDatetime (POSIXct): Converted creation datetime.

  • updatedAt (integer): Last updated timestamp in milliseconds.

  • remark (character): Additional remarks (may be empty).

  • arrears (logical): Whether the deposit is in arrears. If no deposits are found, an empty data.table with these columns is returned.

Details

Workflow Overview

  1. URL Construction: Combines the base URL with the endpoint /api/v1/deposits and constructs query parameters using build_query().

  2. Pagination Initialisation: Sets an initial query with currentPage = 1 and the specified page_size, merging with additional filters.

  3. Page Fetching: Defines an asynchronous helper function (fetch_page) to send GET requests for each page, including authentication headers.

  4. Automatic Pagination: Leverages auto_paginate to fetch all pages up to max_pages, aggregating results into a single list.

  5. Response Handling: Processes responses with process_kucoin_response(), combines items into a data.table using rbindlist(), and adds a createdAtDatetime column for human-readable timestamps.

API Endpoint

GET https://api.kucoin.com/api/v1/deposits

Usage

Utilised internally to fetch a comprehensive history of deposits for a KuCoin account, allowing filtering by currency, status, and time range.

Official Documentation

KuCoin Get Deposit History

Examples

if (FALSE) { # \dontrun{
keys <- get_api_keys()
base_url <- "https://api.kucoin.com"
main_async <- coro::async(function() {
  dt <- await(get_deposit_history_impl(
    keys = keys,
    base_url = base_url,
    currency = "USDT",
    status = "SUCCESS",
    startAt = 1728663338000,
    endAt = 1728692138000,
    page_size = 50,
    max_pages = 2
  ))
  print(dt)
})
main_async()
while (!later::loop_empty()) later::run_now()
} # }