// Realtap public API client: copy what you need. No dependencies (Node 18+, Bun, Deno or a browser). // Anonymous requests share a per-IP limit; an API key (header x-api-key) raises it: https://realtap.app/developers const BASE = 'https://realtap.app/api/v1'; const KEY: string | undefined = typeof process !== 'undefined' ? process.env.OPENTAP_KEY : undefined; /** every endpoint also accepts fields=a,b.c (keep only those fields) and compact=1 (drop nulls and empty arrays) */ type Query = T & { fields?: string; compact?: 1 | boolean }; async function request(path: string, query: Record = {}, retries = 2): Promise { const qs = new URLSearchParams(); for (const [k, v] of Object.entries(query)) if (v !== undefined) qs.set(k, v === true ? '1' : String(v)); const res = await fetch(BASE + path + (qs.size ? '?' + qs : ''), { headers: KEY ? { 'x-api-key': KEY } : {} }); if (res.status === 429 && retries > 0) { await new Promise((r) => setTimeout(r, (Number(res.headers.get('retry-after')) || 5) * 1000)); return request(path, query, retries - 1); } if (!res.ok) throw new Error(`${res.status} ${await res.text()}`); return (await res.json()) as T; } /** GET /tokens: List tokens */ export const getTokens = (query: Query<{ sort?: string | number; period?: string | number; order?: string | number; quote?: string | number; minLiquidity?: string | number; minHolders?: string | number; q?: string | number; logos?: string | number; page?: string | number; pageSize?: string | number; }> = {}) => request(`/tokens`, query); /** GET /tokens/{unit}: Token detail with pools */ export const getTokensByUnit = (unit: string, query: Query<{ }> = {}) => request(`/tokens/${encodeURIComponent(unit)}`, query); /** GET /tokens/{unit}/candles: OHLCV candles */ export const getTokensByUnitCandles = (unit: string, query: Query<{ interval?: string | number; pool?: string | number; quote?: string | number; from?: string | number; to?: string | number; }> = {}) => request(`/tokens/${encodeURIComponent(unit)}/candles`, query); /** GET /tokens/{unit}/trades: Recent trades of a token */ export const getTokensByUnitTrades = (unit: string, query: Query<{ limit?: string | number; cursor?: string | number; }> = {}) => request(`/tokens/${encodeURIComponent(unit)}/trades`, query); /** GET /tokens/{unit}/holders: Top holders */ export const getTokensByUnitHolders = (unit: string, query: Query<{ }> = {}) => request(`/tokens/${encodeURIComponent(unit)}/holders`, query); /** GET /tokens/{unit}/traders: Top traders of a token, and its buys and sells, over a window */ export const getTokensByUnitTraders = (unit: string, query: Query<{ window?: string | number; limit?: string | number; }> = {}) => request(`/tokens/${encodeURIComponent(unit)}/traders`, query); /** GET /tokens/{unit}/liquidity: Depth within ±2% per pool, liquidity added and removed over a window, net flow per wallet */ export const getTokensByUnitLiquidity = (unit: string, query: Query<{ window?: string | number; }> = {}) => request(`/tokens/${encodeURIComponent(unit)}/liquidity`, query); /** GET /tokens/{unit}/liquidity/events: Add and remove orders of a token's pools, newest first */ export const getTokensByUnitLiquidityEvents = (unit: string, query: Query<{ window?: string | number; limit?: string | number; cursor?: string | number; }> = {}) => request(`/tokens/${encodeURIComponent(unit)}/liquidity/events`, query); /** GET /tokens/{unit}/distribution: How supply is spread over holders, with what the holder list covers */ export const getTokensByUnitDistribution = (unit: string, query: Query<{ }> = {}) => request(`/tokens/${encodeURIComponent(unit)}/distribution`, 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) */ export const getTokensByUnitTransfers = (unit: string, query: Query<{ limit?: string | number; cursor?: string | number; }> = {}) => request(`/tokens/${encodeURIComponent(unit)}/transfers`, 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) */ export const getTokensByUnitHoldersHistory = (unit: string, query: Query<{ days?: string | number; }> = {}) => request(`/tokens/${encodeURIComponent(unit)}/holders/history`, query); /** GET /tokens/{unit}/series/{metric}: Daily liquidity or holder-count history */ export const getTokensByUnitSeriesByMetric = (unit: string, metric: string, query: Query<{ days?: string | number; }> = {}) => request(`/tokens/${encodeURIComponent(unit)}/series/${encodeURIComponent(metric)}`, query); /** GET /pools: List liquidity pools */ export const getPools = (query: Query<{ dex?: string | number; sort?: string | number; page?: string | number; pageSize?: string | number; }> = {}) => request(`/pools`, query); /** GET /pools/{id}: Pool detail */ export const getPoolsById = (id: string, query: Query<{ }> = {}) => request(`/pools/${encodeURIComponent(id)}`, query); /** GET /pools/{id}/candles: Pool OHLCV candles */ export const getPoolsByIdCandles = (id: string, query: Query<{ interval?: string | number; quote?: string | number; }> = {}) => request(`/pools/${encodeURIComponent(id)}/candles`, query); /** GET /pools/{id}/trades: Pool trades */ export const getPoolsByIdTrades = (id: string, query: Query<{ limit?: string | number; cursor?: string | number; }> = {}) => request(`/pools/${encodeURIComponent(id)}/trades`, query); /** GET /wallet/{address}: Wallet portfolio: positions valued in ADA and USD */ export const getWalletByAddress = (address: string, query: Query<{ }> = {}) => request(`/wallet/${encodeURIComponent(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) */ export const getWalletByAddressRelated = (address: string, query: Query<{ limit?: string | number; days?: string | number; contracts?: string | number; }> = {}) => request(`/wallet/${encodeURIComponent(address)}/related`, query); /** GET /wallet/{address}/trades: DEX trades made by a wallet */ export const getWalletByAddressTrades = (address: string, query: Query<{ limit?: string | number; cursor?: string | number; }> = {}) => request(`/wallet/${encodeURIComponent(address)}/trades`, query); /** GET /wallet/{address}/pnl: Realised / unrealised profit and loss (heavy: lower rate limit) */ export const getWalletByAddressPnl = (address: string, query: Query<{ }> = {}) => request(`/wallet/${encodeURIComponent(address)}/pnl`, query); /** GET /wallet/{address}/activity: Trades by weekday and hour (UTC) over the swaps the site holds */ export const getWalletByAddressActivity = (address: string, query: Query<{ }> = {}) => request(`/wallet/${encodeURIComponent(address)}/activity`, query); /** GET /wallet/{address}/liquidity: Liquidity a wallet added and removed, by pool */ export const getWalletByAddressLiquidity = (address: string, query: Query<{ }> = {}) => request(`/wallet/${encodeURIComponent(address)}/liquidity`, query); /** GET /wallet/{address}/risk: Transparent 0-100 wallet risk score with named reasons (a heuristic, not an accusation) */ export const getWalletByAddressRisk = (address: string, query: Query<{ }> = {}) => request(`/wallet/${encodeURIComponent(address)}/risk`, query); /** GET /nft/collections: List NFT collections */ export const getNftCollections = (query: Query<{ page?: string | number; pageSize?: string | number; }> = {}) => request(`/nft/collections`, query); /** GET /nft/collections/{policy}: NFT collection detail */ export const getNftCollectionsByPolicy = (policy: string, query: Query<{ }> = {}) => request(`/nft/collections/${encodeURIComponent(policy)}`, query); /** GET /nft/collections/{policy}/sales: Recent sales of a collection */ export const getNftCollectionsByPolicySales = (policy: string, query: Query<{ limit?: string | number; cursor?: string | number; }> = {}) => request(`/nft/collections/${encodeURIComponent(policy)}/sales`, query); /** GET /nft/collections/{policy}/listings: Active listings of a collection */ export const getNftCollectionsByPolicyListings = (policy: string, query: Query<{ }> = {}) => request(`/nft/collections/${encodeURIComponent(policy)}/listings`, query); /** GET /nft/collections/{policy}/depth: Listing depth: cost to buy the cheapest N listings and the floor after */ export const getNftCollectionsByPolicyDepth = (policy: string, query: Query<{ }> = {}) => request(`/nft/collections/${encodeURIComponent(policy)}/depth`, query); /** GET /nft/collections/{policy}/activity: Per day sales, volume, buyers, sellers and royalties; wallet sizes; top traders */ export const getNftCollectionsByPolicyActivity = (policy: string, query: Query<{ days?: string | number; }> = {}) => request(`/nft/collections/${encodeURIComponent(policy)}/activity`, query); /** GET /nft/collections/{policy}/listing-history: Listings made, sold, withdrawn and open per day, with the floor */ export const getNftCollectionsByPolicyListingHistory = (policy: string, query: Query<{ days?: string | number; }> = {}) => request(`/nft/collections/${encodeURIComponent(policy)}/listing-history`, query); /** GET /nft/collections/{policy}/sales-points: The sales of the window as price points (up to 1,000, newest) */ export const getNftCollectionsByPolicySalesPoints = (policy: string, query: Query<{ days?: string | number; }> = {}) => request(`/nft/collections/${encodeURIComponent(policy)}/sales-points`, query); /** GET /nft/collections/{policy}/trait-prices: Per trait value: listed, floor, sales, average sale */ export const getNftCollectionsByPolicyTraitPrices = (policy: string, query: Query<{ days?: string | number; }> = {}) => request(`/nft/collections/${encodeURIComponent(policy)}/trait-prices`, query); /** GET /nft/collections/{policy}/trades: Sales feed with rarity rank, both wallets and royalty (same-wallet rows left out) */ export const getNftCollectionsByPolicyTrades = (policy: string, query: Query<{ limit?: string | number; cursor?: string | number; }> = {}) => request(`/nft/collections/${encodeURIComponent(policy)}/trades`, query); /** GET /nft/collections/{policy}/wallet-trades: One wallet's entries and exits in a collection */ export const getNftCollectionsByPolicyWalletTrades = (policy: string, query: Query<{ address?: string | number; }> = {}) => request(`/nft/collections/${encodeURIComponent(policy)}/wallet-trades`, query); /** GET /nft/collections/{policy}/concentration: Share of the supply held by the largest holders, where the ledger count is complete */ export const getNftCollectionsByPolicyConcentration = (policy: string, query: Query<{ }> = {}) => request(`/nft/collections/${encodeURIComponent(policy)}/concentration`, query); /** GET /nft/market: The whole NFT market: sales, volume, active wallets, fees and royalties per marketplace */ export const getNftMarket = (query: Query<{ days?: string | number; }> = {}) => request(`/nft/market`, 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 */ export const getNftMarketPulse = (query: Query<{ }> = {}) => request(`/nft/market/pulse`, query); /** GET /explorer/blocks/{id}: Block by hash or height */ export const getExplorerBlocksById = (id: string, query: Query<{ }> = {}) => request(`/explorer/blocks/${encodeURIComponent(id)}`, query); /** GET /explorer/tx/{hash}: Transaction with inputs, outputs and metadata */ export const getExplorerTxByHash = (hash: string, query: Query<{ }> = {}) => request(`/explorer/tx/${encodeURIComponent(hash)}`, query); /** GET /explorer/address/{address}: Address balance and summary */ export const getExplorerAddressByAddress = (address: string, query: Query<{ }> = {}) => request(`/explorer/address/${encodeURIComponent(address)}`, query); /** GET /staking/pools: Stake pools */ export const getStakingPools = (query: Query<{ page?: string | number; pageSize?: string | number; }> = {}) => request(`/staking/pools`, query); /** GET /staking/delegation-tx: Build an unsigned stake-pool and/or DRep delegation transaction (never signed or submitted by Realtap) */ export const getStakingDelegationTx = (query: Query<{ address?: string | number; pool?: string | number; drep?: string | number; }> = {}) => request(`/staking/delegation-tx`, query); /** GET /staking/pools/{id}: Stake pool detail */ export const getStakingPoolsById = (id: string, query: Query<{ }> = {}) => request(`/staking/pools/${encodeURIComponent(id)}`, query); /** GET /aquarium/overview: Aquarium (Iagon / Aquarium network) overview */ export const getAquariumOverview = (query: Query<{ }> = {}) => request(`/aquarium/overview`, query); /** GET /market/overview: Market overview: volume, TVL, DEX shares, gainers, losers, trending */ export const getMarketOverview = (query: Query<{ }> = {}) => request(`/market/overview`, query); /** GET /market/history: The DEX market over time: volume, swaps, makers and trading fees per day (week, month), for all DEXes or one */ export const getMarketHistory = (query: Query<{ range?: string | number; dex?: string | number; }> = {}) => request(`/market/history`, query); /** GET /market/dexes: Every DEX: the last 24 hours, the last 7 and 30 full days, liquidity and fee APR */ export const getMarketDexes = (query: Query<{ }> = {}) => request(`/market/dexes`, query); /** GET /trades: Every settled swap on every DEX, newest first; filter by size for large trades, or by DEX */ export const getTrades = (query: Query<{ window?: string | number; minAda?: string | number; dex?: string | number; limit?: string | number; cursor?: string | number; }> = {}) => request(`/trades`, query); /** GET /swap/quote: Best-route swap quote */ export const getSwapQuote = (query: Query<{ in?: string | number; out?: string | number; amount?: string | number; }> = {}) => request(`/swap/quote`, 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 */ export const getSwapRoute = (query: Query<{ in?: string | number; out?: string | number; amount?: string | number; slippage?: string | number; maxLegs?: string | number; }> = {}) => request(`/swap/route`, query); /** GET /trade/status/{txHash}: Status of the swap orders a transaction placed */ export const getTradeStatusByTxHash = (txHash: string, query: Query<{ }> = {}) => request(`/trade/status/${encodeURIComponent(txHash)}`, query); /** GET /trade/atomic: Direct (atomic) against batched trades per aggregator and DEX, SteelSwap version adoption and partner wallets */ export const getTradeAtomic = (query: Query<{ window?: string | number; }> = {}) => request(`/trade/atomic`, query); /** GET /trade/orders: Open swap orders of a wallet at Minswap V2, SundaeSwap V3 and WingRiders V2 (unspent in the ledger now) */ export const getTradeOrders = (query: Query<{ address?: string | number; }> = {}) => request(`/trade/orders`, query); /** GET /masumi/overview: Masumi: registered AI agent services and the payments through its escrow in the last 30 days */ export const getMasumiOverview = (query: Query<{ }> = {}) => request(`/masumi/overview`, query); /** GET /masumi/agents: AI agent services registered in the Masumi registry, with price, endpoint and the payments each received */ export const getMasumiAgents = (query: Query<{ q?: string | number; kind?: string | number; sort?: string | number; paid?: string | number; status?: string | number; page?: string | number; pageSize?: string | number; }> = {}) => request(`/masumi/agents`, query); /** GET /masumi/agents/{unit}: One registry entry with its latest payments */ export const getMasumiAgentsByUnit = (unit: string, query: Query<{ }> = {}) => request(`/masumi/agents/${encodeURIComponent(unit)}`, query); /** GET /masumi/payments: Payments through the Masumi escrow, newest first */ export const getMasumiPayments = (query: Query<{ agent?: string | number; limit?: string | number; cursor?: string | number; }> = {}) => request(`/masumi/payments`, query); /** GET /programmable: Programmable tokens (CIP-113): the deployment, how far our index reaches, every registered token with its rules in a line */ export const getProgrammable = (query: Query<{ }> = {}) => request(`/programmable`, 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 */ export const getProgrammableTokensById = (id: string, query: Query<{ }> = {}) => request(`/programmable/tokens/${encodeURIComponent(id)}`, query); /** GET /programmable/tokens/{id}/holders: Holders of a programmable token under the standard's contract */ export const getProgrammableTokensByIdHolders = (id: string, query: Query<{ limit?: string | number; }> = {}) => request(`/programmable/tokens/${encodeURIComponent(id)}/holders`, 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 */ export const getProgrammableIssuerById = (id: string, query: Query<{ }> = {}) => request(`/programmable/issuer/${encodeURIComponent(id)}`, query); /** GET /programmable/address/{q}: Programmable balances of an address, stake address or owner credential, with each token's restrictions */ export const getProgrammableAddressByQ = (q: string, query: Query<{ }> = {}) => request(`/programmable/address/${encodeURIComponent(q)}`, 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 */ export const getProgrammableEvents = (query: Query<{ policy?: string | number; kind?: string | number; subject?: string | number; limit?: string | number; before?: string | number; }> = {}) => request(`/programmable/events`, 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" */ export const getProgrammablePreflight = (query: Query<{ unit?: string | number; from?: string | number; to?: string | number; amount?: string | number; }> = {}) => request(`/programmable/preflight`, 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 */ export const getProgrammableSendContext = (query: Query<{ unit?: string | number; owner?: string | number; to?: string | number; }> = {}) => request(`/programmable/send-context`, query); /** GET /tokens/prices: Prices of up to 100 tokens in one request */ export const getTokensPrices = (query: Query<{ units?: string | number; }> = {}) => request(`/tokens/prices`, query); /** GET /tokens/price-change: Change of the ADA price over one or more windows, for up to 100 tokens */ export const getTokensPriceChange = (query: Query<{ units?: string | number; windows?: string | number; }> = {}) => request(`/tokens/price-change`, query); /** GET /explorer/labels: Names of contracts and entities for up to 100 credentials or addresses, each with source and licence */ export const getExplorerLabels = (query: Query<{ items?: string | number; }> = {}) => request(`/explorer/labels`, query); /** GET /explorer/labels/{id}: Name of one contract or entity (null when unknown), with source and licence */ export const getExplorerLabelsById = (id: string, query: Query<{ }> = {}) => request(`/explorer/labels/${encodeURIComponent(id)}`, query); /** GET /explorer/stake/{address}: Stake key: controlled stake, rewards, pool and DRep, addresses */ export const getExplorerStakeByAddress = (address: string, query: Query<{ }> = {}) => request(`/explorer/stake/${encodeURIComponent(address)}`, query); /** GET /explorer/policy/{policy}: Minting policy: its assets, mints in the window, script */ export const getExplorerPolicyByPolicy = (policy: string, query: Query<{ }> = {}) => request(`/explorer/policy/${encodeURIComponent(policy)}`, query); /** GET /explorer/epochs: Epochs with blocks, transactions and fees (exact totals for epochs older than our block index) */ export const getExplorerEpochs = (query: Query<{ }> = {}) => request(`/explorer/epochs`, query); /** GET /explorer/protocol: Current protocol parameters (the ledger's values) and the genesis constants */ export const getExplorerProtocol = (query: Query<{ }> = {}) => request(`/explorer/protocol`, query); /** GET /explorer/history: The chain per UTC day: transactions, fees and block space used, from our own block index */ export const getExplorerHistory = (query: Query<{ range?: string | number; }> = {}) => request(`/explorer/history`, query); /** GET /governance/overview: Governance overview: treasury, DReps, actions by status, committee, rules in force, live actions with tallies */ export const getGovernanceOverview = (query: Query<{ }> = {}) => request(`/governance/overview`, query); /** GET /governance/actions: Governance actions with status, epochs and vote tallies */ export const getGovernanceActions = (query: Query<{ status?: string | number; type?: string | number; q?: string | number; }> = {}) => request(`/governance/actions`, query); /** GET /governance/actions/{id}: One governance action: text, withdrawals, parameter changes, every vote */ export const getGovernanceActionsById = (id: string, query: Query<{ }> = {}) => request(`/governance/actions/${encodeURIComponent(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) */ export const getGovernanceActionsByIdTallyHistory = (id: string, query: Query<{ }> = {}) => request(`/governance/actions/${encodeURIComponent(id)}/tally-history`, query); /** GET /governance/dreps: DReps by voting power, with participation */ export const getGovernanceDreps = (query: Query<{ sort?: string | number; status?: string | number; q?: string | number; page?: string | number; pageSize?: string | number; }> = {}) => request(`/governance/dreps`, query); /** GET /governance/dreps/{id}: One DRep: power, votes, participation, certificates, delegators, power history */ export const getGovernanceDrepsById = (id: string, query: Query<{ }> = {}) => request(`/governance/dreps/${encodeURIComponent(id)}`, query); /** GET /governance/committee: Constitutional committee: members, terms, who appointed them, constitution, committee actions */ export const getGovernanceCommittee = (query: Query<{ }> = {}) => request(`/governance/committee`, query); /** GET /governance/treasury/withdrawals: Treasury withdrawals proposed to governance, paid out per year */ export const getGovernanceTreasuryWithdrawals = (query: Query<{ }> = {}) => request(`/governance/treasury/withdrawals`, query); /** GET /governance/parameters: History of protocol parameter changes since epoch 208, with the governance action behind each */ export const getGovernanceParameters = (query: Query<{ }> = {}) => request(`/governance/parameters`, query); /** GET /claims: Pool and DRep pages their operators have claimed (verified or approved claims only) */ export const getClaims = (query: Query<{ }> = {}) => request(`/claims`, query); /** GET /claims/{kind}/{id}: The claim shown on one pool or DRep page, or null */ export const getClaimsByKindById = (kind: string, id: string, query: Query<{ }> = {}) => request(`/claims/${encodeURIComponent(kind)}/${encodeURIComponent(id)}`, query); /** GET /buybot/info: Telegram buy bot: groups using it, tokens followed, posts in 24 h, and the add-to-group link */ export const getBuybotInfo = (query: Query<{ }> = {}) => request(`/buybot/info`, 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 */ export const getEmbedWidgetBySubjectById = (subject: string, id: string, query: Query<{ }> = {}) => request(`/embed/widget/${encodeURIComponent(subject)}/${encodeURIComponent(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 */ export const getWrappedById = (id: string, query: Query<{ refresh?: string | number; }> = {}) => request(`/wrapped/${encodeURIComponent(id)}`, 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 */ export const getCreditsPacks = (query: Query<{ }> = {}) => request(`/credits/packs`, query); /** GET /credits/me: Your credit balance, today's use, limits and open payment requests (needs an x-api-key) */ export const getCreditsMe = (query: Query<{ }> = {}) => request(`/credits/me`, 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 */ export const getCreditsIntents = (query: Query<{ }> = {}) => request(`/credits/intents`, 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) */ export const getCreditsIntentsById = (id: string, query: Query<{ }> = {}) => request(`/credits/intents/${encodeURIComponent(id)}`, query); /** GET /tokens/{unit}/safety: Safety score of a token: mint policy, holder concentration, liquidity lock, red flags */ export const getTokensByUnitSafety = (unit: string, query: Query<{ }> = {}) => request(`/tokens/${encodeURIComponent(unit)}/safety`, query); /** GET /loans/overview: Fluid loans: totals, rates and the biggest principal assets */ export const getLoansOverview = (query: Query<{ }> = {}) => request(`/loans/overview`, query); /** GET /loans: List loans and loan offers */ export const getLoans = (query: Query<{ status?: string | number; protocol?: string | number; wallet?: string | number; sort?: string | number; page?: string | number; pageSize?: string | number; }> = {}) => request(`/loans`, query); /** GET /loans/wallet/{address}: Loans a wallet borrowed or lent */ export const getLoansWalletByAddress = (address: string, query: Query<{ }> = {}) => request(`/loans/wallet/${encodeURIComponent(address)}`, query); /** GET /loans/token/{unit}: Loans that use a token as principal or collateral, with the lending market rates */ export const getLoansTokenByUnit = (unit: string, query: Query<{ }> = {}) => request(`/loans/token/${encodeURIComponent(unit)}`, query); /** GET /loans/{id}: One loan with its terms, collateral value and liquidation distance */ export const getLoansById = (id: string, query: Query<{ }> = {}) => request(`/loans/${encodeURIComponent(id)}`, query); /** GET /perps/overview: Perpetual futures on Cardano: open interest, volume, funding, vault size, liquidations */ export const getPerpsOverview = (query: Query<{ }> = {}) => request(`/perps/overview`, query); /** GET /perps/markets: Every perp market: mark and index price, funding, open interest, 24 h volume */ export const getPerpsMarkets = (query: Query<{ }> = {}) => request(`/perps/markets`, query); /** GET /perps/positions: Open positions, largest first */ export const getPerpsPositions = (query: Query<{ symbol?: string | number; side?: string | number; wallet?: string | number; minUsd?: string | number; traders?: string | number; sort?: string | number; page?: string | number; pageSize?: string | number; }> = {}) => request(`/perps/positions`, query); /** GET /perps/events: Recent fills: opens, closes, funding and liquidations */ export const getPerpsEvents = (query: Query<{ symbol?: string | number; before?: string | number; }> = {}) => request(`/perps/events`, query); /** GET /perps/liquidations: Liquidated positions */ export const getPerpsLiquidations = (query: Query<{ wallet?: string | number; page?: string | number; pageSize?: string | number; }> = {}) => request(`/perps/liquidations`, query); /** GET /perps/leaderboard: Best traders by volume, PnL or ROI */ export const getPerpsLeaderboard = (query: Query<{ period?: string | number; sort?: string | number; limit?: string | number; offset?: string | number; }> = {}) => request(`/perps/leaderboard`, query); /** GET /perps/custody: What the perps venue holds in custody */ export const getPerpsCustody = (query: Query<{ }> = {}) => request(`/perps/custody`, query); /** GET /perps/transfers: Deposits into and withdrawals out of the venue */ export const getPerpsTransfers = (query: Query<{ kind?: string | number; wallet?: string | number; page?: string | number; pageSize?: string | number; }> = {}) => request(`/perps/transfers`, query); /** GET /perps/wallet/{address}: One wallet on the perps venue: equity, positions, fills */ export const getPerpsWalletByAddress = (address: string, query: Query<{ }> = {}) => request(`/perps/wallet/${encodeURIComponent(address)}`, query); /** GET /defi: Cardano DeFi: total value locked by protocol and category */ export const getDefi = (query: Query<{ }> = {}) => request(`/defi`, query); /** GET /defi/protocols/{id}: One protocol: TVL history, markets and links */ export const getDefiProtocolsById = (id: string, query: Query<{ }> = {}) => request(`/defi/protocols/${encodeURIComponent(id)}`, query); /** GET /defi/markets: Lending and staking markets with supply and borrow rates */ export const getDefiMarkets = (query: Query<{ protocol?: string | number; kind?: string | number; }> = {}) => request(`/defi/markets`, query); /** GET /defi/registry: The protocols and stablecoins Realtap tracks, with policy ids */ export const getDefiRegistry = (query: Query<{ }> = {}) => request(`/defi/registry`, query); /** GET /defi/positions/{address}: A wallet's lending, staking and liquidity positions across protocols */ export const getDefiPositionsByAddress = (address: string, query: Query<{ }> = {}) => request(`/defi/positions/${encodeURIComponent(address)}`, query); /** GET /yields: Yield table: LP fee APR, lending rates and staking ROA */ export const getYields = (query: Query<{ minTvl?: string | number; limit?: string | number; }> = {}) => request(`/yields`, query); /** GET /stablecoins: Cardano stablecoins: price, peg deviation, market cap and supply history */ export const getStablecoins = (query: Query<{ }> = {}) => request(`/stablecoins`, query); /** GET /earn: Where could this asset earn the most? Staking, lending, p2p loans and liquidity pools ranked */ export const getEarn = (query: Query<{ asset?: string | number; amount?: string | number; minTvl?: string | number; lpLimit?: string | number; }> = {}) => request(`/earn`, query); /** GET /earn/assets: Assets the earn comparison supports */ export const getEarnAssets = (query: Query<{ }> = {}) => request(`/earn/assets`, query); /** GET /predictions/overview: Prediction markets (Bodega): open markets, volume, biggest movers */ export const getPredictionsOverview = (query: Query<{ }> = {}) => request(`/predictions/overview`, query); /** GET /predictions/markets: List prediction markets with odds */ export const getPredictionsMarkets = (query: Query<{ status?: string | number; sort?: string | number; q?: string | number; page?: string | number; pageSize?: string | number; }> = {}) => request(`/predictions/markets`, query); /** GET /predictions/markets/{slug}: One market: outcomes, odds history and recent trades */ export const getPredictionsMarketsBySlug = (slug: string, query: Query<{ }> = {}) => request(`/predictions/markets/${encodeURIComponent(slug)}`, query); /** GET /predictions/trades: Recent prediction-market trades */ export const getPredictionsTrades = (query: Query<{ market?: string | number; action?: string | number; wallet?: string | number; page?: string | number; pageSize?: string | number; }> = {}) => request(`/predictions/trades`, query); /** GET /predictions/wallet/{address}: A wallet's shares and history in prediction markets */ export const getPredictionsWalletByAddress = (address: string, query: Query<{ }> = {}) => request(`/predictions/wallet/${encodeURIComponent(address)}`, query); /** GET /news: Cardano news from tracked sources, deduplicated, newest first */ export const getNews = (query: Query<{ source?: string | number; q?: string | number; page?: string | number; pageSize?: string | number; }> = {}) => request(`/news`, query); /** GET /handles: Search or browse ADA Handles */ export const getHandles = (query: Query<{ q?: string | number; sort?: string | number; kind?: string | number; page?: string | number; pageSize?: string | number; }> = {}) => request(`/handles`, query); /** GET /handles/stats: ADA Handle counts by type and length */ export const getHandlesStats = (query: Query<{ }> = {}) => request(`/handles/stats`, query); /** GET /handles/resolve/{name}: Which address owns a handle */ export const getHandlesResolveByName = (name: string, query: Query<{ }> = {}) => request(`/handles/resolve/${encodeURIComponent(name)}`, query); /** GET /handles/of/{address}: Handles owned by an address or stake key hash */ export const getHandlesOfByAddress = (address: string, query: Query<{ }> = {}) => request(`/handles/of/${encodeURIComponent(address)}`, query); /** GET /projects: Token projects whose teams published links, logo and description (signed or reviewed) */ export const getProjects = (query: Query<{ }> = {}) => request(`/projects`, query); /** GET /projects/token/{unit}: The current published project profile of one token */ export const getProjectsTokenByUnit = (unit: string, query: Query<{ }> = {}) => request(`/projects/token/${encodeURIComponent(unit)}`, query); /** GET /explorer/blocks: Latest blocks */ export const getExplorerBlocks = (query: Query<{ limit?: string | number; before?: string | number; pool?: string | number; epoch?: string | number; }> = {}) => request(`/explorer/blocks`, 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 */ export const getExplorerBlocksScriptBudget = (query: Query<{ hours?: string | number; }> = {}) => request(`/explorer/blocks/script-budget`, query); /** GET /explorer/txs: Latest transactions */ export const getExplorerTxs = (query: Query<{ limit?: string | number; before?: string | number; filter?: string | number; }> = {}) => request(`/explorer/txs`, query); /** GET /explorer/address/{address}/txs: Transactions of an address */ export const getExplorerAddressByAddressTxs = (address: string, query: Query<{ limit?: string | number; before?: string | number; }> = {}) => request(`/explorer/address/${encodeURIComponent(address)}/txs`, query); /** GET /explorer/address/{address}/utxos: Unspent outputs at an address */ export const getExplorerAddressByAddressUtxos = (address: string, query: Query<{ }> = {}) => request(`/explorer/address/${encodeURIComponent(address)}/utxos`, query); /** GET /explorer/epochs/{n}: One epoch: dates, blocks, transactions, fees, stake, rewards ("latest" for the current one) */ export const getExplorerEpochsByN = (n: string, query: Query<{ }> = {}) => request(`/explorer/epochs/${encodeURIComponent(n)}`, query); /** GET /explorer/network: Network figures: tip, epoch progress, stake, pools, supply */ export const getExplorerNetwork = (query: Query<{ }> = {}) => request(`/explorer/network`, query); /** GET /explorer/asset/{unit}: On-chain facts of one asset: supply, mints, metadata */ export const getExplorerAssetByUnit = (unit: string, query: Query<{ }> = {}) => request(`/explorer/asset/${encodeURIComponent(unit)}`, query); /** GET /explorer/asset/{unit}/holders: Holders of an asset by balance */ export const getExplorerAssetByUnitHolders = (unit: string, query: Query<{ page?: string | number; pageSize?: string | number; }> = {}) => request(`/explorer/asset/${encodeURIComponent(unit)}/holders`, query); /** GET /midnight/overview: Midnight (NIGHT): supply, thaw schedule, redemptions and DUST figures */ export const getMidnightOverview = (query: Query<{ }> = {}) => request(`/midnight/overview`, query); /** GET /midnight/supply/history: NIGHT supply over time */ export const getMidnightSupplyHistory = (query: Query<{ days?: string | number; }> = {}) => request(`/midnight/supply/history`, query); /** GET /midnight/thaw/calendar: When claimed NIGHT thaws */ export const getMidnightThawCalendar = (query: Query<{ bucket?: string | number; }> = {}) => request(`/midnight/thaw/calendar`, query); /** GET /midnight/thaw/wallet/{address}: A wallet's NIGHT allocation and thaw schedule */ export const getMidnightThawWalletByAddress = (address: string, query: Query<{ }> = {}) => request(`/midnight/thaw/wallet/${encodeURIComponent(address)}`, query); /** GET /midnight/redemptions: Recent NIGHT redemptions */ export const getMidnightRedemptions = (query: Query<{ limit?: string | number; kind?: string | number; cursor?: string | number; }> = {}) => request(`/midnight/redemptions`, query); /** GET /midnight/dust/stats: DUST address registrations: counts, daily series, latest */ export const getMidnightDustStats = (query: Query<{ }> = {}) => request(`/midnight/dust/stats`, query); /** GET /midnight/dust/status/{address}: DUST registration status of a Cardano stake address */ export const getMidnightDustStatusByAddress = (address: string, query: Query<{ }> = {}) => request(`/midnight/dust/status/${encodeURIComponent(address)}`, query); /** GET /midnight/allocations: NIGHT allocations by group */ export const getMidnightAllocations = (query: Query<{ }> = {}) => request(`/midnight/allocations`, query); /** GET /midnight/locations: Where NIGHT sits: wallets, exchanges, contracts */ export const getMidnightLocations = (query: Query<{ }> = {}) => request(`/midnight/locations`, query); /** GET /midnight/trades/large: Large NIGHT trades on Cardano DEXes */ export const getMidnightTradesLarge = (query: Query<{ min?: string | number; limit?: string | number; days?: string | number; }> = {}) => request(`/midnight/trades/large`, query); /** GET /midnight/network: Midnight chain status */ export const getMidnightNetwork = (query: Query<{ }> = {}) => request(`/midnight/network`, query); /** GET /midnight/blocks: Latest Midnight blocks */ export const getMidnightBlocks = (query: Query<{ limit?: string | number; before?: string | number; nonEmpty?: string | number; }> = {}) => request(`/midnight/blocks`, query); /** GET /midnight/blocks/{id}: One Midnight block by height or hash */ export const getMidnightBlocksById = (id: string, query: Query<{ }> = {}) => request(`/midnight/blocks/${encodeURIComponent(id)}`, query); /** GET /midnight/txs: Latest Midnight transactions */ export const getMidnightTxs = (query: Query<{ limit?: string | number; before?: string | number; contract?: string | number; contracts?: string | number; }> = {}) => request(`/midnight/txs`, query); /** GET /midnight/txs/{hash}: One Midnight transaction */ export const getMidnightTxsByHash = (hash: string, query: Query<{ }> = {}) => request(`/midnight/txs/${encodeURIComponent(hash)}`, query); /** GET /midnight/contracts: Most active Midnight contracts */ export const getMidnightContracts = (query: Query<{ limit?: string | number; sort?: string | number; days?: string | number; }> = {}) => request(`/midnight/contracts`, query); /** GET /midnight/contracts/{address}: One Midnight contract and its recent actions */ export const getMidnightContractsByAddress = (address: string, query: Query<{ }> = {}) => request(`/midnight/contracts/${encodeURIComponent(address)}`, query); /** GET /midnight/search: Classify a Midnight id (height, hash, contract, DUST address) */ export const getMidnightSearch = (query: Query<{ q?: string | number; }> = {}) => request(`/midnight/search`, 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) */ export const getAlerts = (query: Query<{ }> = {}) => request(`/alerts`, 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 */ export const getAlertsTargets = (query: Query<{ }> = {}) => request(`/alerts/targets`, 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 */ export const getAlertsDeliveries = (query: Query<{ limit?: string | number; before?: string | number; }> = {}) => request(`/alerts/deliveries`, 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) */ export const getExplorerCertificates = (query: Query<{ kind?: string | number; limit?: string | number; before?: string | number; }> = {}) => request(`/explorer/certificates`, query); /** GET /explorer/tx/{hash}/cbor: Raw transaction CBOR as hex (add download=1 for a .cbor file) */ export const getExplorerTxByHashCbor = (hash: string, query: Query<{ download?: string | number; }> = {}) => request(`/explorer/tx/${encodeURIComponent(hash)}/cbor`, 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) */ export const getExplorerInspect = (query: Query<{ input?: string | number; kind?: string | number; }> = {}) => request(`/explorer/inspect`, 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 */ export const getStakingTokens = (query: Query<{ }> = {}) => request(`/staking/tokens`, query); /** GET /staking/tokens/{unit}: One token staking program: top stakers, size distribution, 7 / 30 day inflows and outflows, lock states, daily history */ export const getStakingTokensByUnit = (unit: string, query: Query<{ }> = {}) => request(`/staking/tokens/${encodeURIComponent(unit)}`, 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) */ export const getExportUsage = (query: Query<{ }> = {}) => request(`/export/usage`, 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 */ export const getExportWallets = (query: Query<{ refs?: string | number; }> = {}) => request(`/export/wallets`, 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 */ export const getExportFiles = (query: Query<{ dataset?: string | number; kind?: string | number; limit?: string | number; }> = {}) => request(`/export/files`, 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 */ export const getExportFilesByIdUrl = (id: string, query: Query<{ }> = {}) => request(`/export/files/${encodeURIComponent(id)}/url`, 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 */ export const getExportMe = (query: Query<{ }> = {}) => request(`/export/me`, 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) */ export const getExportByDataset = (dataset: string, query: Query<{ after?: string | number; limit?: string | number; since?: string | number; until?: string | number; format?: string | number; pool?: string | number; dex?: string | number; unit?: string | number; status?: string | number; type?: string | number; policy?: string | number; marketplace?: string | number; category?: string | number; window?: string | number; }> = {}) => request(`/export/${encodeURIComponent(dataset)}`, query);