@surf-ai/sdk 1.0.0-alpha.3 → 1.0.0-alpha.30
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 +1 -1
- package/dist/db/index.cjs +4 -2
- package/dist/db/index.js +4 -2
- package/dist/server/index.cjs +48 -53
- package/dist/server/index.d.cts +349 -293
- package/dist/server/index.d.ts +349 -293
- package/dist/server/index.js +48 -53
- package/package.json +4 -3
package/dist/server/index.js
CHANGED
|
@@ -13,7 +13,7 @@ import path from "path";
|
|
|
13
13
|
import { Cron } from "croner";
|
|
14
14
|
|
|
15
15
|
// src/core/config.ts
|
|
16
|
-
var DEFAULT_API_BASE_URL = "https://api.
|
|
16
|
+
var DEFAULT_API_BASE_URL = "https://api.asksurf.ai/gateway/v1";
|
|
17
17
|
function trimTrailingSlashes(value) {
|
|
18
18
|
return String(value || "").replace(/\/+$/, "");
|
|
19
19
|
}
|
|
@@ -165,7 +165,9 @@ async function doSyncSchema(schemaPath) {
|
|
|
165
165
|
);
|
|
166
166
|
if (tables.length === 0) return;
|
|
167
167
|
await post("db/provision", {});
|
|
168
|
-
const
|
|
168
|
+
const tablesResult = await get("db/tables");
|
|
169
|
+
const tablesList = Array.isArray(tablesResult) ? tablesResult : tablesResult.tables || [];
|
|
170
|
+
const existing = tablesList.map((t) => typeof t === "string" ? t : t.name);
|
|
169
171
|
const missing = tables.filter((t) => !existing.includes(getTableConfig(t).name));
|
|
170
172
|
if (missing.length > 0) {
|
|
171
173
|
const { generateDrizzleJson, generateMigration } = __require("drizzle-kit/api");
|
|
@@ -510,7 +512,7 @@ var exchange = {
|
|
|
510
512
|
long_short_ratio: (params) => get("exchange/long-short-ratio", params),
|
|
511
513
|
/** 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. */
|
|
512
514
|
markets: (params) => get("exchange/markets", params),
|
|
513
|
-
/** Returns a
|
|
515
|
+
/** 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. */
|
|
514
516
|
perp: (params) => get("exchange/perp", params),
|
|
515
517
|
/** 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`. */
|
|
516
518
|
price: (params) => get("exchange/price", params)
|
|
@@ -518,11 +520,11 @@ var exchange = {
|
|
|
518
520
|
|
|
519
521
|
// src/data/categories/fund.ts
|
|
520
522
|
var fund = {
|
|
521
|
-
/** Returns a fund's
|
|
523
|
+
/** 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. */
|
|
522
524
|
detail: (params) => get("fund/detail", params),
|
|
523
525
|
/** 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`). */
|
|
524
526
|
portfolio: (params) => get("fund/portfolio", params),
|
|
525
|
-
/** Returns top
|
|
527
|
+
/** Returns top crypto VC funds ranked by tier or portfolio count. **Available metrics:** `tier` (lower is better), `portfolio_count` (number of invested projects). */
|
|
526
528
|
ranking: (params) => get("fund/ranking", params)
|
|
527
529
|
};
|
|
528
530
|
|
|
@@ -532,15 +534,15 @@ var kalshi = {
|
|
|
532
534
|
events: (params) => get("prediction-market/kalshi/events", params),
|
|
533
535
|
/** Returns Kalshi markets, optionally filtered by `market_ticker`. Each market includes price, volume, and status. **Data refresh:** ~30 minutes */
|
|
534
536
|
markets: (params) => get("prediction-market/kalshi/markets", params),
|
|
535
|
-
/**
|
|
537
|
+
/** Daily open interest time series for a Kalshi market. **Data refresh:** ~30 minutes */
|
|
536
538
|
open_interest: (params) => get("prediction-market/kalshi/open-interest", params),
|
|
537
|
-
/**
|
|
539
|
+
/** Historical orderbook snapshots for a Kalshi market. Returns yes-side bid/ask levels. Timestamps in milliseconds, prices in cents. Data refresh: ~5 minutes */
|
|
540
|
+
orderbooks: (params) => get("prediction-market/kalshi/orderbooks", params),
|
|
541
|
+
/** Price time series for a Kalshi market with daily or hourly OHLC data, or latest price from recent trades. **Data refresh:** ~30 minutes */
|
|
538
542
|
prices: (params) => get("prediction-market/kalshi/prices", params),
|
|
539
|
-
/** Returns top-ranked Kalshi markets by last day's `notional_volume_usd` or `open_interest`. **Filters:** `status`. **Data refresh:** ~30 minutes */
|
|
540
|
-
ranking: (params) => get("prediction-market/kalshi/ranking", params),
|
|
541
543
|
/** 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 */
|
|
542
544
|
trades: (params) => get("prediction-market/kalshi/trades", params),
|
|
543
|
-
/**
|
|
545
|
+
/** Daily trading volume time series for a Kalshi market. **Data refresh:** ~30 minutes */
|
|
544
546
|
volumes: (params) => get("prediction-market/kalshi/volumes", params)
|
|
545
547
|
};
|
|
546
548
|
|
|
@@ -566,17 +568,15 @@ var market = {
|
|
|
566
568
|
price: (params) => get("market/price", params),
|
|
567
569
|
/** 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`. */
|
|
568
570
|
price_indicator: (params) => get("market/price-indicator", params),
|
|
569
|
-
/** Returns
|
|
571
|
+
/** 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`. */
|
|
570
572
|
ranking: (params) => get("market/ranking", params)
|
|
571
573
|
};
|
|
572
574
|
|
|
573
575
|
// src/data/categories/matching.ts
|
|
574
576
|
var matching = {
|
|
575
|
-
/** Returns daily volume and open interest comparison for a specific matched
|
|
577
|
+
/** 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. */
|
|
576
578
|
market_daily: (params) => get("prediction-market/matching/daily", params),
|
|
577
|
-
/**
|
|
578
|
-
market_find: (params) => get("prediction-market/matching/find", params),
|
|
579
|
-
/** 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. */
|
|
579
|
+
/** 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 */
|
|
580
580
|
market_pairs: (params) => get("prediction-market/matching/pairs", params)
|
|
581
581
|
};
|
|
582
582
|
|
|
@@ -596,51 +596,59 @@ var onchain = {
|
|
|
596
596
|
gas_price: (params) => get("onchain/gas-price", params),
|
|
597
597
|
/** 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 } ``` */
|
|
598
598
|
structured_query: (body) => post("onchain/query", body),
|
|
599
|
-
/** Returns
|
|
599
|
+
/** 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. */
|
|
600
600
|
schema: () => get("onchain/schema"),
|
|
601
601
|
/** 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 ``` */
|
|
602
602
|
sql: (body) => post("onchain/sql", body),
|
|
603
603
|
/** 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. */
|
|
604
604
|
tx: (params) => get("onchain/tx", params),
|
|
605
|
-
/** Returns DeFi yield pools ranked by APY or TVL.
|
|
605
|
+
/** 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. */
|
|
606
606
|
yield_ranking: (params) => get("onchain/yield/ranking", params)
|
|
607
607
|
};
|
|
608
608
|
|
|
609
609
|
// src/data/categories/polymarket.ts
|
|
610
610
|
var polymarket = {
|
|
611
|
-
/** Returns trade and redemption activity for a Polymarket wallet. **Data refresh:** ~30 minutes */
|
|
612
|
-
activity: (params) => get("prediction-market/polymarket/activity", params),
|
|
613
611
|
/** 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 */
|
|
614
612
|
events: (params) => get("prediction-market/polymarket/events", params),
|
|
613
|
+
/** 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. */
|
|
614
|
+
leaderboard: (params) => get("prediction-market/polymarket/leaderboard", params),
|
|
615
615
|
/** 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 */
|
|
616
616
|
markets: (params) => get("prediction-market/polymarket/markets", params),
|
|
617
|
-
/**
|
|
617
|
+
/** Daily open interest time series showing total value locked in a Polymarket market. **Data refresh:** ~30 minutes */
|
|
618
618
|
open_interest: (params) => get("prediction-market/polymarket/open-interest", params),
|
|
619
|
-
/**
|
|
619
|
+
/** Historical orderbook snapshots for a Polymarket token. Returns raw bid/ask depth levels. Timestamps in milliseconds. Data refresh: ~5 minutes */
|
|
620
|
+
orderbooks: (params) => get("prediction-market/polymarket/orderbooks", params),
|
|
621
|
+
/** 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 */
|
|
620
622
|
positions: (params) => get("prediction-market/polymarket/positions", params),
|
|
621
|
-
/**
|
|
623
|
+
/** 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 */
|
|
624
|
+
price_ohlcv: (params) => get("prediction-market/polymarket/price-ohlcv/{condition_id}", params),
|
|
625
|
+
/** 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 */
|
|
622
626
|
prices: (params) => get("prediction-market/polymarket/prices", params),
|
|
623
|
-
/**
|
|
624
|
-
|
|
625
|
-
/**
|
|
627
|
+
/** 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 */
|
|
628
|
+
smart_money: (params) => get("prediction-market/polymarket/smart-money", params),
|
|
629
|
+
/** 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 */
|
|
626
630
|
trades: (params) => get("prediction-market/polymarket/trades", params),
|
|
627
|
-
/**
|
|
631
|
+
/** 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 */
|
|
632
|
+
volume_split: (params) => get("prediction-market/polymarket/volume-split/{condition_id}", params),
|
|
633
|
+
/** 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 */
|
|
628
634
|
volumes: (params) => get("prediction-market/polymarket/volumes", params)
|
|
629
635
|
};
|
|
630
636
|
|
|
631
637
|
// src/data/categories/prediction_market.ts
|
|
632
638
|
var prediction_market = {
|
|
633
|
-
/**
|
|
634
|
-
|
|
639
|
+
/** 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. */
|
|
640
|
+
analytics: (params) => get("prediction-market/analytics", params),
|
|
641
|
+
/** 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. */
|
|
642
|
+
correlations: (params) => get("prediction-market/correlations", params)
|
|
635
643
|
};
|
|
636
644
|
|
|
637
645
|
// src/data/categories/project.ts
|
|
638
646
|
var project = {
|
|
639
|
-
/** Returns time-series DeFi
|
|
647
|
+
/** 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. */
|
|
640
648
|
defi_metrics: (params) => get("project/defi/metrics", params),
|
|
641
|
-
/** Returns
|
|
649
|
+
/** 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`. */
|
|
642
650
|
defi_ranking: (params) => get("project/defi/ranking", params),
|
|
643
|
-
/** Returns
|
|
651
|
+
/** 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`. */
|
|
644
652
|
detail: (params) => get("project/detail", params)
|
|
645
653
|
};
|
|
646
654
|
|
|
@@ -652,12 +660,14 @@ var search = {
|
|
|
652
660
|
events: (params) => get("search/events", params),
|
|
653
661
|
/** Searches funds by keyword. **Included fields:** name, tier, type, logo, top invested projects. */
|
|
654
662
|
fund: (params) => get("search/fund", params),
|
|
655
|
-
/** 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 */
|
|
663
|
+
/** **[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 */
|
|
656
664
|
kalshi: (params) => get("search/kalshi", params),
|
|
657
665
|
/** Searches crypto news articles by keyword. Returns top 10 results ranked by relevance with highlighted matching fragments. */
|
|
658
666
|
news: (params) => get("search/news", params),
|
|
659
|
-
/** 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 */
|
|
667
|
+
/** **[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 */
|
|
660
668
|
polymarket: (params) => get("search/polymarket", params),
|
|
669
|
+
/** 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. */
|
|
670
|
+
prediction_market: (params) => get("search/prediction-market", params),
|
|
661
671
|
/** Searches crypto projects by keyword. **Included fields:** name, description, chains, logo. */
|
|
662
672
|
project: (params) => get("search/project", params),
|
|
663
673
|
/** Searches X (Twitter) users by keyword. **Included fields:** handle, display name, bio, follower count, avatar. */
|
|
@@ -672,7 +682,7 @@ var search = {
|
|
|
672
682
|
|
|
673
683
|
// src/data/categories/social.ts
|
|
674
684
|
var social = {
|
|
675
|
-
/** Returns a
|
|
685
|
+
/** 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. */
|
|
676
686
|
detail: (params) => get("social/detail", params),
|
|
677
687
|
/** 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. */
|
|
678
688
|
mindshare: (params) => get("social/mindshare", params),
|
|
@@ -684,7 +694,7 @@ var social = {
|
|
|
684
694
|
tweet_replies: (params) => get("social/tweet/replies", params),
|
|
685
695
|
/** Returns X (Twitter) posts by numeric post ID strings. Pass up to 100 comma-separated IDs via the `ids` query parameter. */
|
|
686
696
|
tweets: (params) => get("social/tweets", params),
|
|
687
|
-
/** Returns
|
|
697
|
+
/** 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 @). */
|
|
688
698
|
user: (params) => get("social/user", params),
|
|
689
699
|
/** Returns a list of followers for the specified handle on X (Twitter). **Lookup:** by `handle` (without @). */
|
|
690
700
|
user_followers: (params) => get("social/user/followers", params),
|
|
@@ -708,25 +718,11 @@ var token = {
|
|
|
708
718
|
transfers: (params) => get("token/transfers", params)
|
|
709
719
|
};
|
|
710
720
|
|
|
711
|
-
// src/data/categories/v2.ts
|
|
712
|
-
var v2 = {
|
|
713
|
-
/** Historical orderbook snapshots for a Kalshi market. Returns yes-side bid/ask levels. Timestamps in milliseconds, prices in cents. Data refresh: ~5 minutes */
|
|
714
|
-
kalshi_orderbooks: (params) => get("gateway/v2/kalshi/orderbooks", params),
|
|
715
|
-
/** OHLCV candlestick data for a Polymarket market. Prices normalized to YES side. Data refresh: ~30 minutes */
|
|
716
|
-
polymarket_candlesticks: (params) => get("gateway/v2/polymarket/candlesticks/{condition_id}", params),
|
|
717
|
-
/** Cumulative volume time series for a Polymarket token. Data refresh: ~30 minutes */
|
|
718
|
-
polymarket_volume_timeseries: (params) => get("gateway/v2/polymarket/markets/{token_id}/volume", params),
|
|
719
|
-
/** Historical orderbook snapshots for a Polymarket token. Returns raw bid/ask depth levels. Timestamps in milliseconds. Data refresh: ~5 minutes */
|
|
720
|
-
polymarket_orderbooks: (params) => get("gateway/v2/polymarket/orderbooks", params),
|
|
721
|
-
/** Volume breakdown by outcome (YES/NO) for a Polymarket market. Data refresh: ~30 minutes */
|
|
722
|
-
polymarket_volume_chart: (params) => get("gateway/v2/polymarket/volume-chart/{condition_id}", params)
|
|
723
|
-
};
|
|
724
|
-
|
|
725
721
|
// src/data/categories/wallet.ts
|
|
726
722
|
var wallet = {
|
|
727
|
-
/** Returns
|
|
723
|
+
/** 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. */
|
|
728
724
|
detail: (params) => get("wallet/detail", params),
|
|
729
|
-
/** Returns
|
|
725
|
+
/** 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`. */
|
|
730
726
|
history: (params) => get("wallet/history", params),
|
|
731
727
|
/** 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. */
|
|
732
728
|
labels_batch: (params) => get("wallet/labels/batch", params),
|
|
@@ -734,7 +730,7 @@ var wallet = {
|
|
|
734
730
|
net_worth: (params) => get("wallet/net-worth", params),
|
|
735
731
|
/** Returns all DeFi protocol positions for a wallet — lending, staking, LP, and farming with token breakdowns and USD values. **Lookup:** by `address`. */
|
|
736
732
|
protocols: (params) => get("wallet/protocols", params),
|
|
737
|
-
/** Returns
|
|
733
|
+
/** 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) */
|
|
738
734
|
transfers: (params) => get("wallet/transfers", params)
|
|
739
735
|
};
|
|
740
736
|
|
|
@@ -763,7 +759,6 @@ var dataApi = {
|
|
|
763
759
|
search,
|
|
764
760
|
social,
|
|
765
761
|
token,
|
|
766
|
-
v2,
|
|
767
762
|
wallet,
|
|
768
763
|
web
|
|
769
764
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@surf-ai/sdk",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.30",
|
|
4
4
|
"description": "Surf platform SDK — data API client, server runtime, and database helpers",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -22,13 +22,14 @@
|
|
|
22
22
|
"build": "tsup",
|
|
23
23
|
"dev": "tsup --watch",
|
|
24
24
|
"typecheck": "tsc --noEmit",
|
|
25
|
-
"codegen": "python3 scripts/gen_sdk.py --spec https://api.
|
|
25
|
+
"codegen": "python3 scripts/gen_sdk.py --spec https://api.asksurf.ai/gateway/openapi.json"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
28
|
"express": "^4.22.0",
|
|
29
29
|
"cors": "^2.8.5",
|
|
30
30
|
"croner": "^9.0.0",
|
|
31
|
-
"drizzle-orm": "^0.44.0"
|
|
31
|
+
"drizzle-orm": "^0.44.0",
|
|
32
|
+
"drizzle-kit": "^0.31.0"
|
|
32
33
|
},
|
|
33
34
|
"devDependencies": {
|
|
34
35
|
"tsup": "^8.0.0",
|