@surf-ai/sdk 1.0.0-alpha.9 → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -16,7 +16,7 @@ SDK 1.0 uses a single direct-auth model.
16
16
  | --- | --- | --- |
17
17
  | `SURF_API_BASE_URL` | `https://api.asksurf.ai/gateway/v1` | Full Surf API base URL |
18
18
  | `SURF_API_KEY` | none | Bearer token used for upstream requests and protected runtime endpoints |
19
- | `PORT` | none | Express server port when `createServer({ port })` is not provided |
19
+ | `BACKEND_PORT` | none | Express server port when `createServer({ port })` is not provided |
20
20
 
21
21
  All upstream SDK requests use:
22
22
 
@@ -140,4 +140,4 @@ exports.users = pgTable('users', {
140
140
  - The runtime no longer mounts `/proxy/*`.
141
141
  - The `@surf-ai/sdk/react` subpath has been removed.
142
142
  - Route modules must export the handler directly with `module.exports = router`.
143
- - `createServer()` requires a port from `options.port` or `process.env.PORT`.
143
+ - `createServer()` requires a port from `options.port` or `process.env.BACKEND_PORT`.
@@ -32,18 +32,15 @@ declare function watchSchema(schemaPath: string, options?: {
32
32
  }): () => void;
33
33
 
34
34
  /**
35
- * @surf-ai/sdk/db — Drizzle ORM + Neon PostgreSQL database helpers.
35
+ * @surf-ai/sdk/db — Database helpers via HTTP proxy to Neon PostgreSQL.
36
36
  *
37
- * Replaces scaffold lib/db.js and db/index.js.
37
+ * All queries go through the Surf API proxy. There is no locally-instantiated
38
+ * Drizzle ORM client — `drizzle-orm/pg-core` is used only to declare the
39
+ * schema; reads and writes go through dbQuery().
38
40
  *
39
41
  * Usage:
40
- * const { db, dbQuery, dbProvision } = require('@surf-ai/sdk/db')
41
- *
42
- * // In a backend route:
43
- * const users = await db.select().from(schema.users)
44
- *
45
- * // Raw SQL:
46
- * const result = await dbQuery('SELECT * FROM users WHERE id = $1', [userId])
42
+ * const { dbQuery } = require('@surf-ai/sdk/db')
43
+ * const { rows } = await dbQuery('SELECT * FROM users WHERE id = $1', [userId])
47
44
  */
48
45
 
49
46
  /**
@@ -58,14 +55,25 @@ declare function dbProvision(): Promise<{
58
55
  }>;
59
56
  /**
60
57
  * Execute a SQL query via db/query.
61
- * Uses pg-proxy driver under the hood — Drizzle ORM calls this automatically.
62
58
  *
63
- * @param options.arrayMode - When true, rows are returned as positional arrays
64
- * instead of objects. Required for Drizzle ORM pg-proxy compatibility.
59
+ * Returns a pg-style result use `result.rows` for the row data:
60
+ * const { rows } = await dbQuery('SELECT * FROM users')
61
+ * const [row] = (await dbQuery('INSERT ... RETURNING *', [...])).rows
62
+ *
63
+ * @param options.arrayMode - When true, each row is a positional array instead
64
+ * of an object keyed by column name. Default false (object rows).
65
65
  */
66
66
  declare function dbQuery(sql: string, params?: any[], options?: {
67
67
  arrayMode?: boolean;
68
- }): Promise<any>;
68
+ }): Promise<{
69
+ rows: any[];
70
+ rowCount?: number;
71
+ fields?: Array<{
72
+ name: string;
73
+ type: string;
74
+ }>;
75
+ truncated?: boolean;
76
+ }>;
69
77
  /**
70
78
  * List tables in the user's database.
71
79
  */
@@ -32,18 +32,15 @@ declare function watchSchema(schemaPath: string, options?: {
32
32
  }): () => void;
33
33
 
34
34
  /**
35
- * @surf-ai/sdk/db — Drizzle ORM + Neon PostgreSQL database helpers.
35
+ * @surf-ai/sdk/db — Database helpers via HTTP proxy to Neon PostgreSQL.
36
36
  *
37
- * Replaces scaffold lib/db.js and db/index.js.
37
+ * All queries go through the Surf API proxy. There is no locally-instantiated
38
+ * Drizzle ORM client — `drizzle-orm/pg-core` is used only to declare the
39
+ * schema; reads and writes go through dbQuery().
38
40
  *
39
41
  * Usage:
40
- * const { db, dbQuery, dbProvision } = require('@surf-ai/sdk/db')
41
- *
42
- * // In a backend route:
43
- * const users = await db.select().from(schema.users)
44
- *
45
- * // Raw SQL:
46
- * const result = await dbQuery('SELECT * FROM users WHERE id = $1', [userId])
42
+ * const { dbQuery } = require('@surf-ai/sdk/db')
43
+ * const { rows } = await dbQuery('SELECT * FROM users WHERE id = $1', [userId])
47
44
  */
