If you’re building high‑traffic trading apps or wallets, you’ve probably asked:
How do we A/B test new on‑chain features without building yet another indexer?
This guide walks through how to use a trading‑grade on‑chain data API for trading apps—specifically Codex—to run rapid experiments on:
- New portfolio views and token groupings
- Token‑aware alerts (whale moves, degen lists, risk pings)
- Social and prediction‑market signals in feeds and dashboards
All without shipping new indexers, touching RPCs, or rewriting ETL. We’ll cover architecture, concrete Codex query examples, experimentation wiring, and a 7‑day rollout playbook.
All scale and performance figures from Codex are based on public claims on codex.io and docs as of August 4, 2026.
Why You Should Never Build an Indexer for an Experiment
Most token‑aware experiments die before they ship because they sound like infra projects:
- “We need to index a new DEX for that volume chart.”
- “We should stand up a subgraph for this wallet analytics feature.”
- “Let’s build a pipeline to normalize prediction‑market events.”
That’s fine for core data pipelines, but it’s overkill for experiments where you might kill the feature in two weeks.
Instead, you want to:
- Prototype the feature, not the indexer.
Use a flexible on‑chain data API that already exposes prices, balances, charts, holders, and prediction markets. - Toggle behavior, not infra.
Use feature flags (LaunchDarkly, Statsig, homegrown) to A/B test logic, UI, and alert rules in real time. - Measure, then decide.
Attach metrics (retention, click‑through, trade volume) to each experiment and keep only what works.
Codex exists exactly for this: a single, enriched data layer powering experiments for products at Coinbase, TradingView, Uniswap, Magic Eden, Rainbow, and others (customers).
Choosing the Best On‑Chain Data API for Trading Apps
If you want fast experiments, your data layer must be boringly reliable. Here’s what “best on‑chain data APIs for trading apps” usually means in practice:
- Latency & throughput.
Codex’s compare page claims ~1s data availability vs 3–10s for Moralis and 1000+ RPS vs ~150 RPS (Codex compare, Aug 2026). - Coverage.
Codex reports 76M+ tokens, 80+ networks, and 700M+ wallets (Codex homepage, Aug 2026). - Enriched schema.
Trading‑ready prices, OHLC candles, holders, liquidity, and prediction markets in one normalized GraphQL‑style API. - Real‑time surfaces.
Subscriptions and webhooks for price moves, trades, launchpad events, and prediction‑market changes (Codex docs).
A quick comparison across popular crypto data APIs for high‑traffic trading apps:
| Provider | Focus | Chains* | Strengths | |-------------|----------------------------------------|-----------------|----------------------------------------------------| | Codex | Trading‑grade token & prediction data | 80+ | Latency, enriched schema, webhooks, prediction mkts| | The Graph | Custom subgraphs / substreams | 60+ (The Graph) | Custom indexing, streaming | | Covalent | Unified Web3 data | 100+ (Covalent) | Broad coverage, verified data | | Moralis | Web3 API + streams | 20+ major chains | Events, NFTs, balances |
*Chain counts from respective sites as of Aug 4, 2026.
If your priority is fast A/B tests on on‑chain features without new indexers, Codex’s combination of speed, coverage, and enriched objects (tokens, wallets, prediction markets) makes it a strong fit.
Architecture: Experiments Layered on a Flexible Data Layer
A modern on‑chain experimentation stack for trading apps typically looks like this:
- Codex (data layer).
- Normalized tokens, wallets, charts, prediction markets.
- Unified GraphQL‑style API across 80+ networks.
- Queries, subscriptions, and webhooks.
- Feature‑flag / experimentation platform.
- LaunchDarkly, Statsig, or your own.
- Toggle features and variations in real time, log exposures, run A/B or A/B/n (Statsig docs).
- Application & UI.
- React/Vue frontend or mobile app.
- Backend or BFF that calls Codex with experiment‑specific params.
- Metrics & analytics.
- Product analytics (Amplitude, Mixpanel, internal).
- Trading metrics (order volume, P&L, engagement, retention).
Your experiments change how you query Codex and render responses, not how you ingest on‑chain data.
Copy‑Pasteable Codex Query Examples
Below are concrete examples you can drop into prototypes for portfolios, charts, and aggregates. For full details see Codex docs.
1) Wallet & Balances Query
Use this to power a cross‑chain portfolio view experiment.
# POST https://api.codex.io/graphql
query WalletPortfolio($wallet: String!) {
wallet(address: $wallet) {
address
chains {
chainId
tokens {
address
symbol
name
balance
balanceUsd
priceUsd
priceChange24h
}
}
}
}
You can A/B test:
- Control: sort tokens by balanceUsd.
- Variant: sort by 24h performance or risk score.
2) Chart / Candle Data Query
Use this to prototype alternative chart views or time ranges.
# POST https://api.codex.io/graphql
query TokenCandles($token: String!, $chainId: Int!) {
token(address: $token, chainId: $chainId) {
address
symbol
candles(resolution: "1h", window: "7d") {
openTime
open
high
low
close
volume
}
}
}
Experiment ideas:
- 1‑minute vs 5‑minute candles for power users.
- Adding volume overlays only for variant users.
3) Aggregated Liquidity & Volume Query
Use this for dashboards and lists of trending tokens.
query TrendingTokens($chainId: Int!) {
tokens(chainId: $chainId, orderBy: VOLUME_24H_DESC, limit: 20) {
address
symbol
name
priceUsd
volume24h
liquidityUsd
uniqueWallets24h
}
}
You can test ranking logic by changing:
orderBy: VOLUME_24H_DESC→orderBy: UNIQUE_WALLETS_24H_DESC.- Or mix factors in your application code (e.g., custom “momentum score”).
Real‑Time Webhooks, Subscriptions & Token‑Aware Alerts
For token‑aware alerts API use cases—like whale moves, price spikes, or risky token flags—you don’t want to poll. You want real‑time on‑chain data API behavior, wired into your experiment flags.
Codex supports subscriptions and webhooks for tokens, trades, launchpads, and prediction markets (subscriptions docs, webhooks docs).
Example Webhook Subscription: Price Spike Alert
Pseudo‑request to create an alert on a 10% 5‑minute move:
POST /webhooks
Content-Type: application/json
Authorization: Bearer CODEx_API_KEY
{
"type": "token_price_window",
"chainId": 1,
"tokenAddress": "0xToken...",
"window": "5m",
"thresholdPct": 10,
"direction": "up",
"callbackUrl": "https://your-app.com/webhooks/price-spike",
"metadata": {
"experiment": "price_alert_v1",
"variant": "B"
}
}
Example webhook payload you’ll receive:
{
"event": "token_price_window.triggered",
"chainId": 1,
"tokenAddress": "0xToken...",
"window": "5m",
"priceChangePct": 12.4,
"priceStart": 1.02,
"priceEnd": 1.148,
"triggeredAt": "2026-08-04T12:00:03Z",
"metadata": {
"experiment": "price_alert_v1",
"variant": "B"
}
}
With feature flags, you can:
- Send alerts only for variant B users.
- Test different thresholds or time windows attached to different variants.
- Measure downstream behavior (opens, trades, retention).
These on‑chain data webhooks for alerts and experiments let you test full notification pipelines without new infra.
Prediction Market APIs & Frontend Real‑Time Data
Prediction markets are increasingly important signals for trading apps, social products, and research tools. Codex exposes prediction market APIs with frontend‑ready real‑time data across Polymarket and Kalshi (currently in beta as of Aug 2026) (Codex prediction market docs).
You can fetch events, markets, outcomes, trades, and trader analytics from one API.
Example Query: Active Prediction Markets for a Topic
query ElectionMarkets {
predictionEvents(filter: { search: "election", activeOnly: true }) {
id
title
platform # e.g., POLYMARKET, KALSHI
markets {
id
question
volume24h
outcomes {
id
name
price
impliedProbability
}
}
}
}
Use this in experiments like:
- A “Market‑Implied Odds” widget next to token charts.
- Social feeds that show top‑moving markets alongside on‑chain sentiment.
- Trader leaderboards that rank users by prediction‑market P&L instead of just on‑chain P&L.
Because Codex prediction market data is served via the same GraphQL‑style interface, you don’t need new indexers for these experiments—just new queries and UI.
7‑Day Playbook: A/B Test an On‑Chain Feature Without Shipping an Indexer
Below is a concrete 7‑day rollout plan to test a new cross‑chain portfolio view powered by Codex. You can adapt it for alerts, social signals, or prediction‑market widgets.
Day 1: Define the Experiment & Metrics
- Feature idea.
Example: new “Smart Portfolio” tab that:- Aggregates balances across chains.
- Groups tokens by risk bucket.
- Shows 7‑day P&L and prediction‑market sentiment.
- Hypothesis.
Users with Smart Portfolio enabled check the app more often and trade more. - Primary metrics.
- Portfolio views per user.
- Trades per user.
- Retention (D7, D30, depending on your horizon).
- Guardrail metrics.
- Error rate on portfolio endpoint.
- Latency P95.
- Alert delivery failures (if applicable).
Day 2: Wire Codex as the Data Layer
- Get an API key and run sample queries from Codex docs.
- Implement a backend BFF endpoint, e.g.
/api/portfolio, that:- Resolves the user’s primary wallet.
- Calls
wallet+tokensqueries like the ones above. - Applies a small server‑side aggregation layer (grouping, sorting).
- Ensure you log:
- Codex latency per call.
- Error codes.
- User, chain, and feature flag variant.
Day 3: Wire Feature Flags and Codex Queries
Restore the flag‑driven behavior you want to test. If you use Statsig or LaunchDarkly, you can treat this as a standard UI/API experiment (Statsig, LaunchDarkly).
Sample Feature‑Flag Toggle (Node.js / TypeScript)
import { getFeatureFlagVariant } from "./flags"; // your wrapper
import { queryCodex } from "./codexClient";
export async function getPortfolio(req, res) {
const userId = req.user.id;
const wallet = req.user.walletAddress;
const variant = await getFeatureFlagVariant("smart_portfolio_v1", userId);
const baseQuery = {
query: `
query WalletPortfolio($wallet: String!) {
wallet(address: $wallet) {
address
chains {
chainId
tokens {
address
symbol
name
balance
balanceUsd
priceUsd
priceChange24h
}
}
}
}
`,
variables: { wallet },
};
const data = await queryCodex(baseQuery);
if (variant === "control") {
// simple sort by USD balance
const portfolio = sortByBalanceUsd(data);
return res.json({ variant, portfolio });
}
if (variant === "smart") {
// experimental aggregation logic
const annotated = addRiskBuckets(data); // e.g., blue chip, long-tail, memecoins
const grouped = groupByRisk(annotated);
return res.json({ variant, portfolio: grouped });
}
// fallback
return res.json({ variant: "fallback", portfolio: sortByBalanceUsd(data) });
}
Key point: the only difference between variants is how you process and present Codex responses. No new indexers, no new subgraphs.
Day 4: Implement Real‑Time Alerts (Optional)
If your experiment includes alerts:
- Add Codex webhooks for price windows or whale trades.
- Tag each webhook with
metadata.variantso you can attribute behavior. - Use your flag system to:
- Turn alerts on only for variant B.
- Adjust thresholds per variant (e.g., 5% vs 10% spikes).
Measure:
- Notification send rate and open rate.
- Downstream activity (trades, app opens).
- Churn or opt‑out behavior.
Day 5: Roll Out to a Small Cohort
- Start with 5–10% of eligible users.
- Randomly assign to
controlvssmart(or multiple variants). - Monitor:
- Latency P95/P99 for Codex calls.
- Error rates (timeouts, 4xx/5xx from Codex and your backend).
- Any UX regressions.
If metrics look healthy, gradually increase traffic to 25–50%.
Day 6: Analyze & Iterate
Pull early stats:
- Compare portfolio views/user and trades/user between variants.
- Check if the experiment impacts wallet connect or deposit rates.
- Look for correlations with specific chains or token types (e.g., memecoin heavy wallets).
Iterate quickly by:
- Changing sorting, grouping, or filters directly in your app logic.
- Tweaking Codex query params (e.g., time windows for P&L).
- Updating alert thresholds in webhook config.
All of this happens without touching indexers, ABIs, or start blocks.
Day 7: Decide & Productionize
Once you have enough data (for some apps, a week; for others, a few weeks):
- Ship or kill.
- If the smart portfolio boosts engagement and trading with acceptable latency, ship as default.
- If not, turn off the flag and move on.
- Harden the implementation.
- Add caching where needed.
- Set tighter timeouts and retries for Codex calls.
- Add observability (dashboards, alerts) around Codex metrics.
- Add new experiments.
- Smart alerts.
- Social signals (top wallet moves, prediction‑market odds).
- Token discovery surfaces grouped by launchpads or risk scores.
Your team now has a repeatable pattern for A/B testing on‑chain features without shipping new indexers.
When Query Changes Aren’t Enough (Limitations & Edge Cases)
There are real limits to what you can do without new indexing logic. You should reach for custom indexers or subgraphs when:
- You need deep protocol‑specific state that isn’t in Codex’s schema yet.
- You require custom aggregation logic that’s too heavy or specialized for the API.
- You’re dealing with very new or exotic chains that Codex doesn’t support (see network list).
Other considerations:
- Eventual consistency.
Codex is designed for sub‑second availability (compare page), but on congested chains or exotic DEXes, there may be small propagation delays (seconds). - Read‑only or limited chains.
Some networks may have partial coverage (e.g., no NFT or launchpad data yet). Always check the per‑network capabilities in the docs. - Pricing & rate limits.
- Publicly, Codex offers a free tier and paid plans; enterprise plans can handle 1000+ RPS (compare).
- Exact rate limits and pricing are contract‑specific; contact Codex for current tiers.
For experiments, this still means you can prototype most token‑aware features directly against Codex, and only build custom indexers when something becomes a proven, high‑value core feature.
FAQ: Running A/B Tests on On‑Chain Features with Data APIs
What are the best on‑chain data APIs for trading apps?
For trading‑adjacent use cases that need low latency and enriched token data, strong options include:
- Codex for trading‑grade token and prediction‑market data (prices, charts, holders, wallets, launchpads, prediction markets) across 80+ networks, 76M+ tokens, 700M+ wallets (Codex, Aug 2026).
- Covalent for broad multi‑chain coverage with a unified schema (Covalent).
- The Graph when you need highly custom indexing logic (The Graph).
If your priority is fast experiments without new indexers, Codex’s enriched schema and webhooks make it particularly well‑suited.
How to run A/B tests on blockchain features without shipping new indexers?
You can run A/B tests on blockchain features by:
- Using a multi‑chain on‑chain data API like Codex as your data layer.
- Implementing feature flags (LaunchDarkly, Statsig, or custom) to control who sees each variant.
- Changing query parameters and aggregation logic per variant rather than building new indexers.
- Logging exposures and outcomes to evaluate which variant wins.
This lets you test portfolios, alerts, and social signals in days instead of infra sprints.
How fresh is Codex data and what is the consistency model?
Codex publicly claims ~1 second data availability vs 3–10 seconds for some competitors, and 1000+ RPS throughput (Codex compare, Aug 2026). Internally, Codex processes raw chain data in near‑real time and exposes it via a read‑optimized, eventually consistent store.
In practice, most trading‑grade surfaces (prices, candles, volume) are updated within seconds, with rare edge‑case lags on congested networks.
How do I handle rate limits and errors when using an on‑chain data API for experiments?
Best practices:
- Time‑box calls.
Use client‑side and server‑side timeouts; fail fast on slow responses. - Retry with backoff.
For 5xx errors or timeouts, retry a small number of times with exponential backoff. - Graceful degradation.
- Show cached data or a simplified view when Codex is unavailable.
- Fall back to control variant if experimental queries fail.
- Monitor usage.
Track request volume, error rates, and latency so you can upgrade plans or optimize queries before hitting hard limits.
Codex’s production contracts typically include SLAs and custom rate limits; check with their team for the latest documentation.
How do prediction market APIs and frontend real‑time data fit into trading apps?
Prediction market APIs like Codex’s Polymarket and Kalshi integration provide:
- Outcome prices and implied probabilities you can overlay on charts.
- Market lists and volumes for discovery surfaces.
- Trader analytics to power leaderboards and social features.
Frontends can subscribe to changes or poll at short intervals to keep odds and prices current, and you can A/B test whether showing these signals improves engagement or trading.
Summary: Prototype Features, Not Indexers
The most successful product teams in Web3 and fintech treat on‑chain data APIs as a flexible experimentation layer—not as an afterthought.
With Codex you can:
- Ship token‑aware experiments (portfolios, alerts, social signals, prediction odds) in days.
- Use feature flags to control variants and measure impact.
- Avoid building and maintaining new indexers, RPC fleets, and ETL pipelines for every idea.
If you’re serious about rapid iteration on token‑aware features, start by pointing your next experiment at Codex—and leave the indexing pain to them.
