Skip to contents

Retrieves the latest announcements from the KuCoin API asynchronously, aggregating paginated results into a single data.table. This internal function is designed for use within a larger system and is not intended for direct end-user consumption.

Usage

get_announcements_impl(
  base_url = get_base_url(),
  query = list(),
  page_size = 50,
  max_pages = Inf,
  .__coro_env_parent__ = <environment>
)

Arguments

base_url

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

query

Named list; additional query parameters to filter announcements. Supported:

  • currentPage (integer, optional): Page number to retrieve.

  • pageSize (integer, optional): Number of announcements per page.

  • annType (string, optional): Type of announcements (e.g., "latest-announcements", "activities", "product-updates", "vip", "maintenance-updates", "delistings", "others", "api-campaigns", "new-listings").

  • lang (string, optional): Language (e.g., "en_US", "zh_HK", "ja_JP").

  • startTime (integer, optional): Start time in milliseconds.

  • endTime (integer, optional): End time in milliseconds.

page_size

Integer; number of results per page (default 50).

max_pages

Numeric; maximum number of pages to fetch (default Inf for all pages).

Value

Promise resolving to a data.table containing:

  • annId (integer): Unique announcement ID.

  • annTitle (character): Announcement title.

  • annType (list): List of announcement types.

  • annDesc (character): Announcement description.

  • cTime (integer): Release time in Unix milliseconds.

  • language (character): Language of the announcement.

  • annUrl (character): URL to the full announcement.

  • currentPage (integer): Current page number.

  • pageSize (integer): Records per page.

  • totalNum (integer): Total number of announcements.

  • totalPage (integer): Total pages available.

Details

Workflow Overview

  1. Query Construction: Merges default parameters (currentPage = 1, pageSize = 50, annType = "latest-announcements", lang = "en_US") with user-supplied query using utils::modifyList().

  2. URL Assembly: Combines base_url with /api/v3/announcements and the query string from build_query().

  3. Page Fetching: Defines an async fetch_page function to send a GET request with a 10-second timeout via httr::GET().

  4. Pagination: Utilises auto_paginate to fetch all pages up to max_pages, extracting "items" from each response.

  5. Aggregation: Combines results into a data.table with data.table::rbindlist().

API Endpoint

GET https://api.kucoin.com/api/v3/announcements

Usage

Utilised to gather KuCoin news announcements (e.g., updates, promotions) for market analysis or display.

Official Documentation

KuCoin Get Announcements

Examples

if (FALSE) { # \dontrun{
main_async <- coro::async(function() {
  # Default: latest announcements in English
  announcements <- await(get_announcements_impl())
  print(announcements)
  # Filtered by type and language
  activities <- await(get_announcements_impl(query = list(annType = "activities", lang = "en_US")))
  print(activities)
})
main_async()
while (!later::loop_empty()) later::run_now()
} # }