48
45
 
49
46
  /**
@@ -58,14 +55,25 @@ declare function dbProvision(): Promise<{
58
55
  }>;
59
56
  /**
60
57
  * Execute a SQL query via db/query.
61
- * Uses pg-proxy driver under the hood — Drizzle ORM calls this automatically.
62
58
  *
63
- * @param options.arrayMode - When true, rows are returned as positional arrays
64
- * instead of objects. Required for Drizzle ORM pg-proxy compatibility.
59
+ * Returns a pg-style result use `result.rows` for the row data:
60
+ * const { rows } = await dbQuery('SELECT * FROM users')
61
+ * const [row] = (await dbQuery('INSERT ... RETURNING *', [...])).rows
62
+ *
63
+ * @param options.arrayMode - When true, each row is a positional array instead
64
+ * of an object keyed by column name. Default false (object rows).
65
65
  */
66
66
  declare function dbQuery(sql: string, params?: any[], options?: {
67
67
  arrayMode?: boolean;
68
- }): Promise<any>;
68
+ }): Promise<{
69
+ rows: any[];
70
+ rowCount?: number;
71
+ fields?: Array<{
72
+ name: string;
73
+ type: string;
74
+ }>;
75
+ truncated?: boolean;
76
+ }>;
69
77
  /**
70
78
  * List tables in the user's database.
71
79
  */
