Repository navigation
crypto2 3.0.0
A major release. crypto2 now draws on two sources: CoinMarketCap (the
crypto_* functions, as before) and CoinGecko (the new cg_* functions),
with a crosswalk that links the two id systems. Several defaults of
crypto_listings() change, so code that relied on them returns different
(complete) data; see "Breaking changes".
Breaking changes
crypto_listings()defaults tolimit = NULL(all coins) instead of
limit = 5000(#26).crypto_listings()defaults toquote = TRUE: price, volume, market-cap
and percent-change columns are returned unlessquote = FALSE. They come
with the same API response, so the default costs no extra requests.crypto_history()withoutcoin_listselects from the full latest
listing rather than its top 5,000.
CoinGecko as a second source
New functions with the same column conventions as their crypto_*
counterparts, so downstream code consumes either tibble. No API key is
needed.
cg_list()-- coin universe; withonly_active = FALSEit adds dead
coins fromcg_id_mapping().cg_listings()-- current snapshot with every/coins/marketsfield
(price, volume, 24h range, price and market-cap changes, all-time
high/low, ROI). CoinGecko's free tier has no historical cross-section;
snapshot this function periodically to build one. Wrapped, staked and
bridged tokens are not listed by/coins/markets.cg_history()andcg_history_by_id()-- daily close, volume and market
cap for the full lifetime of each coin in any quote currency, from
CoinGecko's website chart data (in USD from its daily CSV export, one
request per coin). Daily open/high/low are built from 4-hour candles and
cover the last 30 days; CoinGecko offers longer windows only as 4-day
candles.cg_info()-- coin metadata.cg_id_mapping()-- archive of CoinGecko ids including dead coins,
cached per session with a small bundled fallback.- Dates follow the CMC / CRSP convention by default
(date_convention = "end_of_day"): CoinGecko's midnight-UTC ticks are
labelled with the day that just ended, soclose[X] / close[X-1] - 1is
the return earned on date X.date_convention = "raw"keeps CoinGecko's
labels. - The package never requires or sends an API key. HTTP 429 and transient
408/502/503/504 responses are retried with backoff. Package options
crypto2.cg_sleep,crypto2.cg_wait,
crypto2.cg_max_retries,crypto2.cg_top_n,crypto2.cg_whatand
crypto2.cg_vs_currencytune rate limits, retries and streams. - Opt-in fallback: with
options(crypto2.cg_api_fallback = TRUE),
cg_history()andcg_history_by_id()fetch coins the website cannot
serve from CoinGecko's public API (no key), which covers only the last
365 days. Off by default; a call that falls back warns and records the
coins inattr(result, "cg_api_fallback").cg_list(),cg_listings()
andcg_info()use the public API (no key) directly.
CMC-CoinGecko crosswalk
- New
crypto_crosswalk()links CoinMarketCap ids to CoinGecko slugs and
numeric ids, including dead coins, from the weekly Open Crypto Pricing
crosswalk (Stoeckl & Pukrop 2026, https://opencryptopricing.com,
CC BY 4.0). Pairs are matched on contracts, project links, name/symbol
and slug and confirmed on both providers' prices;min_confidence
(high / medium / low) filters by match quality and
include_unmatched = TRUEadds coins listed by one provider only. The
file is cached per session; Parquet is used whenarrowis installed,
CSV otherwise.
Bug fixes
crypto_listings(which = "historical")returns all coins per day by
default (#26).crypto_listings()handles days with an exact multiple of 5,000 coins
(#27).crypto_global_quotes()returns the current metrics with the default
which = "latest"(#28).crypto_info()andexchange_info()keep an allowlist of known columns,
so new fields in the CoinMarketCap response no longer break them.
Robustness
crypto_listings(which = "historical")fetches each day in pages of
5,000; a day that fails after the retries is named in a warning, and a
day that reaches an explicitlimitis flagged.- The
cg_*functions warn with the page number when paging stops on a
failed page, andcg_history()/cg_history_by_id()stop with an error
when CoinGecko returns no series for any requested coin; partial
failures name the affected coins.
Vignettes
vignette("coingecko-integration")-- walkthrough of thecg_*
functions and a survivorship-bias-free price history in three lines.vignette("cg-vs-cmc")-- what each source delivers, matching coins
withcrypto_crosswalk(), the date conventions, and a reconciliation of
the CMC top 20 across both sources.vignette("coingecko-pro-backfill")-- optional one-shot recipes for a
complete historic universe with a CoinGecko Pro key. The recipes live in
the vignette only; the package itself never uses a key.
Tests
- Offline tests with simulated API responses cover paging, retries,
failure warnings, the CSV re-alignment, the API fallback and the
crosswalk, and run on CRAN. Live tests (skipped on CRAN) reconcile BTC
across both sources and fail when a CoinGecko endpoint is retired rather
than skipping. - A weekly GitHub Actions workflow (
endpoint-check) calls every
CoinMarketCap function and fetches every CoinGecko and Hugging Face
source the package uses, checks the shape of each answer and fails when
an endpoint is retired or its format changes. Run it locally with
Rscript .github/scripts/check_endpoints.R.