Really-amin's picture
api-resources README English
f8c5f03 verified
|
Raw
History Blame Contribute Delete
1.96 kB

API Resources β€” Datasourceforcryptocurrency-2

Canonical data-source registry for the v2 Hugging Face Space.

Files

File Role
crypto_resources_unified_2025-11-11.json Primary reference β€” structured registry (~274 external + local routes), rotation pools
ultimate_crypto_pipeline_2025_NZasinich.json Supplement β€” 55 curated sources with rate limits, TypeScript examples, free-tier notes
fallback_chains.json Hierarchical failover β€” ordered provider chains per data type (market, news, sentiment, explorers)

Architecture

Request
  β†’ local v2 endpoint (priority 0)
  β†’ rotation pool from unified registry (priority / round_robin / weighted)
  β†’ fallback_chains.json ordered chain (on 429 / 5xx / timeout)
  β†’ v4 complement Space (only if v2 chain exhausted)
  β†’ never return empty β€” cached stale data as last resort

Registry choice

  • Primary: crypto_resources_unified_2025-11-11.json β€” machine-readable schema, section keys match resource_rotation_bridge.py, env key resolution via HF secrets.
  • Supplement: ultimate_crypto_pipeline_2025_NZasinich.json β€” human-friendly examples; merged into unified when URLs are unique. Fixed: stray filename line removed so JSON parses cleanly.

API keys

Never hardcode keys in registry JSON. Use HF Space secrets:

  • CRYPTOCOMPARE_API_KEY, COINMARKETCAP_KEY_1/2, ETHERSCAN_KEY_1/2
  • BSCSCAN_API_KEY, TRONSCAN_API_KEY, NEWSAPI_KEY, HF_TOKEN, COINGECKO_API_KEY

See config/api_keys.json for the full mapping.

Regenerate merged registry

python patches/datasource-v2/scripts/merge_api_registries.py

Endpoints

  • GET /api/resources/rotation β€” pool plan + runtime stats
  • GET /api/resources/rotation/health β€” pool availability
  • GET /api/resources/fallback-chains β€” all chain names
  • GET /api/resources/fallback-chains?data_type=market_price β€” single chain