Skip to contents

Retrieves detailed information for a specified currency from the KuCoin API asynchronously, including chain-specific details for multi-chain currencies.

Usage

get_currency_impl(
  base_url = get_base_url(),
  currency,
  chain = NULL,
  .__coro_env_parent__ = <environment>
)

Arguments

base_url

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

currency

Character string; currency code (e.g., "BTC", "USDT").

chain

Character string (optional); specific chain for multi-chain currencies (e.g., "ERC20", "TRC20").

Value

Promise resolving to a data.table containing:

  • currency (character): Unique currency code.

  • name (character): Short name of the currency.

  • fullName (character): Full name of the currency.

  • precision (integer): Decimal places for the currency.

  • confirms (integer or NULL): Block confirmations required.

  • contractAddress (character or NULL): Contract address for tokenized currencies.

  • isMarginEnabled (logical): Margin trading enabled status.

  • isDebitEnabled (logical): Debit enabled status.

  • Chain-specific fields (e.g., chainName, withdrawalMinSize) from the chains list.

Details

Workflow Overview

  1. Query Construction: Builds a query string with the optional chain parameter using build_query().

  2. URL Assembly: Combines base_url, /api/v3/currencies/, the currency code, and the query string.

  3. HTTP Request: Sends a GET request with a 10-second timeout via httr::GET().

  4. Response Processing: Validates the response with process_kucoin_response() and extracts the "data" field.

  5. Data Conversion: Splits "data" into summary fields and chains data, combining them into a data.table.

API Endpoint

GET https://api.kucoin.com/api/v3/currencies/{currency}

Usage

Utilised to obtain metadata (e.g., precision, chain support) for a specific currency on KuCoin.

Official Documentation

KuCoin Get Currency

Examples

if (FALSE) { # \dontrun{
main_async <- coro::async(function() {
  # Bitcoin details
  btc <- await(get_currency_impl(currency = "BTC"))
  print(btc)
  # USDT on ERC20 chain
  usdt_erc20 <- await(get_currency_impl(currency = "USDT", chain = "ERC20"))
  print(usdt_erc20)
})
main_async()
while (!later::loop_empty()) later::run_now()
} # }