@@ -542,7 +542,7 @@ var exchange = {
542
542
  long_short_ratio: (params) => get("exchange/long-short-ratio", params),
543
543
  /** Returns trading pairs available on an exchange. **Filters:** `type` (`spot`, `swap`, `future`, `option`) or free-text `search`. **Included fields:** pair name, base/quote currencies, market type, active status, and default fee rates. Use the returned `pair` values as the `pair` parameter in other exchange endpoints. */
544
544
  markets: (params) => get("exchange/markets", params),
545
- /** Returns a combined snapshot of perpetual contract data for a pair. **Available fields** (via `fields`): - `funding` — current funding rate, next settlement, mark/index price - `oi` — open interest in contracts and USD Just pass the base pair (e.g. `pair=BTC/USDT`). The `:USDT` swap suffix is added automatically. */
545
+ /** Returns a perpetual futures snapshot for a trading pair: funding rate, open interest, mark/index price. **Available fields** (via `fields`): - `funding` — current funding rate, next settlement, mark/index price - `oi` — open interest in contracts and USD Just pass the base pair (e.g. `pair=BTC/USDT`). The `:USDT` swap suffix is added automatically. */
546
546
  perp: (params) => get("exchange/perp", params),
547
547
  /** Returns the real-time ticker for a trading pair. **Included fields:** last price, bid/ask, 24h high/low, 24h volume, 24h price change. Set `type=swap` to query perpetual contract prices instead of spot. For historical price trends, use `/market/price`. */
548
548
  price: (params) => get("exchange/price", params)
@@ -550,11 +550,11 @@ var exchange = {
550
550
 
551
551
  // src/data/categories/fund.ts
552
552
  var fund = {
553
- /** Returns a fund's **profile metadata**. **Included fields:** X accounts, team members, recent research, invested project count. This does NOT return the list of investments — use `/fund/portfolio` for that. **Lookup:** by UUID (`id`) or name (`q`). Returns 404 if not found. */
553
+ /** Returns a crypto VC fund's full profile: description, jurisdiction, portfolio count, social links, and team members with roles. **Included fields:** X accounts, team members, recent research, invested project count. This does NOT return the list of investments — use `/fund/portfolio` for that. **Lookup:** by UUID (`id`) or name (`q`). Returns 404 if not found. */
554
554
  detail: (params) => get("fund/detail", params),
555
555
  /** Returns investment rounds for a fund's portfolio, sorted by date (newest first). A project may appear multiple times if the fund participated in multiple rounds. **Included fields:** project name, logo, date, raise amount, lead investor status. **Lookup:** by UUID (`id`) or name (`q`). */
556
556
  portfolio: (params) => get("fund/portfolio", params),
557
- /** Returns top-ranked funds by a specified metric. **Available metrics:** `tier` (lower is better), `portfolio_count` (number of invested projects). */
557
+ /** Returns top crypto VC funds ranked by tier or portfolio count. **Available metrics:** `tier` (lower is better), `portfolio_count` (number of invested projects). */
558
558
  ranking: (params) => get("fund/ranking", params)
559
559
  };
560
560
 
@@ -564,15 +564,15 @@ var kalshi = {
564
564
  events: (params) => get("prediction-market/kalshi/events", params),
565
565
  /** Returns Kalshi markets, optionally filtered by `market_ticker`. Each market includes price, volume, and status. **Data refresh:** ~30 minutes */
566
566
  markets: (params) => get("prediction-market/kalshi/markets", params),
567
- /** Returns daily open interest history for a Kalshi market, filtered by `time_range`. **Data refresh:** ~30 minutes */
567
+ /** Daily open interest time series for a Kalshi market. **Data refresh:** ~30 minutes */
568
568
  open_interest: (params) => get("prediction-market/kalshi/open-interest", params),
569
- /** Returns price history for a Kalshi market. **Interval options:** - `interval=1d` daily OHLC from market reports (~30 min delay) - `interval=latest` — real-time price from trades **Data refresh:** ~30 minutes (daily), real-time (latest) */
569
+ /** Historical orderbook snapshots for a Kalshi market. Returns yes-side bid/ask levels. Timestamps in milliseconds, prices in cents. Data refresh: ~5 minutes */
570
+ orderbooks: (params) => get("prediction-market/kalshi/orderbooks", params),
571
+ /** Price time series for a Kalshi market with daily or hourly OHLC data, or latest price from recent trades. **Data refresh:** ~30 minutes */
570
572
  prices: (params) => get("prediction-market/kalshi/prices", params),
571
- /** Returns top-ranked Kalshi markets by last day's `notional_volume_usd` or `open_interest`. **Filters:** `status`. **Data refresh:** ~30 minutes */
572
- ranking: (params) => get("prediction-market/kalshi/ranking", params),
573
573
  /** Returns individual trade records for a Kalshi market. **Filters:** `taker_side`, `min_contracts`, and date range. **Sort:** `timestamp` or `num_contracts`. **Data refresh:** real-time */
574
574
  trades: (params) => get("prediction-market/kalshi/trades", params),
575
- /** Returns daily trading volume history for a Kalshi market, filtered by `time_range`. **Data refresh:** ~30 minutes */
575
+ /** Daily trading volume time series for a Kalshi market. **Data refresh:** ~30 minutes */
576
576
  volumes: (params) => get("prediction-market/kalshi/volumes", params)
577
577
  };
578
578
 
@@ -598,17 +598,15 @@ var market = {
598
598
  price: (params) => get("market/price", params),
599
599
  /** Returns a technical indicator for a trading pair on a given exchange and interval. **Modes:** - Set `from`/`to` for time-series - Omit for latest value only **Indicator-specific tuning** via `options` (e.g. `period:7`, `fast_period:8,slow_period:21,signal_period:5`, `period:10,stddev:1.5`). **Available indicators:** `rsi`, `macd`, `ema`, `sma`, `bbands`, `stoch`, `adx`, `atr`, `cci`, `obv`, `vwap`, `dmi`, `ichimoku`, `supertrend`. */
600
600
  price_indicator: (params) => get("market/price-indicator", params),
601
- /** Returns tokens ranked by a specified metric. **Available metrics:** `market_cap`, `top_gainers`, `top_losers`, `volume`. **Note:** `top_gainers` and `top_losers` rank by 24h price change within the top 250 coins by market cap. For circulating supply, FDV, ATH/ATL, use `/project/detail?fields=token_info`. */
601
+ /** Returns a token leaderboard sorted by market cap, 24h change, or volume. Each entry includes price, market cap, FDV, supply, ATH/ATL, and 24h range. Supports category filtering (MEME, AI, L1, L2, DEFI, GAMING, etc.). **Available metrics:** `market_cap`, `top_gainers`, `top_losers`, `volume`. **Note:** `top_gainers` and `top_losers` rank by 24h price change within the top 250 coins by market cap. For circulating supply, FDV, ATH/ATL, use `/project/detail?fields=token_info`. */
602
602
  ranking: (params) => get("market/ranking", params)
603
603
  };
604
604
 
605
605
  // src/data/categories/matching.ts
606
606
  var matching = {
607
- /** Returns daily volume and open interest comparison for a specific matched market pair. Both `polymarket_condition_id` and `kalshi_market_ticker` are required. **Volume units:** Polymarket = USD, Kalshi = contracts. */
607
+ /** Returns daily volume and open interest comparison for a specific Polymarket <> Kalshi matched pair. Both `polymarket_condition_id` and `kalshi_market_ticker` are required. Use `matching-market-pairs` to discover matched pairs first. **Volume units:** Polymarket = USD, Kalshi = contracts. */
608
608
  market_daily: (params) => get("prediction-market/matching/daily", params),
609
- /** Given a Polymarket condition_id or Kalshi market_ticker, find the corresponding match on the other platform. Provide at least one of `polymarket_condition_id` or `kalshi_market_ticker`. When both are provided, results are filtered to pairs matching both (useful for verifying a specific pair). */
610
- market_find: (params) => get("prediction-market/matching/find", params),
611
- /** Returns one-to-one matched market pairs between Polymarket and Kalshi. Each pair maps a Polymarket condition_id to a Kalshi market_ticker with a confidence score. **Volume units differ:** Polymarket = USD, Kalshi = contracts ($1 binary options). **Data refresh:** seed-driven, updated periodically. */
609
+ /** Cross-platform prediction market pair matcher — finds the same event listed on both Polymarket and Kalshi, with live price spread data. This is prediction-market only (Polymarket and Kalshi). For crypto exchange markets, use `exchange-markets`. Filter by category, match type, confidence score, or look up a specific market's cross-platform counterpart via `polymarket_condition_id` or `kalshi_market_ticker`. Each pair includes current prices and spread percentage for arbitrage analysis. Sort by `spread_pct` to find the widest spreads. **Data refresh:** ~5 minutes */
612
610
  market_pairs: (params) => get("prediction-market/matching/pairs", params)
613
611
  };
614
612
 
@@ -628,51 +626,59 @@ var onchain = {
628
626
  gas_price: (params) => get("onchain/gas-price", params),
629
627
  /** Executes a structured JSON query on blockchain data. No raw SQL needed — specify source, fields, filters, sort, and pagination. All tables live in the **agent** database. Use `GET /v1/onchain/schema` to discover available tables and their columns. **Key rules:** - **Source format:** `agent.<table_name>` (e.g. `agent.ethereum_transactions`, `agent.ethereum_dex_trades`) - Max 10,000 rows (default 20), 30s timeout - **Always filter on block_date** — it is the partition key. Without it, queries scan billions of rows and will timeout **Data refresh:** ~24 hours. ## Example ```json { "source": "agent.ethereum_dex_trades", "fields": ["block_time", "project", "token_pair", "amount_usd", "taker"], "filters": [ {"field": "block_date", "op": "gte", "value": "2025-03-01"}, {"field": "project", "op": "eq", "value": "uniswap"}, {"field": "amount_usd", "op": "gte", "value": 100000} ], "sort": [{"field": "amount_usd", "order": "desc"}], "limit": 20 } ``` */
630
628
  structured_query: (body) => post("onchain/query", body),
631
- /** Returns table metadata for all available on-chain databases. **Included fields:** database name, table name, column names, types, and comments. */
629
+ /** Returns the ClickHouse schema catalog (tables, columns, types) for on-chain analytics. Use this to discover available tables before writing SQL with `onchain-sql`. **Included fields:** database name, table name, column names, types, and comments. */
632
630
  schema: () => get("onchain/schema"),
633
631
  /** Executes a raw SQL SELECT query against blockchain data. All tables live in the **agent** database. Use `GET /v1/onchain/schema` to discover available tables and their columns before writing queries. ## Rules - Only SELECT/WITH statements allowed (read-only) - All table references must be database-qualified: `agent.<table_name>` - Max 10,000 rows (default 1,000), 30s timeout - **Always filter on block_date or block_number** — partition key, without it queries will timeout - Avoid `SELECT *` on large tables — specify only the columns you need **Data refresh:** ~24 hours. ## Example ```sql SELECT block_time, token_pair, amount_usd, taker, tx_hash FROM agent.ethereum_dex_trades WHERE block_date >= today() - 7 AND project = 'uniswap' AND amount_usd > 100000 ORDER BY amount_usd DESC LIMIT 20 ``` */
634
632
  sql: (body) => post("onchain/sql", body),
635
633
  /** Returns transaction details by hash. All numeric fields are hex-encoded — use parseInt(hex, 16) to convert. **Supported chains:** `ethereum`, `polygon`, `bsc`, `arbitrum`, `optimism`, `base`, `avalanche`, `fantom`, `linea`, `cyber`. Returns 404 if the transaction is not found. */
636
634
  tx: (params) => get("onchain/tx", params),
637
- /** Returns DeFi yield pools ranked by APY or TVL. Returns the latest snapshot. Filter by protocol. */
635
+ /** Returns individual DeFi yield pools/vaults ranked by APY or TVL, with APY breakdown (base vs reward) and pool contract address. Unlike `project-defi-ranking` which ranks whole protocols, this ranks specific pools within protocols. Filter by protocol name (e.g. `lido`, `aave`). Only pools with TVL >= $100k are included when sorted by APY. */
638
636
  yield_ranking: (params) => get("onchain/yield/ranking", params)
639
637
  };
640
638
 
641
639
  // src/data/categories/polymarket.ts
642
640
  var polymarket = {
643
- /** Returns trade and redemption activity for a Polymarket wallet. **Data refresh:** ~30 minutes */
644
- activity: (params) => get("prediction-market/polymarket/activity", params),
645
641
  /** Returns Polymarket events with nested markets, optionally filtered by `event_slug`. Each event includes aggregated status, volume, and a list of markets with `side_a`/`side_b` outcomes. **Data refresh:** ~30 minutes */
646
642
  events: (params) => get("prediction-market/polymarket/events", params),
643
+ /** Returns a ranked leaderboard of Polymarket traders by realized PnL, volume, or trade count. Sortable by `pnl`, `volume`, or `trade_count`. Each entry includes the wallet address and aggregate trading statistics. **Data refresh:** ~5 minutes. */
644
+ leaderboard: (params) => get("prediction-market/polymarket/leaderboard", params),
647
645
  /** Returns Polymarket markets, optionally filtered by `market_slug`. Each market includes `side_a` and `side_b` outcomes. Current prices are available via `/polymarket/prices` using the `condition_id`. **Data refresh:** ~30 minutes */
648
646
  markets: (params) => get("prediction-market/polymarket/markets", params),
649
- /** Returns daily open interest history for a Polymarket market. **Data refresh:** ~30 minutes */
647
+ /** Daily open interest time series showing total value locked in a Polymarket market. **Data refresh:** ~30 minutes */
650
648
  open_interest: (params) => get("prediction-market/polymarket/open-interest", params),
651
- /** Returns wallet positions on Polymarket markets. **Data refresh:** ~30 minutes */
649
+ /** Historical orderbook snapshots for a Polymarket token. Returns raw bid/ask depth levels. Timestamps in milliseconds. Data refresh: ~5 minutes */
650
+ orderbooks: (params) => get("prediction-market/polymarket/orderbooks", params),
651
+ /** Given a specific wallet address, returns that wallet's open positions on Polymarket markets. This is a single-wallet lookup — you must provide the wallet `address`. **Not what you need?** - To discover top/smart wallets across all of Polymarket, use `polymarket-smart-money` (view=positioning for aggregate signals, view=trades for individual whale trades). - To find top traders by PnL or volume, use `polymarket-leaderboard`. **Data refresh:** ~30 minutes */
652
652
  positions: (params) => get("prediction-market/polymarket/positions", params),
653
- /** Returns aggregated price history for a Polymarket market. Use `interval=latest` for the most recent price snapshot. **Data refresh:** ~30 minutes */
653
+ /** OHLCV candlestick data for charting a Polymarket market — open, high, low, close, volume per candle. Use this for rendering price charts with candlestick or bar visualizations. For simple price time series (one price per interval), use `prices` instead. Data refresh: ~30 minutes */
654
+ price_ohlcv: (params) => get("prediction-market/polymarket/price-ohlcv/{condition_id}", params),
655
+ /** Simple price time series for a Polymarket market — one price point per interval. Use this for tracking price trends over time. For OHLCV candlestick data (open/high/low/close for charting libraries), use `price-ohlcv` instead. **Data refresh:** ~30 minutes */
654
656
  prices: (params) => get("prediction-market/polymarket/prices", params),
655
- /** Returns top-ranked Polymarket markets. **Sort by:** `volume_24h`, `volume_7d`, `open_interest`, or `trade_count`. **Filters:** `status` and `end_before`. **Data refresh:** ~30 minutes */
656
- ranking: (params) => get("prediction-market/polymarket/ranking", params),
657
- /** Returns paginated trade records for a Polymarket market or wallet. **Filters:** `condition_id` (market) or `address` (wallet), plus `outcome_label`, `min_amount`, and date range. At least one of `condition_id` or `address` is required. **Sort:** `newest`, `oldest`, or `largest`. **Data refresh:** ~30 minutes */
657
+ /** Smart wallet analytics for Polymarket markets. view=positioning (default): Aggregate smart wallet direction per market net bullish/bearish signal and conviction. view=trades: Individual $10K+ trades with wallet address, amount, outcome, price, and wallet age. **Data refresh:** ~5 minutes */
658
+ smart_money: (params) => get("prediction-market/polymarket/smart-money", params),
659
+ /** Trade and activity history for a Polymarket market or wallet. Filter by market (condition_id), wallet (address), outcome (Yes/No), minimum trade size, and time range. Use type=redemption for splits/merges/redemptions, type=all for everything. **Data refresh:** ~5 minutes */
658
660
  trades: (params) => get("prediction-market/polymarket/trades", params),
659
- /** Returns trading volume and trade count history for a Polymarket market. **Data refresh:** ~30 minutes */
661
+ /** Volume split by YES/NO outcome sides per interval (hour/day/week), plus total volume and trade count. Use this to see directional volume bias. For aggregate volume without YES/NO breakdown, use `volumes` instead. Data refresh: ~30 minutes */
662
+ volume_split: (params) => get("prediction-market/polymarket/volume-split/{condition_id}", params),
663
+ /** Aggregate trading volume (USD) and trade count as a time series. Use this for volume trend analysis. For YES/NO volume breakdown by outcome side, use `volume-split` instead. **Data refresh:** ~30 minutes */
660
664
  volumes: (params) => get("prediction-market/polymarket/volumes", params)
661
665
  };
662
666
 
663
667
  // src/data/categories/prediction_market.ts
664
668
  var prediction_market = {
665
- /** Returns daily notional volume and open interest aggregated by category across Kalshi and Polymarket. **Filters:** `source` or `category`. **Data refresh:** daily */
666
- category_metrics: (params) => get("prediction-market/category-metrics", params)
669
+ /** Trends, top markets, momentum distribution, and per-market momentum signals for prediction markets. **Platform-wide totals:** Omit `category` to get aggregated volume/OI/market-count across the entire prediction market (Polymarket + Kalshi combined). Use `platform` to filter to one exchange. This is the recommended way to answer questions like "What is Polymarket's total volume this week?" or "How does Kalshi volume compare to Polymarket?" **Category drill-down:** Provide `category` to scope all data to one category (e.g. crypto, politics). Combines volume/OI time series, top markets by open interest, momentum summary (price/volume signal distribution), and per-market momentum signals (price changes, volume direction, whale flows). **Note on top_markets:** When both `category` and `platform` are omitted, top markets are ranked globally by open interest. Because Polymarket OI is significantly larger than Kalshi OI, the list will skew heavily toward Polymarket. Use `platform` to get per-platform rankings. **Use `search` instead if** you want to browse/search individual markets. **Data refresh:** ~5 minutes. */
670
+ analytics: (params) => get("prediction-market/analytics", params),
671
+ /** Returns 30-day Pearson price correlation pairs between Polymarket markets within a category. Correlation data covers the top 100 markets by 7-day volume globally; lower-volume markets may not have correlation data. Filter by `condition_id` to find all markets correlated with a specific market, or set `min_correlation` to control the threshold. The `category` parameter is required. **Data refresh:** ~5 minutes. */
672
+ correlations: (params) => get("prediction-market/correlations", params)
667
673
  };
668
674
 
669
675
  // src/data/categories/project.ts
670
676
  var project = {
671
- /** Returns time-series DeFi metrics for a project. **Available metrics:** `volume`, `fee`, `fees`, `revenue`, `tvl`, `users`. **Lookup:** by UUID (`id`) or name (`q`). Filter by `chain` and date range (`from`/`to`). Returns 404 if the project is not found. **Note:** this endpoint only returns data for DeFi protocol projects (e.g. `aave`, `uniswap`, `lido`, `makerdao`). Use `q` with a DeFi protocol name. */
677
+ /** Returns historical time-series for a single DeFi protocol metric (e.g. daily TVL). Each data point has a Unix timestamp and value. **Available metrics:** `volume`, `fee`, `fees`, `revenue`, `tvl`, `users`. **Lookup:** by UUID (`id`) or name (`q`). Filter by `chain` and date range (`from`/`to`). Returns 404 if the project is not found. **Note:** this endpoint only returns data for DeFi protocol projects (e.g. `aave`, `uniswap`, `lido`, `makerdao`). Use `q` with a DeFi protocol name. */
672
678
  defi_metrics: (params) => get("project/defi/metrics", params),
673
- /** Returns top DeFi projects ranked by a protocol metric. **Available metrics:** `tvl`, `revenue`, `fees`, `volume`, `users`. */
679
+ /** Returns a DeFi protocol leaderboard (e.g. Aave, Uniswap, Lido) ranked by TVL, fees, revenue, or users. For individual pool/vault yields, use `onchain-yield-ranking` instead. **Available metrics:** `tvl`, `revenue`, `fees`, `volume`, `users`. */
674
680
  defi_ranking: (params) => get("project/defi/ranking", params),
675
- /** Returns multiple project sub-resources in a single request. **Available fields** (via `fields`): `overview`, `token_info`, `tokenomics`, `funding`, `team`, `contracts`, `social`, `tge_status`. **Lookup:** accepts project names directly via `q` (e.g. `?q=aave`) — no need to call `/search/project` first. Also accepts UUID via `id`. Returns 404 if not found. For DeFi metrics (TVL, fees, revenue, volume, users) and per-chain breakdown, use `/project/defi/metrics`. */
681
+ /** Returns a crypto project's profile with selectable sub-resources: overview (description, chains, exchanges), token_info (price, market cap, supply), tokenomics, funding, team, contracts, social, tge_status. **Available fields** (via `fields`): `overview`, `token_info`, `tokenomics`, `funding`, `team`, `contracts`, `social`, `tge_status`. **Lookup:** accepts project names directly via `q` (e.g. `?q=aave`) — no need to call `/search/project` first. Also accepts UUID via `id`. Returns 404 if not found. For DeFi metrics (TVL, fees, revenue, volume, users) and per-chain breakdown, use `/project/defi/metrics`. */
676
682
  detail: (params) => get("project/detail", params)
677
683
  };
678
684
 
@@ -684,12 +690,14 @@ var search = {
684
690
  events: (params) => get("search/events", params),
685
691
  /** Searches funds by keyword. **Included fields:** name, tier, type, logo, top invested projects. */
686
692
  fund: (params) => get("search/fund", params),
687
- /** Searches Kalshi events by keyword and/or category. **Filters:** - Keyword matching event title, subtitle, or market title - Category At least one of `q` or `category` is required. Returns events with nested markets. **Data refresh:** ~30 minutes */
693
+ /** **[DEPRECATED]** Use `GET /v1/search/prediction-market?platform=kalshi` instead. This endpoint will continue to work but will not receive new features. --- Searches Kalshi events by keyword and/or category. **Filters:** - Keyword matching event title, subtitle, or market title - Category At least one of `q` or `category` is required. Returns events with nested markets. **Data refresh:** ~30 minutes */
688
694
  kalshi: (params) => get("search/kalshi", params),
689
695
  /** Searches crypto news articles by keyword. Returns top 10 results ranked by relevance with highlighted matching fragments. */
690
696
  news: (params) => get("search/news", params),
691
- /** Searches Polymarket events by keyword, tags, and/or category. **Filters:** - Keyword matching market question, event title, or description - Comma-separated tag labels - Surf-curated category At least one of `q`, `tags`, or `category` is required. Returns events with nested markets ranked by volume. **Data refresh:** ~30 minutes */
697
+ /** **[DEPRECATED]** Use `GET /v1/search/prediction-market?platform=polymarket` instead. This endpoint will continue to work but will not receive new features. --- Searches Polymarket events by keyword, tags, and/or category. **Filters:** - Keyword matching market question, event title, or description - Comma-separated tag labels - Surf-curated category At least one of `q`, `tags`, or `category` is required. Returns events with nested markets ranked by volume. **Data refresh:** ~30 minutes */
692
698
  polymarket: (params) => get("search/polymarket", params),
699
+ /** Browse and search prediction markets across all supported platforms. Filter by platform, category, status, keyword search, and smart money direction. Each result includes volume, open interest, trade counts, and smart money signals. Supports single-market lookup via `condition_id` or `market_ticker`. **Data refresh:** ~5 minutes. */
700
+ prediction_market: (params) => get("search/prediction-market", params),
693
701
  /** Searches crypto projects by keyword. **Included fields:** name, description, chains, logo. */
694
702
  project: (params) => get("search/project", params),
695
703
  /** Searches X (Twitter) users by keyword. **Included fields:** handle, display name, bio, follower count, avatar. */
@@ -704,7 +712,7 @@ var search = {
704
712
 
705
713
  // src/data/categories/social.ts
706
714
  var social = {
707
- /** Returns a **point-in-time snapshot** of social analytics for a project. **Available fields** (via `fields`): `sentiment`, `follower_geo`, `smart_followers`. **Lookup:** by X account ID (`x_id`) or project name (`q`, e.g. `uniswap`, `solana`). The `q` parameter must be a crypto project name, not a personal Twitter handle. Returns 404 if the project has no linked Twitter account. For sentiment **trends over time**, use `/social/mindshare` instead. */
715
+ /** Returns Twitter/X analytics for a crypto project: sentiment score, follower geography, and smart follower breakdown (VCs, KOLs, developers). For individual user profiles use `social-user` instead. **Available fields** (via `fields`): `sentiment`, `follower_geo`, `smart_followers`. **Lookup:** by X account ID (`x_id`) or project name (`q`, e.g. `uniswap`, `solana`). The `q` parameter must be a crypto project name, not a personal Twitter handle. Returns 404 if the project has no linked Twitter account. For sentiment **trends over time**, use `/social/mindshare` instead. */
708
716
  detail: (params) => get("social/detail", params),
709
717
  /** Returns mindshare (social view count) **time-series trend** for a project, aggregated by `interval`. **Intervals:** `5m`, `1h`, `1d`, `7d`. **Filters:** date range with `from`/`to` (Unix seconds). Lookup by name (`q`). Use this for sentiment **trends**, mindshare **over time**, or social momentum changes. For a **point-in-time snapshot** of social analytics (sentiment score, follower geo, smart followers), use `/social/detail` instead. */
710
718
  mindshare: (params) => get("social/mindshare", params),
@@ -716,7 +724,7 @@ var social = {
716
724
  tweet_replies: (params) => get("social/tweet/replies", params),
717
725
  /** Returns X (Twitter) posts by numeric post ID strings. Pass up to 100 comma-separated IDs via the `ids` query parameter. */
718
726
  tweets: (params) => get("social/tweets", params),
719
- /** Returns an X (Twitter) user profile. **Included fields:** display name, follower count, following count, and bio. **Lookup:** by `handle` (without @). */
727
+ /** Returns a basic X/Twitter profile (name, bio, avatar, follower/following counts) for any handle. For crypto project social analytics (sentiment, smart followers, geo), use `social-detail` instead. **Lookup:** by `handle` (without @). */
720
728
  user: (params) => get("social/user", params),
721
729
  /** Returns a list of followers for the specified handle on X (Twitter). **Lookup:** by `handle` (without @). */
722
730
  user_followers: (params) => get("social/user/followers", params),
@@ -740,25 +748,11 @@ var token = {
740
748
  transfers: (params) => get("token/transfers", params)
741
749
  };
742
750
 
743
- // src/data/categories/v2.ts
744
- var v2 = {
745
- /** Historical orderbook snapshots for a Kalshi market. Returns yes-side bid/ask levels. Timestamps in milliseconds, prices in cents. Data refresh: ~5 minutes */
746
- kalshi_orderbooks: (params) => get("gateway/v2/kalshi/orderbooks", params),
747
- /** OHLCV candlestick data for a Polymarket market. Prices normalized to YES side. Data refresh: ~30 minutes */
748
- polymarket_candlesticks: (params) => get("gateway/v2/polymarket/candlesticks/{condition_id}", params),
749
- /** Cumulative volume time series for a Polymarket token. Data refresh: ~30 minutes */
750
- polymarket_volume_timeseries: (params) => get("gateway/v2/polymarket/markets/{token_id}/volume", params),
751
- /** Historical orderbook snapshots for a Polymarket token. Returns raw bid/ask depth levels. Timestamps in milliseconds. Data refresh: ~5 minutes */
752
- polymarket_orderbooks: (params) => get("gateway/v2/polymarket/orderbooks", params),
753
- /** Volume breakdown by outcome (YES/NO) for a Polymarket market. Data refresh: ~30 minutes */
754
- polymarket_volume_chart: (params) => get("gateway/v2/polymarket/volume-chart/{condition_id}", params)
755
- };
756
-
757
751
  // src/data/categories/wallet.ts
758
752
  var wallet = {
759
- /** Returns multiple wallet sub-resources in a single request. **Available fields** (via `fields`): `balance`, `tokens`, `labels`, `nft`. **Lookup:** by `address`. Partial failures return available fields with per-field error info. Returns 422 if `fields` is invalid. */
753
+ /** Returns a wallet's cross-chain portfolio with selectable sub-resources (balance, tokens, labels, NFTs). Always includes per-chain USD breakdown across 15+ EVM chains. **Available fields** (via `fields`): `balance`, `tokens`, `labels`, `nft`. **Lookup:** by `address`. Partial failures return available fields with per-field error info. Returns 422 if `fields` is invalid. */
760
754
  detail: (params) => get("wallet/detail", params),
761
- /** Returns full transaction history for a wallet swaps, transfers, and contract interactions. **Lookup:** by `address`. Filter by `chain` — supports `ethereum`, `polygon`, `bsc`, `arbitrum`, `optimism`, `avalanche`, `fantom`, `base`. */
755
+ /** Returns all on-chain transactions for a wallet, classified by type (send, receive, swap, approve) with native token value. For ERC-20 token transfers with token identity and USD value, use `wallet-transfers` instead. **Lookup:** by `address`. Filter by `chain` — supports `ethereum`, `polygon`, `bsc`, `arbitrum`, `optimism`, `avalanche`, `fantom`, `base`. */
762
756
  history: (params) => get("wallet/history", params),
763
757
  /** Returns entity labels for multiple wallet addresses. Pass up to 100 comma-separated addresses via the `addresses` query parameter. **Included fields:** entity name, type, and labels per address. */
764
758
  labels_batch: (params) => get("wallet/labels/batch", params),
@@ -766,7 +760,7 @@ var wallet = {
766
760
  net_worth: (params) => get("wallet/net-worth", params),
767
761
  /** Returns all DeFi protocol positions for a wallet — lending, staking, LP, and farming with token breakdowns and USD values. **Lookup:** by `address`. */
768
762
  protocols: (params) => get("wallet/protocols", params),
769
- /** Returns recent token transfers **sent or received by a wallet**. Pass the **wallet address** in `address` — returns all ERC-20/SPL token transfers where this wallet is the sender or receiver. **Included fields:** token contract, counterparty, raw amount, block timestamp. Use this to audit a wallet's token flow (e.g. inflows, outflows, airdrop receipts). **Lookup:** `address` (wallet, raw 0x hex or base58 — ENS not supported). Filter by `chain` — supports `ethereum`, `base`, `solana`. **Data refresh:** ~24 hours · **Chains:** Ethereum, Base (Solana uses a different source with no delay) */
763
+ /** Returns ERC-20/SPL token transfers with token identity, USD value, and flow direction (in/out). Unlike `wallet-history` which shows all tx types in native value, this focuses on token-level transfer activity. Pass the **wallet address** in `address` — returns all ERC-20/SPL token transfers where this wallet is the sender or receiver. **Included fields:** token contract, token symbol, amount USD, counterparty, flow direction. Filter by specific token or flow direction (in/out). **Lookup:** `address` (wallet, raw 0x hex or base58 — ENS not supported). Filter by `chain` — supports `ethereum`, `base`, `solana`. **Data refresh:** ~24 hours · **Chains:** Ethereum, Base (Solana uses a different source with no delay) */
770
764
  transfers: (params) => get("wallet/transfers", params)
771
765
  };
772
766
 
@@ -795,7 +789,6 @@ var dataApi = {
795
789
  search,
796
790
  social,
797
791
  token,
798
- v2,
799
792
  wallet,
800
793
  web
801
794
  };