"""Realtap public API client: copy what you need. Standard library only (Python 3.8+). Anonymous requests share a per-IP limit; an API key (env OPENTAP_KEY, header x-api-key) raises it: https://realtap.app/developers""" import json import os import time import urllib.error import urllib.parse import urllib.request from urllib.parse import quote BASE = "https://realtap.app/api/v1" KEY = os.environ.get("OPENTAP_KEY") def request(path, query=None, retries=2): """Every endpoint also accepts fields="a,b.c" (keep only those fields) and compact=1 (drop nulls and empty arrays).""" params = {k: ("1" if v is True else v) for k, v in (query or {}).items() if v is not None} url = BASE + path + ("?" + urllib.parse.urlencode(params) if params else "") req = urllib.request.Request(url, headers={"x-api-key": KEY} if KEY else {}) try: with urllib.request.urlopen(req, timeout=30) as res: return json.load(res) except urllib.error.HTTPError as e: if e.code == 429 and retries > 0: time.sleep(int(e.headers.get("Retry-After") or 5)) return request(path, query, retries - 1) raise def get_tokens(**query): """GET /tokens: List tokens Query: sort, period, order, quote, minLiquidity, minHolders, q, logos, page, pageSize, plus fields and compact.""" return request(f"/tokens", query) def get_tokens_by_unit(unit, **query): """GET /tokens/{unit}: Token detail with pools Query: fields, compact.""" return request(f"/tokens/{quote(str(unit), safe='')}", query) def get_tokens_by_unit_candles(unit, **query): """GET /tokens/{unit}/candles: OHLCV candles Query: interval, pool, quote, from, to, plus fields and compact.""" return request(f"/tokens/{quote(str(unit), safe='')}/candles", query) def get_tokens_by_unit_trades(unit, **query): """GET /tokens/{unit}/trades: Recent trades of a token Query: limit, cursor, plus fields and compact.""" return request(f"/tokens/{quote(str(unit), safe='')}/trades", query) def get_tokens_by_unit_holders(unit, **query): """GET /tokens/{unit}/holders: Top holders Query: fields, compact.""" return request(f"/tokens/{quote(str(unit), safe='')}/holders", query) def get_tokens_by_unit_traders(unit, **query): """GET /tokens/{unit}/traders: Top traders of a token, and its buys and sells, over a window Query: window, limit, plus fields and compact.""" return request(f"/tokens/{quote(str(unit), safe='')}/traders", query) def get_tokens_by_unit_liquidity(unit, **query): """GET /tokens/{unit}/liquidity: Depth within ±2% per pool, liquidity added and removed over a window, net flow per wallet Query: window, plus fields and compact.""" return request(f"/tokens/{quote(str(unit), safe='')}/liquidity", query) def get_tokens_by_unit_liquidity_events(unit, **query): """GET /tokens/{unit}/liquidity/events: Add and remove orders of a token's pools, newest first Query: window, limit, cursor, plus fields and compact.""" return request(f"/tokens/{quote(str(unit), safe='')}/liquidity/events", query) def get_tokens_by_unit_distribution(unit, **query): """GET /tokens/{unit}/distribution: How supply is spread over holders, with what the holder list covers Query: fields, compact.""" return request(f"/tokens/{quote(str(unit), safe='')}/distribution", query) def get_tokens_by_unit_transfers(unit, **query): """GET /tokens/{unit}/transfers: Transfers of a token with senders and receivers, newest first; needs the ledger index (available false and a note while it is off) Query: limit, cursor, plus fields and compact.""" return request(f"/tokens/{quote(str(unit), safe='')}/transfers", query) def get_tokens_by_unit_holders_history(unit, **query): """GET /tokens/{unit}/holders/history: Holders, top 10 and top 50 share per day (shares are null unless the stored holder list is the true top) Query: days, plus fields and compact.""" return request(f"/tokens/{quote(str(unit), safe='')}/holders/history", query) def get_tokens_by_unit_series_by_metric(unit, metric, **query): """GET /tokens/{unit}/series/{metric}: Daily liquidity or holder-count history Query: days, plus fields and compact.""" return request(f"/tokens/{quote(str(unit), safe='')}/series/{quote(str(metric), safe='')}", query) def get_pools(**query): """GET /pools: List liquidity pools Query: dex, sort, page, pageSize, plus fields and compact.""" return request(f"/pools", query) def get_pools_by_id(id, **query): """GET /pools/{id}: Pool detail Query: fields, compact.""" return request(f"/pools/{quote(str(id), safe='')}", query) def get_pools_by_id_candles(id, **query): """GET /pools/{id}/candles: Pool OHLCV candles Query: interval, quote, plus fields and compact.""" return request(f"/pools/{quote(str(id), safe='')}/candles", query) def get_pools_by_id_trades(id, **query): """GET /pools/{id}/trades: Pool trades Query: limit, cursor, plus fields and compact.""" return request(f"/pools/{quote(str(id), safe='')}/trades", query) def get_wallet_by_address(address, **query): """GET /wallet/{address}: Wallet portfolio: positions valued in ADA and USD Query: fields, compact.""" return request(f"/wallet/{quote(str(address), safe='')}", query) def get_wallet_by_address_related(address, **query): """GET /wallet/{address}/related: Counterparties of a wallet in token transfers, by number of shared transactions; needs the ledger index (available false while it is off) Query: limit, days, contracts, plus fields and compact.""" return request(f"/wallet/{quote(str(address), safe='')}/related", query) def get_wallet_by_address_trades(address, **query): """GET /wallet/{address}/trades: DEX trades made by a wallet Query: limit, cursor, plus fields and compact.""" return request(f"/wallet/{quote(str(address), safe='')}/trades", query) def get_wallet_by_address_pnl(address, **query): """GET /wallet/{address}/pnl: Realised / unrealised profit and loss (heavy: lower rate limit) Query: fields, compact.""" return request(f"/wallet/{quote(str(address), safe='')}/pnl", query) def get_wallet_by_address_activity(address, **query): """GET /wallet/{address}/activity: Trades by weekday and hour (UTC) over the swaps the site holds Query: fields, compact.""" return request(f"/wallet/{quote(str(address), safe='')}/activity", query) def get_wallet_by_address_liquidity(address, **query): """GET /wallet/{address}/liquidity: Liquidity a wallet added and removed, by pool Query: fields, compact.""" return request(f"/wallet/{quote(str(address), safe='')}/liquidity", query) def get_wallet_by_address_risk(address, **query): """GET /wallet/{address}/risk: Transparent 0-100 wallet risk score with named reasons (a heuristic, not an accusation) Query: fields, compact.""" return request(f"/wallet/{quote(str(address), safe='')}/risk", query) def get_nft_collections(**query): """GET /nft/collections: List NFT collections Query: page, pageSize, plus fields and compact.""" return request(f"/nft/collections", query) def get_nft_collections_by_policy(policy, **query): """GET /nft/collections/{policy}: NFT collection detail Query: fields, compact.""" return request(f"/nft/collections/{quote(str(policy), safe='')}", query) def get_nft_collections_by_policy_sales(policy, **query): """GET /nft/collections/{policy}/sales: Recent sales of a collection Query: limit, cursor, plus fields and compact.""" return request(f"/nft/collections/{quote(str(policy), safe='')}/sales", query) def get_nft_collections_by_policy_listings(policy, **query): """GET /nft/collections/{policy}/listings: Active listings of a collection Query: fields, compact.""" return request(f"/nft/collections/{quote(str(policy), safe='')}/listings", query) def get_nft_collections_by_policy_depth(policy, **query): """GET /nft/collections/{policy}/depth: Listing depth: cost to buy the cheapest N listings and the floor after Query: fields, compact.""" return request(f"/nft/collections/{quote(str(policy), safe='')}/depth", query) def get_nft_collections_by_policy_activity(policy, **query): """GET /nft/collections/{policy}/activity: Per day sales, volume, buyers, sellers and royalties; wallet sizes; top traders Query: days, plus fields and compact.""" return request(f"/nft/collections/{quote(str(policy), safe='')}/activity", query) def get_nft_collections_by_policy_listing_history(policy, **query): """GET /nft/collections/{policy}/listing-history: Listings made, sold, withdrawn and open per day, with the floor Query: days, plus fields and compact.""" return request(f"/nft/collections/{quote(str(policy), safe='')}/listing-history", query) def get_nft_collections_by_policy_sales_points(policy, **query): """GET /nft/collections/{policy}/sales-points: The sales of the window as price points (up to 1,000, newest) Query: days, plus fields and compact.""" return request(f"/nft/collections/{quote(str(policy), safe='')}/sales-points", query) def get_nft_collections_by_policy_trait_prices(policy, **query): """GET /nft/collections/{policy}/trait-prices: Per trait value: listed, floor, sales, average sale Query: days, plus fields and compact.""" return request(f"/nft/collections/{quote(str(policy), safe='')}/trait-prices", query) def get_nft_collections_by_policy_trades(policy, **query): """GET /nft/collections/{policy}/trades: Sales feed with rarity rank, both wallets and royalty (same-wallet rows left out) Query: limit, cursor, plus fields and compact.""" return request(f"/nft/collections/{quote(str(policy), safe='')}/trades", query) def get_nft_collections_by_policy_wallet_trades(policy, **query): """GET /nft/collections/{policy}/wallet-trades: One wallet's entries and exits in a collection Query: address, plus fields and compact.""" return request(f"/nft/collections/{quote(str(policy), safe='')}/wallet-trades", query) def get_nft_collections_by_policy_concentration(policy, **query): """GET /nft/collections/{policy}/concentration: Share of the supply held by the largest holders, where the ledger count is complete Query: fields, compact.""" return request(f"/nft/collections/{quote(str(policy), safe='')}/concentration", query) def get_nft_market(**query): """GET /nft/market: The whole NFT market: sales, volume, active wallets, fees and royalties per marketplace Query: days, plus fields and compact.""" return request(f"/nft/market", query) def get_nft_market_pulse(**query): """GET /nft/market/pulse: The NFT market right now: 24 h and 7 d sales, volume, new listings and marketplace share; top collections by volume; biggest floor moves Query: fields, compact.""" return request(f"/nft/market/pulse", query) def get_explorer_blocks_by_id(id, **query): """GET /explorer/blocks/{id}: Block by hash or height Query: fields, compact.""" return request(f"/explorer/blocks/{quote(str(id), safe='')}", query) def get_explorer_tx_by_hash(hash, **query): """GET /explorer/tx/{hash}: Transaction with inputs, outputs and metadata Query: fields, compact.""" return request(f"/explorer/tx/{quote(str(hash), safe='')}", query) def get_explorer_address_by_address(address, **query): """GET /explorer/address/{address}: Address balance and summary Query: fields, compact.""" return request(f"/explorer/address/{quote(str(address), safe='')}", query) def get_staking_pools(**query): """GET /staking/pools: Stake pools Query: page, pageSize, plus fields and compact.""" return request(f"/staking/pools", query) def get_staking_delegation_tx(**query): """GET /staking/delegation-tx: Build an unsigned stake-pool and/or DRep delegation transaction (never signed or submitted by Realtap) Query: address, pool, drep, plus fields and compact.""" return request(f"/staking/delegation-tx", query) def get_staking_pools_by_id(id, **query): """GET /staking/pools/{id}: Stake pool detail Query: fields, compact.""" return request(f"/staking/pools/{quote(str(id), safe='')}", query) def get_aquarium_overview(**query): """GET /aquarium/overview: Aquarium (Iagon / Aquarium network) overview Query: fields, compact.""" return request(f"/aquarium/overview", query) def get_market_overview(**query): """GET /market/overview: Market overview: volume, TVL, DEX shares, gainers, losers, trending Query: fields, compact.""" return request(f"/market/overview", query) def get_market_history(**query): """GET /market/history: The DEX market over time: volume, swaps, makers and trading fees per day (week, month), for all DEXes or one Query: range, dex, plus fields and compact.""" return request(f"/market/history", query) def get_market_dexes(**query): """GET /market/dexes: Every DEX: the last 24 hours, the last 7 and 30 full days, liquidity and fee APR Query: fields, compact.""" return request(f"/market/dexes", query) def get_trades(**query): """GET /trades: Every settled swap on every DEX, newest first; filter by size for large trades, or by DEX Query: window, minAda, dex, limit, cursor, plus fields and compact.""" return request(f"/trades", query) def get_swap_quote(**query): """GET /swap/quote: Best-route swap quote Query: in, out, amount, plus fields and compact.""" return request(f"/swap/quote", query) def get_swap_route(**query): """GET /swap/route: Swap plan of the own router: one or several orders on Minswap V2, SundaeSwap V3 and WingRiders V2, with every fee Query: in, out, amount, slippage, maxLegs, plus fields and compact.""" return request(f"/swap/route", query) def get_trade_status_by_txhash(txhash, **query): """GET /trade/status/{txHash}: Status of the swap orders a transaction placed Query: fields, compact.""" return request(f"/trade/status/{quote(str(txhash), safe='')}", query) def get_trade_atomic(**query): """GET /trade/atomic: Direct (atomic) against batched trades per aggregator and DEX, SteelSwap version adoption and partner wallets Query: window, plus fields and compact.""" return request(f"/trade/atomic", query) def get_trade_orders(**query): """GET /trade/orders: Open swap orders of a wallet at Minswap V2, SundaeSwap V3 and WingRiders V2 (unspent in the ledger now) Query: address, plus fields and compact.""" return request(f"/trade/orders", query) def get_masumi_overview(**query): """GET /masumi/overview: Masumi: registered AI agent services and the payments through its escrow in the last 30 days Query: fields, compact.""" return request(f"/masumi/overview", query) def get_masumi_agents(**query): """GET /masumi/agents: AI agent services registered in the Masumi registry, with price, endpoint and the payments each received Query: q, kind, sort, paid, status, page, pageSize, plus fields and compact.""" return request(f"/masumi/agents", query) def get_masumi_agents_by_unit(unit, **query): """GET /masumi/agents/{unit}: One registry entry with its latest payments Query: fields, compact.""" return request(f"/masumi/agents/{quote(str(unit), safe='')}", query) def get_masumi_payments(**query): """GET /masumi/payments: Payments through the Masumi escrow, newest first Query: agent, limit, cursor, plus fields and compact.""" return request(f"/masumi/payments", query) def get_programmable(**query): """GET /programmable: Programmable tokens (CIP-113): the deployment, how far our index reaches, every registered token with its rules in a line Query: fields, compact.""" return request(f"/programmable", query) def get_programmable_tokens_by_id(id, **query): """GET /programmable/tokens/{id}: A programmable token's rules in plain words, its issuer (administrator and operators), block list, holders and latest compliance events Query: fields, compact.""" return request(f"/programmable/tokens/{quote(str(id), safe='')}", query) def get_programmable_tokens_by_id_holders(id, **query): """GET /programmable/tokens/{id}/holders: Holders of a programmable token under the standard's contract Query: limit, plus fields and compact.""" return request(f"/programmable/tokens/{quote(str(id), safe='')}/holders", query) def get_programmable_issuer_by_id(id, **query): """GET /programmable/issuer/{id}: The issuer view of a programmable token: its rules, supply (held, minted, burned), holders, tokens that share its administrator or scripts, and every issuer action we read Query: fields, compact.""" return request(f"/programmable/issuer/{quote(str(id), safe='')}", query) def get_programmable_address_by_q(q, **query): """GET /programmable/address/{q}: Programmable balances of an address, stake address or owner credential, with each token's restrictions Query: fields, compact.""" return request(f"/programmable/address/{quote(str(q), safe='')}", query) def get_programmable_events(**query): """GET /programmable/events: Freezes, unfreezes, tokens moved by the issuer without the holder (third_party), mints, burns, rule and setting changes, each with its transaction Query: policy, kind, subject, limit, before, plus fields and compact.""" return request(f"/programmable/events", query) def get_programmable_preflight(**query): """GET /programmable/preflight: Would a transfer of a programmable token from A to B be allowed, and if not, why? Answers only from indexed state and lists what it cannot know; never 'allowed' Query: unit, from, to, amount, plus fields and compact.""" return request(f"/programmable/preflight", query) def get_programmable_send_context(**query): """GET /programmable/send-context: What a browser needs to build a transfer of a programmable token (CIP-113): the token's rules, the owner's holdings, the standard's reference UTxOs, the covering block-list node, identity proofs found on chain and the proven cost models. Answers `disabled` unless the site has the send flow switched on. Read-only; nothing is built, signed or sent Query: unit, owner, to, plus fields and compact.""" return request(f"/programmable/send-context", query) def get_tokens_prices(**query): """GET /tokens/prices: Prices of up to 100 tokens in one request Query: units, plus fields and compact.""" return request(f"/tokens/prices", query) def get_tokens_price_change(**query): """GET /tokens/price-change: Change of the ADA price over one or more windows, for up to 100 tokens Query: units, windows, plus fields and compact.""" return request(f"/tokens/price-change", query) def get_explorer_labels(**query): """GET /explorer/labels: Names of contracts and entities for up to 100 credentials or addresses, each with source and licence Query: items, plus fields and compact.""" return request(f"/explorer/labels", query) def get_explorer_labels_by_id(id, **query): """GET /explorer/labels/{id}: Name of one contract or entity (null when unknown), with source and licence Query: fields, compact.""" return request(f"/explorer/labels/{quote(str(id), safe='')}", query) def get_explorer_stake_by_address(address, **query): """GET /explorer/stake/{address}: Stake key: controlled stake, rewards, pool and DRep, addresses Query: fields, compact.""" return request(f"/explorer/stake/{quote(str(address), safe='')}", query) def get_explorer_policy_by_policy(policy, **query): """GET /explorer/policy/{policy}: Minting policy: its assets, mints in the window, script Query: fields, compact.""" return request(f"/explorer/policy/{quote(str(policy), safe='')}", query) def get_explorer_epochs(**query): """GET /explorer/epochs: Epochs with blocks, transactions and fees (exact totals for epochs older than our block index) Query: fields, compact.""" return request(f"/explorer/epochs", query) def get_explorer_protocol(**query): """GET /explorer/protocol: Current protocol parameters (the ledger's values) and the genesis constants Query: fields, compact.""" return request(f"/explorer/protocol", query) def get_explorer_history(**query): """GET /explorer/history: The chain per UTC day: transactions, fees and block space used, from our own block index Query: range, plus fields and compact.""" return request(f"/explorer/history", query) def get_governance_overview(**query): """GET /governance/overview: Governance overview: treasury, DReps, actions by status, committee, rules in force, live actions with tallies Query: fields, compact.""" return request(f"/governance/overview", query) def get_governance_actions(**query): """GET /governance/actions: Governance actions with status, epochs and vote tallies Query: status, type, q, plus fields and compact.""" return request(f"/governance/actions", query) def get_governance_actions_by_id(id, **query): """GET /governance/actions/{id}: One governance action: text, withdrawals, parameter changes, every vote Query: fields, compact.""" return request(f"/governance/actions/{quote(str(id), safe='')}", query) def get_governance_actions_by_id_tally_history(id, **query): """GET /governance/actions/{id}/tally-history: How the vote on an action moved: daily tally per voting body (DRep power Yes/No/Abstain, pool and committee vote counts) Query: fields, compact.""" return request(f"/governance/actions/{quote(str(id), safe='')}/tally-history", query) def get_governance_dreps(**query): """GET /governance/dreps: DReps by voting power, with participation Query: sort, status, q, page, pageSize, plus fields and compact.""" return request(f"/governance/dreps", query) def get_governance_dreps_by_id(id, **query): """GET /governance/dreps/{id}: One DRep: power, votes, participation, certificates, delegators, power history Query: fields, compact.""" return request(f"/governance/dreps/{quote(str(id), safe='')}", query) def get_governance_committee(**query): """GET /governance/committee: Constitutional committee: members, terms, who appointed them, constitution, committee actions Query: fields, compact.""" return request(f"/governance/committee", query) def get_governance_treasury_withdrawals(**query): """GET /governance/treasury/withdrawals: Treasury withdrawals proposed to governance, paid out per year Query: fields, compact.""" return request(f"/governance/treasury/withdrawals", query) def get_governance_parameters(**query): """GET /governance/parameters: History of protocol parameter changes since epoch 208, with the governance action behind each Query: fields, compact.""" return request(f"/governance/parameters", query) def get_claims(**query): """GET /claims: Pool and DRep pages their operators have claimed (verified or approved claims only) Query: fields, compact.""" return request(f"/claims", query) def get_claims_by_kind_by_id(kind, id, **query): """GET /claims/{kind}/{id}: The claim shown on one pool or DRep page, or null Query: fields, compact.""" return request(f"/claims/{quote(str(kind), safe='')}/{quote(str(id), safe='')}", query) def get_buybot_info(**query): """GET /buybot/info: Telegram buy bot: groups using it, tokens followed, posts in 24 h, and the add-to-group link Query: fields, compact.""" return request(f"/buybot/info", query) def get_embed_widget_by_subject_by_id(subject, id, **query): """GET /embed/widget/{subject}/{id}: The figures behind the embeddable widget of a stake pool, DRep, token, wallet, NFT collection, the market strip (id ada) or a governance action Query: fields, compact.""" return request(f"/embed/widget/{quote(str(subject), safe='')}/{quote(str(id), safe='')}", query) def get_wrapped_by_id(id, **query): """GET /wrapped/{id}: Cardano Wrapped 2026: one wallet's year card. Off until 1 December 2026 (404 with the launch date); 451 when the wallet opted out; 503 {status: busy, retryAfter} while many cards are being computed Query: refresh, plus fields and compact.""" return request(f"/wrapped/{quote(str(id), safe='')}", query) def get_credits_packs(**query): """GET /credits/packs: Request credits bought in ADA: the packs, how to pay, how to get a free key (Telegram /apikey), and when a Plus plan is cheaper Query: fields, compact.""" return request(f"/credits/packs", query) def get_credits_me(**query): """GET /credits/me: Your credit balance, today's use, limits and open payment requests (needs an x-api-key) Query: fields, compact.""" return request(f"/credits/me", query) def get_credits_intents(**query): """GET /credits/intents: Your last 10 credit payment requests (needs an x-api-key). To BUY a pack: POST https:///api/credits/intents {'pack':'s'} with the key (v1 itself is read-only); it answers the address and the exact ADA amount Query: fields, compact.""" return request(f"/credits/intents", query) def get_credits_intents_by_id(id, **query): """GET /credits/intents/{id}: Look for the payment of a credit request; credits are added when it is found (needs an x-api-key) Query: fields, compact.""" return request(f"/credits/intents/{quote(str(id), safe='')}", query) def get_tokens_by_unit_safety(unit, **query): """GET /tokens/{unit}/safety: Safety score of a token: mint policy, holder concentration, liquidity lock, red flags Query: fields, compact.""" return request(f"/tokens/{quote(str(unit), safe='')}/safety", query) def get_loans_overview(**query): """GET /loans/overview: Fluid loans: totals, rates and the biggest principal assets Query: fields, compact.""" return request(f"/loans/overview", query) def get_loans(**query): """GET /loans: List loans and loan offers Query: status, protocol, wallet, sort, page, pageSize, plus fields and compact.""" return request(f"/loans", query) def get_loans_wallet_by_address(address, **query): """GET /loans/wallet/{address}: Loans a wallet borrowed or lent Query: fields, compact.""" return request(f"/loans/wallet/{quote(str(address), safe='')}", query) def get_loans_token_by_unit(unit, **query): """GET /loans/token/{unit}: Loans that use a token as principal or collateral, with the lending market rates Query: fields, compact.""" return request(f"/loans/token/{quote(str(unit), safe='')}", query) def get_loans_by_id(id, **query): """GET /loans/{id}: One loan with its terms, collateral value and liquidation distance Query: fields, compact.""" return request(f"/loans/{quote(str(id), safe='')}", query) def get_perps_overview(**query): """GET /perps/overview: Perpetual futures on Cardano: open interest, volume, funding, vault size, liquidations Query: fields, compact.""" return request(f"/perps/overview", query) def get_perps_markets(**query): """GET /perps/markets: Every perp market: mark and index price, funding, open interest, 24 h volume Query: fields, compact.""" return request(f"/perps/markets", query) def get_perps_positions(**query): """GET /perps/positions: Open positions, largest first Query: symbol, side, wallet, minUsd, traders, sort, page, pageSize, plus fields and compact.""" return request(f"/perps/positions", query) def get_perps_events(**query): """GET /perps/events: Recent fills: opens, closes, funding and liquidations Query: symbol, before, plus fields and compact.""" return request(f"/perps/events", query) def get_perps_liquidations(**query): """GET /perps/liquidations: Liquidated positions Query: wallet, page, pageSize, plus fields and compact.""" return request(f"/perps/liquidations", query) def get_perps_leaderboard(**query): """GET /perps/leaderboard: Best traders by volume, PnL or ROI Query: period, sort, limit, offset, plus fields and compact.""" return request(f"/perps/leaderboard", query) def get_perps_custody(**query): """GET /perps/custody: What the perps venue holds in custody Query: fields, compact.""" return request(f"/perps/custody", query) def get_perps_transfers(**query): """GET /perps/transfers: Deposits into and withdrawals out of the venue Query: kind, wallet, page, pageSize, plus fields and compact.""" return request(f"/perps/transfers", query) def get_perps_wallet_by_address(address, **query): """GET /perps/wallet/{address}: One wallet on the perps venue: equity, positions, fills Query: fields, compact.""" return request(f"/perps/wallet/{quote(str(address), safe='')}", query) def get_defi(**query): """GET /defi: Cardano DeFi: total value locked by protocol and category Query: fields, compact.""" return request(f"/defi", query) def get_defi_protocols_by_id(id, **query): """GET /defi/protocols/{id}: One protocol: TVL history, markets and links Query: fields, compact.""" return request(f"/defi/protocols/{quote(str(id), safe='')}", query) def get_defi_markets(**query): """GET /defi/markets: Lending and staking markets with supply and borrow rates Query: protocol, kind, plus fields and compact.""" return request(f"/defi/markets", query) def get_defi_registry(**query): """GET /defi/registry: The protocols and stablecoins Realtap tracks, with policy ids Query: fields, compact.""" return request(f"/defi/registry", query) def get_defi_positions_by_address(address, **query): """GET /defi/positions/{address}: A wallet's lending, staking and liquidity positions across protocols Query: fields, compact.""" return request(f"/defi/positions/{quote(str(address), safe='')}", query) def get_yields(**query): """GET /yields: Yield table: LP fee APR, lending rates and staking ROA Query: minTvl, limit, plus fields and compact.""" return request(f"/yields", query) def get_stablecoins(**query): """GET /stablecoins: Cardano stablecoins: price, peg deviation, market cap and supply history Query: fields, compact.""" return request(f"/stablecoins", query) def get_earn(**query): """GET /earn: Where could this asset earn the most? Staking, lending, p2p loans and liquidity pools ranked Query: asset, amount, minTvl, lpLimit, plus fields and compact.""" return request(f"/earn", query) def get_earn_assets(**query): """GET /earn/assets: Assets the earn comparison supports Query: fields, compact.""" return request(f"/earn/assets", query) def get_predictions_overview(**query): """GET /predictions/overview: Prediction markets (Bodega): open markets, volume, biggest movers Query: fields, compact.""" return request(f"/predictions/overview", query) def get_predictions_markets(**query): """GET /predictions/markets: List prediction markets with odds Query: status, sort, q, page, pageSize, plus fields and compact.""" return request(f"/predictions/markets", query) def get_predictions_markets_by_slug(slug, **query): """GET /predictions/markets/{slug}: One market: outcomes, odds history and recent trades Query: fields, compact.""" return request(f"/predictions/markets/{quote(str(slug), safe='')}", query) def get_predictions_trades(**query): """GET /predictions/trades: Recent prediction-market trades Query: market, action, wallet, page, pageSize, plus fields and compact.""" return request(f"/predictions/trades", query) def get_predictions_wallet_by_address(address, **query): """GET /predictions/wallet/{address}: A wallet's shares and history in prediction markets Query: fields, compact.""" return request(f"/predictions/wallet/{quote(str(address), safe='')}", query) def get_news(**query): """GET /news: Cardano news from tracked sources, deduplicated, newest first Query: source, q, page, pageSize, plus fields and compact.""" return request(f"/news", query) def get_handles(**query): """GET /handles: Search or browse ADA Handles Query: q, sort, kind, page, pageSize, plus fields and compact.""" return request(f"/handles", query) def get_handles_stats(**query): """GET /handles/stats: ADA Handle counts by type and length Query: fields, compact.""" return request(f"/handles/stats", query) def get_handles_resolve_by_name(name, **query): """GET /handles/resolve/{name}: Which address owns a handle Query: fields, compact.""" return request(f"/handles/resolve/{quote(str(name), safe='')}", query) def get_handles_of_by_address(address, **query): """GET /handles/of/{address}: Handles owned by an address or stake key hash Query: fields, compact.""" return request(f"/handles/of/{quote(str(address), safe='')}", query) def get_projects(**query): """GET /projects: Token projects whose teams published links, logo and description (signed or reviewed) Query: fields, compact.""" return request(f"/projects", query) def get_projects_token_by_unit(unit, **query): """GET /projects/token/{unit}: The current published project profile of one token Query: fields, compact.""" return request(f"/projects/token/{quote(str(unit), safe='')}", query) def get_explorer_blocks(**query): """GET /explorer/blocks: Latest blocks Query: limit, before, pool, epoch, plus fields and compact.""" return request(f"/explorer/blocks", query) def get_explorer_blocks_script_budget(**query): """GET /explorer/blocks/script-budget: Plutus script budget per hour: share of the per-block execution-unit limits (memory, steps) used and the share of transactions that ran scripts Query: hours, plus fields and compact.""" return request(f"/explorer/blocks/script-budget", query) def get_explorer_txs(**query): """GET /explorer/txs: Latest transactions Query: limit, before, filter, plus fields and compact.""" return request(f"/explorer/txs", query) def get_explorer_address_by_address_txs(address, **query): """GET /explorer/address/{address}/txs: Transactions of an address Query: limit, before, plus fields and compact.""" return request(f"/explorer/address/{quote(str(address), safe='')}/txs", query) def get_explorer_address_by_address_utxos(address, **query): """GET /explorer/address/{address}/utxos: Unspent outputs at an address Query: fields, compact.""" return request(f"/explorer/address/{quote(str(address), safe='')}/utxos", query) def get_explorer_epochs_by_n(n, **query): """GET /explorer/epochs/{n}: One epoch: dates, blocks, transactions, fees, stake, rewards ('latest' for the current one) Query: fields, compact.""" return request(f"/explorer/epochs/{quote(str(n), safe='')}", query) def get_explorer_network(**query): """GET /explorer/network: Network figures: tip, epoch progress, stake, pools, supply Query: fields, compact.""" return request(f"/explorer/network", query) def get_explorer_asset_by_unit(unit, **query): """GET /explorer/asset/{unit}: On-chain facts of one asset: supply, mints, metadata Query: fields, compact.""" return request(f"/explorer/asset/{quote(str(unit), safe='')}", query) def get_explorer_asset_by_unit_holders(unit, **query): """GET /explorer/asset/{unit}/holders: Holders of an asset by balance Query: page, pageSize, plus fields and compact.""" return request(f"/explorer/asset/{quote(str(unit), safe='')}/holders", query) def get_midnight_overview(**query): """GET /midnight/overview: Midnight (NIGHT): supply, thaw schedule, redemptions and DUST figures Query: fields, compact.""" return request(f"/midnight/overview", query) def get_midnight_supply_history(**query): """GET /midnight/supply/history: NIGHT supply over time Query: days, plus fields and compact.""" return request(f"/midnight/supply/history", query) def get_midnight_thaw_calendar(**query): """GET /midnight/thaw/calendar: When claimed NIGHT thaws Query: bucket, plus fields and compact.""" return request(f"/midnight/thaw/calendar", query) def get_midnight_thaw_wallet_by_address(address, **query): """GET /midnight/thaw/wallet/{address}: A wallet's NIGHT allocation and thaw schedule Query: fields, compact.""" return request(f"/midnight/thaw/wallet/{quote(str(address), safe='')}", query) def get_midnight_redemptions(**query): """GET /midnight/redemptions: Recent NIGHT redemptions Query: limit, kind, cursor, plus fields and compact.""" return request(f"/midnight/redemptions", query) def get_midnight_dust_stats(**query): """GET /midnight/dust/stats: DUST address registrations: counts, daily series, latest Query: fields, compact.""" return request(f"/midnight/dust/stats", query) def get_midnight_dust_status_by_address(address, **query): """GET /midnight/dust/status/{address}: DUST registration status of a Cardano stake address Query: fields, compact.""" return request(f"/midnight/dust/status/{quote(str(address), safe='')}", query) def get_midnight_allocations(**query): """GET /midnight/allocations: NIGHT allocations by group Query: fields, compact.""" return request(f"/midnight/allocations", query) def get_midnight_locations(**query): """GET /midnight/locations: Where NIGHT sits: wallets, exchanges, contracts Query: fields, compact.""" return request(f"/midnight/locations", query) def get_midnight_trades_large(**query): """GET /midnight/trades/large: Large NIGHT trades on Cardano DEXes Query: min, limit, days, plus fields and compact.""" return request(f"/midnight/trades/large", query) def get_midnight_network(**query): """GET /midnight/network: Midnight chain status Query: fields, compact.""" return request(f"/midnight/network", query) def get_midnight_blocks(**query): """GET /midnight/blocks: Latest Midnight blocks Query: limit, before, nonEmpty, plus fields and compact.""" return request(f"/midnight/blocks", query) def get_midnight_blocks_by_id(id, **query): """GET /midnight/blocks/{id}: One Midnight block by height or hash Query: fields, compact.""" return request(f"/midnight/blocks/{quote(str(id), safe='')}", query) def get_midnight_txs(**query): """GET /midnight/txs: Latest Midnight transactions Query: limit, before, contract, contracts, plus fields and compact.""" return request(f"/midnight/txs", query) def get_midnight_txs_by_hash(hash, **query): """GET /midnight/txs/{hash}: One Midnight transaction Query: fields, compact.""" return request(f"/midnight/txs/{quote(str(hash), safe='')}", query) def get_midnight_contracts(**query): """GET /midnight/contracts: Most active Midnight contracts Query: limit, sort, days, plus fields and compact.""" return request(f"/midnight/contracts", query) def get_midnight_contracts_by_address(address, **query): """GET /midnight/contracts/{address}: One Midnight contract and its recent actions Query: fields, compact.""" return request(f"/midnight/contracts/{quote(str(address), safe='')}", query) def get_midnight_search(**query): """GET /midnight/search: Classify a Midnight id (height, hash, contract, DUST address) Query: q, plus fields and compact.""" return request(f"/midnight/search", query) def get_alerts(**query): """GET /alerts: Alert rules of the key's account (needs an x-api-key). Also: POST creates a rule {kind, params, webhookUrl?, targetIds?, cooldownSecs?} (same kinds as the site; webhookUrl makes a signed-webhook target and answers its secret once), PATCH /alerts/{id} changes one, DELETE /alerts/{id} removes it, POST /alerts/test {targetId | ruleId} sends a signed test message (v1 is otherwise read-only) Query: fields, compact.""" return request(f"/alerts", query) def get_alerts_targets(**query): """GET /alerts/targets: Delivery targets of the key's account (needs an x-api-key); POST {url, label?} adds a signed webhook (public https only) and returns its HMAC secret once Query: fields, compact.""" return request(f"/alerts/targets", query) def get_alerts_deliveries(**query): """GET /alerts/deliveries: Delivery log of the key's account (needs an x-api-key): status, attempts, HTTP status and error per delivery, newest first Query: limit, before, plus fields and compact.""" return request(f"/alerts/deliveries", query) def get_explorer_certificates(**query): """GET /explorer/certificates: Stake, pool and DRep certificates, newest first (kind: stake_registration | stake_deregistration | delegation | vote_delegation | pool_registration | pool_retirement | drep_registration | drep_update | drep_retirement) Query: kind, limit, before, plus fields and compact.""" return request(f"/explorer/certificates", query) def get_explorer_tx_by_hash_cbor(hash, **query): """GET /explorer/tx/{hash}/cbor: Raw transaction CBOR as hex (add download=1 for a .cbor file) Query: download, plus fields and compact.""" return request(f"/explorer/tx/{quote(str(hash), safe='')}/cbor", query) def get_explorer_inspect(**query): """GET /explorer/inspect: Decode a pasted address (network, payment and stake credentials), Plutus datum (CBOR hex to JSON) or transaction (CBOR hex to summary); POST {input, kind?} for large inputs (64 KB) Query: input, kind, plus fields and compact.""" return request(f"/explorer/inspect", query) def get_staking_tokens(**query): """GET /staking/tokens: Token staking programs (Iagon IAG, Indigo INDY, Minswap farms): TVL, stakers and 24 h / 7 d change of the staked amount Query: fields, compact.""" return request(f"/staking/tokens", query) def get_staking_tokens_by_unit(unit, **query): """GET /staking/tokens/{unit}: One token staking program: top stakers, size distribution, 7 / 30 day inflows and outflows, lock states, daily history Query: fields, compact.""" return request(f"/staking/tokens/{quote(str(unit), safe='')}", query) def get_export_usage(**query): """GET /export/usage: Your key's export usage: requests, rows and bytes per UTC day and dataset over the last 30 days (needs an x-api-key) Query: fields, compact.""" return request(f"/export/usage", query) def get_export_wallets(**query): """GET /export/wallets: Batch lookup: value, token count and trading profit and loss of up to 100 wallets in one call with a Data plan (5 without), in the order asked. Each ref costs what one wallet profit-and-loss call costs: a request of the key's daily quota, then 5 credits; without a key (or with neither left) one of the per-IP tokens for expensive calls. A bad ref, or one that could not be paid for, is answered { ref, ok: false, error } without failing the batch Query: refs, plus fields and compact.""" return request(f"/export/wallets", query) def get_export_files(**query): """GET /export/files: Dataset files (Parquet and csv.gz, nightly deltas and snapshots, weekly full files and the bundle) with what the caller may download: samples are free, delta and snapshot files need a Data plan (Data Pro for the derived datasets), full files and the bundle need Data Pro or the one-time archive. Newest first per dataset Query: dataset, kind, limit, plus fields and compact.""" return request(f"/export/files", query) def get_export_files_by_id_url(id, **query): """GET /export/files/{id}/url: A download link for one file, valid for one hour (a signed /api/export/dl/ link, or a presigned mirror link). Counts one request against the key. The link needs no key and supports Range requests Query: fields, compact.""" return request(f"/export/files/{quote(str(id), safe='')}/url", query) def get_export_me(**query): """GET /export/me: The buyer dashboard in one answer (session or API key): plan and expiry, the presented key's tier and use today, the archive grant, export usage per dataset over 30 days, the last 50 file downloads, open streams against the allowance, and links Query: fields, compact.""" return request(f"/export/me", query) def get_export_by_dataset(dataset, **query): """GET /export/{dataset}: One page of a dataset (a whole table with a cursor): swaps, candles, pools, pool_states, liquidity_ops, tokens, token_stats, nft_sales, nft_listings, nft_collections, stake_pools, stake_pool_epochs, address_labels, leaderboard, hot_wallets. Without a plan the answer is the free sample described in the data dictionary on /data, 1,000 rows a page; with Data the full history, up to 10,000 rows a page. format=ndjson and format=csv answer rows only; every format carries X-Next-Cursor and Link rel=next. Amounts are decimal-adjusted (ADA in ADA, tokens by their decimals) Query: after, limit, since, until, format, pool, dex, unit, status, type, policy, marketplace, category, window, plus fields and compact.""" return request(f"/export/{quote(str(dataset), safe='')}", query)