Compare the best on‑chain data APIs for trading apps and learn how NFT rarity, pricing, and liquidity metrics are built from raw chain data. This guide explains how blockchain data analytics and rarity tools work under the hood, then shows how teams can reuse trading‑grade token infrastructure—like the Codex on‑chain data API—for NFT analytics instead of building separate pipelines.
Best On‑Chain Data APIs for Trading Apps
For trading‑grade NFT and token analytics, the best on‑chain data APIs for trading apps share three traits:
- They normalize raw blockchain logs into stable entities (tokens, NFTs, trades, wallets).
- They precompute pricing, rarity, and liquidity metrics so your UI doesn’t do heavy math.
- They deliver sub‑second latency and multi‑chain coverage suitable for high‑traffic apps.
Most product teams don’t want to run:
- Custom indexers per chain
- RPC fleets and archival nodes
- Separate ETL jobs for tokens vs NFTs vs prediction markets
Instead, they plug into infrastructure‑grade APIs that already:
- Ingest events across dozens of chains
- Enrich them into canonical models
- Expose trading‑ready metrics via GraphQL/REST
Codex (per its docs, a customer‑supplied/marketing claim) describes this pattern at scale: 80+ networks, 700M+ wallets, and tens of millions of tokens indexed into a single enriched data layer.1
On‑Chain vs Off‑Chain: What NFT Analytics Actually Reads
Before diving into rarity and pricing algorithms, you need a clear view of what is on‑chain and what isn’t.
On‑chain data fields for NFTs
Typical ERC‑721 / ERC‑1155 events and storage give you:
Transferlogs (from,to,tokenId)Mintpatterns (Transfers from zero address)- Contract metadata (name, symbol)
- Ownership and balances (who holds which tokenId)
- Marketplace interactions (sales, listings, offers) when the marketplace is on‑chain
These are immutable once mined, and they form the backbone of:
- Trade history
- Wallet‑level holding and P&L
- Liquidity and turnover metrics
Off‑chain / metadata‑driven fields
Rarity, visual traits, and many pricing signals rely on off‑chain metadata and marketplace APIs:
tokenURIper tokenId- JSON traits (e.g.,
{ "trait_type": "Hat", "value": "Beanie" }) - Image URLs and media
- Off‑chain order books or aggregated listings
These often live on:
- IPFS or similar decentralized storage
- HTTPS endpoints controlled by project teams
- Marketplace APIs (OpenSea, Blur, Magic Eden, etc.)
OpenSea, for instance, reads NFT metadata via tokenURI and applies the OpenRarity rarity standard only to eligible ERC‑721 collections with string traits.2
Normalization challenges
Rarity tools and blockchain analytics platforms must defend against:
- Metadata mutability: creators can update traits and images; OpenSea explicitly warns that rarity rankings may change when metadata changes.2
- Partial reveals: unrevealed items often have placeholder traits; showing rarity early leads to misleading scores.
- IPFS/HTTP failures: tokenURI may be unreachable or rate‑limited.
Best‑practice normalization patterns:
- Snapshot trait state once a collection is fully revealed.
- Cache metadata off‑chain with versioning.
- Flag missing traits and treat them separately in rarity computations.
- Fail soft when tokenURI is unavailable (exclude from rarity rankings or mark as unknown).
How NFT Rarity Is Calculated from Raw Data
Core idea: inverse frequency of traits
Most NFT rarity tools on‑chain converge on a simple principle:
- Traits that appear less often in the collection are rarer.
OpenRarity defines rarity as the relative scarcity of traits within a collection and provides an open, reproducible standard.2
A common inverse‑frequency formula per trait value:
rarity_weight(trait_value) = 1 / (count(trait_value) / total_items)
Where:
total_items= number of NFTs in the collectioncount(trait_value)= number of NFTs with that exact trait value
Example:
- 10,000‑piece collection
- 100 tokens with
Hat = Beanie
frequency = 100 / 10_000 = 0.01
rarity_weight = 1 / 0.01 = 100
Additive vs multiplicative rarity scoring
To get a per‑NFT rarity score, platforms combine trait weights either additively or multiplicatively.
Additive method:
rarity_score(token) = Σ rarity_weight(trait_value_i)
Multiplicative method (more sensitive to single rare traits):
rarity_score(token) = Π rarity_weight(trait_value_i)
In pseudocode (additive, with handling for missing traits):
def rarity_score(token_traits, trait_stats):
score = 0.0
for trait_type, trait_value in token_traits.items():
stats = trait_stats.get((trait_type, trait_value))
if not stats:
# Missing or undefined trait: optionally skip or assign baseline
continue
freq = stats["count"] / stats["total_items"]
weight = 1.0 / freq
score += weight
return score
Jaccard distance & normalization (NFTGo GoRarity)
NFTGo’s GoRarity uses a more statistical approach combining Jaccard distance between trait sets with normalization.3
For two NFTs A and B:
Jaccard(A, B) = |traits(A) ∩ traits(B)| / |traits(A) ∪ traits(B)|
Distance:
distance(A, B) = 1 - Jaccard(A, B)
They then:
- Build a similarity matrix across the collection.
- Use distances to infer how “unusual” each token is.
- Normalize scores across the collection (e.g., min‑max scaling):
normalized_score(token) = (raw_score(token) - min_raw) / (max_raw - min_raw)
Where normalized_score can be mapped to rank or percentile.
Handling partial reveals and ambiguous traits
Robust rarity pipelines:
- Exclude tokens whose metadata is clearly placeholder (
"trait_type": "Hidden"or uniform dummy traits). - Only compute final rarity when the collection is fully revealed (OpenSea recommends this).2
- Treat missing traits explicitly (e.g., trait absence can itself be a trait value).
Academic work backs the importance of rarity: a study of 3.7M transactions, 1.4M NFTs, and 410 collections found rarer NFTs tend to sell at higher prices, trade less often, and deliver higher ROI.4
NFT Pricing Algorithms from On‑Chain Data
Floor price vs trait‑aware valuation
Most NFT platforms start pricing from the floor price:
- OpenSea defines collection floor as the cheapest active listing, and trait floors as the cheapest active listing for each trait value across aggregated marketplaces.5
Simplified formula:
collection_floor = min(active_listing_prices)
trait_floor(trait_value) = min(active_listing_prices where token has trait_value)
But floor alone is fragile:
- It ignores trait premiums.
- It can be distorted by wash trading or single mispriced listings.
NFTGo’s GoPricing model acknowledges this explicitly: floor is a useful anchor, but a trading‑grade price needs trait premiums and wash‑trade‑filtered historical sales.6
Hybrid pricing model (floor + trait premiums + last sale)
A robust NFT pricing algorithm on‑chain data typically:
- Anchors each collection to a clean floor, filtered for wash trades.
- Learns trait premiums/discounts from historical, non‑wash sales.
- Uses 7‑day median price as a stabilizer for liquid collections.
NFTGo, for ERC‑721 collections, defines estimated value as:7
- High‑liquidity:
estimated_value = max(floor_price, 7D_median_sale_price) - Low‑liquidity:
estimated_value = floor_price
Pseudocode for per‑token valuation:
def estimate_nft_value(collection_floor, trait_premiums, token_traits, last_sale=None):
base = collection_floor
# Add trait premiums (could be additive or multiplicative)
premium_factor = 1.0
for trait_type, trait_value in token_traits.items():
premium_factor *= trait_premiums.get((trait_type, trait_value), 1.0)
value_from_floor = base * premium_factor
# Optionally blend last sale if recent and non-wash
if last_sale and not last_sale["is_wash"]:
# Time decay factor could be applied here
return max(value_from_floor, last_sale["price"])
return value_from_floor
Wash trading detection heuristics
Wash trading—self‑trading to inflate activity—is a first‑class data quality problem for NFTs.
NFTGo defines wash trades as trades where the buyer and seller are effectively the same actor and explicitly filters suspected wash trades from volume, sales, and marketplace metrics.8
Reproducible heuristics often include:
-
Address relationships:
- Buyer == seller
- Buyer and seller funded by the same root address
- Repeated trading loops among a small cluster of addresses
-
Time & price patterns:
- Many trades of the same token in a short window
- Prices far above/below prevailing market price
-
Distinct counterparty requirements:
- Require minimum number of distinct counterparties per token over a lookback window for trades to be considered organic.
Example rule set:
def is_wash_trade(trade, price_index, funding_graph):
buyer = trade["buyer"]
seller = trade["seller"]
token_id = trade["token_id"]
price = trade["price"]
ts = trade["timestamp"]
# Direct self-trade
if buyer == seller:
return True
# Same funder within 1 hop
if funding_graph.common_funder(buyer, seller):
return True
# Price anomaly: more than 3x collection floor
floor = price_index.collection_floor(token_id.collection)
if price > 3 * floor:
return True
# Rapid flip: same token traded >3 times in 1 hour
if price_index.recent_trades(token_id, window="1h") > 3:
return True
return False
When a trade is flagged as wash:
- Exclude it from volume metrics.
- Exclude it from median/average price calculations.
- Exclude it from trait premium training datasets.
This directly improves:
- NFT floor price calculation on‑chain (reduced artificial spikes)
- Collection market cap estimates
- Wallet P&L accuracy
On‑Chain NFT Liquidity Metrics & Order‑Book Shape
Trading‑grade NFT analytics need more than volume charts; they need on‑chain NFT liquidity metrics and order‑book depth.
Liquidity signals used in practice
OpenSea’s Insights panel exposes three primary views:9
- Sales: historical sales count and volume
- Depth: distribution of active listings across price bands
- Floor: evolution of the cheapest listing over time
NFTGo similarly surfaces:
- Floor depth
- Best offer
- Holder trends
- Trader counts and whale concentration
- Wash‑trade‑filtered sales volume10
Example liquidity metrics and formulas
- Turnover rate:
turnover_30d = sales_30d / supply
- Holder concentration:
top_10_share = (sum holdings of top 10 wallets) / total_supply
- Order‑book depth (at k% above floor):
depth_k = count(listings with price <= floor_price * (1 + k))
- Spread between best offer and floor:
spread = floor_price - best_offer_price
spread_pct = spread / floor_price
These metrics are built from:
- On‑chain marketplace listing and offer events
- Off‑chain listing APIs (when marketplaces are partially off‑chain)
- Enriched wallet holdings and historical trades
Fastest On‑Chain NFT Data API and Latency Considerations
For high‑traffic trading apps, the fastest on‑chain NFT data API is not just about raw node speed—it’s about:
- Pre‑computed aggregates (OHLCV, depth, rarity ranks) near the UI.
- Cache‑friendly GraphQL queries that fetch multiple metrics in one round trip.
- Regional edge deployments to minimize latency to major user clusters.
Latency considerations for NFT trading UIs:
- Sub‑second chart refresh for price, floor, and depth.
- Near real‑time rarity & trait‑floor updates after notable sales.
- Streaming or poll‑based updates for active order books.
Infrastructure‑grade data providers typically:
- Maintain hot indexes for popular collections.
- Pre‑compute time‑bucketed metrics (1m / 5m / 1h) for charts.
- Use columnar stores or time‑series databases for efficient reads.
This is the same architecture used for best real‑time crypto data API trading 2024 style use cases—NFTs just add another entity layer on the same pipeline.
Token Enrichment API for NFTs: Reusing Trading Infrastructure
Codex positions itself as a token enrichment API and unified data layer:
- Raw chain events are ingested across 80+ networks.
- Events are normalized into canonical tokens, wallets, trades, aggregates.1
- Pre‑computed metrics include OHLC, candles, volume, liquidity, TVL‑like stats, holders, and balances.
For product and data teams, the key advantage is that NFT analytics can be built by extending this pattern, not reinventing it.
How Codex’s enrichment pattern generalizes to NFTs
From Codex’s documented enrichment architecture (customer‑supplied/marketing description):1
-
Ingest NFT‑related events:
- NFT mints, transfers, marketplace trades
- Wallet balance changes
-
Normalize into entities:
- NFT collection
- NFT item (tokenId)
- NFT trade (buyer, seller, price, timestamp)
- Wallet holdings
-
Enrich with off‑chain data:
- Trait metadata from tokenURI
- Marketplace listing and offer data
-
Pre‑compute metrics:
- Rarity scores and ranks per tokenId
- Floor and trait floors
- Depth and liquidity metrics
- Wash‑trade‑adjusted volume and prices
-
Expose via one API:
- GraphQL queries or REST endpoints to power trading views, dashboards, wallets, and prediction market UIs.
Because Codex already powers token charting and prediction market analytics, NFT rarity and liquidity become another asset type on the same all‑in‑one pipeline.
Sample Queries: Rarity, Floors, Depth & Wash‑Filtered Volume
Below are example GraphQL‑style query patterns and responses your team might use. Names are illustrative, based on Codex’s documented approach to entities and filters.1
1. Fetch rarity score and rank for an NFT
Query:
query GetNftRarity($collectionAddress: String!, $tokenId: String!) {
nftRarity(collectionAddress: $collectionAddress, tokenId: $tokenId) {
tokenId
rarityScore
rarityRank
rarityPercentile
traits {
traitType
value
frequency
rarityWeight
}
}
}
Response (example):
{
"data": {
"nftRarity": {
"tokenId": "1234",
"rarityScore": 842.3,
"rarityRank": 37,
"rarityPercentile": 0.9963,
"traits": [
{
"traitType": "Hat",
"value": "Beanie",
"frequency": 0.01,
"rarityWeight": 100
},
{
"traitType": "Background",
"value": "Blue",
"frequency": 0.25,
"rarityWeight": 4
}
]
}
}
}
2. Fetch collection trait floors and floor depth
OpenSea exposes trait floors via its API for eligible collections.11 A unified NFT data API can provide similar enriched outputs.
Query:
query GetCollectionLiquidity($collectionAddress: String!) {
collectionLiquidity(collectionAddress: $collectionAddress) {
collectionFloor
bestOffer
floorDepthBands {
bandUpperPct
listingCount
}
traitFloors {
traitType
value
floorPrice
floorDepth
}
}
}
Response (example):
{
"data": {
"collectionLiquidity": {
"collectionFloor": 1.2,
"bestOffer": 1.05,
"floorDepthBands": [
{ "bandUpperPct": 0.05, "listingCount": 42 },
{ "bandUpperPct": 0.10, "listingCount": 87 }
],
"traitFloors": [
{
"traitType": "Hat",
"value": "Beanie",
"floorPrice": 2.4,
"floorDepth": 8
},
{
"traitType": "Background",
"value": "Blue",
"floorPrice": 1.3,
"floorDepth": 55
}
]
}
}
}
3. Fetch wash‑trade‑adjusted volume
Query:
query GetWashAdjustedMetrics($collectionAddress: String!, $window: String!) {
nftCollectionStats(collectionAddress: $collectionAddress, window: $window) {
window
rawVolume
washFilteredVolume
washTradeShare
rawSalesCount
washFilteredSalesCount
}
}
Response (example):
{
"data": {
"nftCollectionStats": {
"window": "7d",
"rawVolume": 1200.5,
"washFilteredVolume": 950.3,
"washTradeShare": 0.208,
"rawSalesCount": 420,
"washFilteredSalesCount": 315
}
}
}
With endpoints like these, your app’s charts and dashboards can consume trading‑ready NFT data the same way they already consume token prices and prediction markets.
On‑Chain Data API Prediction Markets and Codex
Prediction markets add a parallel dimension to trading UIs:
- Events and markets (e.g., “US election 2028”, “BTC above $100k in 2027”).
- Order books and trades on platforms like Polymarket and Kalshi.
- Trader analytics (win rates, exposure, P&L).
Codex documents prediction market endpoints such as filterPredictionEvents, filterPredictionMarkets, and trader stats (customer‑supplied/marketing claims).12
The same enrichment ideas apply:
- Normalize events, markets, orders, and trades.
- Pre‑compute prices, implied probabilities, and volume.
- Expose them via one GraphQL API alongside tokens and NFTs.
This lets teams build:
- Unified trading terminals: tokens + NFTs + prediction markets.
- Cross‑asset analytics: correlation between NFT collections and macro events.
- Wallet views that aggregate exposure across asset types.
Most Reliable On‑Chain Data APIs for Trading Apps
When evaluating the most reliable on‑chain data APIs for trading apps, consider:
-
Data scope & depth
-
Data quality
-
Performance & reliability
- Sub‑second latency and SLA‑backed uptime.
- Battle‑tested with high‑traffic apps (Codex cites Coinbase, TradingView, Uniswap, Magic Eden, Rainbow, MoonPay and others as customers in its marketing).1
-
Developer experience
- Rich docs with entity models and example queries.
- GraphQL or clean REST schemas for tokens, NFTs, and prediction markets.
Codex’s enrichment‑layer thesis matches this pattern, providing a unified Codex on‑chain data API that product teams can use for trading‑grade token, NFT, and prediction market analytics without maintaining separate ingestion stacks.112 You can explore capabilities and docs at codex.io.
Sources
- Codex blog, "On‑chain data API enrichment layer" — describes ingestion across 80+ networks, 700M+ wallets, and enriched tokens/trades/aggregates. https://www.codex.io/blog/on-chain-data-api-enrichment-layer
- OpenSea support, "What is OpenRarity?" — OpenSea adopted the OpenRarity standard for transparent, reproducible rarity rankings. https://support.opensea.io/en/articles/8867099-what-is-openrarity
- NFTGo docs, GoRarity — Jaccard distance + normalization for rarity. https://docs.nftgo.io/docs/nft-rarity
- Schmitt et al., "The Economics of Non-Fungible Tokens", analysis of 3.7M transactions, 1.4M NFTs, 410 collections. https://arxiv.org/abs/2204.10243
- OpenSea docs, trait floors — floor price defined as cheapest current listing; trait floors computed per trait value. https://docs.opensea.io/reference/get_collection_trait_floors
- NFTGo docs, GoPricing — floor‑anchored pricing plus ML‑learned trait premiums. https://docs.nftgo.io/reference/gopricing
- NFTGo docs, collection metrics — ERC‑721 market cap using max(floor, 7D median) for liquid collections. https://docs.nftgo.io/docs/collection-metrics
- NFTGo docs, wash trade filter — defines wash trading and filters it from metrics. https://docs.nftgo.io/docs/wash-trade-filter-1
- OpenSea support, "How do I use the Insights section?" — exposes Sales, Depth, and Floor views plus activity filters. https://support.opensea.io/en/articles/8866982-how-do-i-use-the-insights-section
- NFTGo API introduction — multichain NFT pricing, collection analytics, orders, wallet P&L. https://docs.nftgo.io/reference/introduction
- OpenSea docs, trait floors API reference. https://docs.opensea.io/reference/get_collection_trait_floors
- Codex docs, prediction markets — filterPredictionEvents, filterPredictionMarkets, trader analytics. https://docs.codex.io/prediction-markets
- OpenSea Developer Platform — supports tokens and NFTs across 30 chains. https://docs.opensea.io/



