@surf-ai/sdk 0.1.0 → 0.1.4
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/dist/react/index.d.ts +247 -179
- package/dist/react/index.js +215 -103
- package/dist/server/index.cjs +35 -35
- package/dist/server/index.d.cts +240 -172
- package/dist/server/index.d.ts +240 -172
- package/dist/server/index.js +35 -35
- package/package.json +8 -4
package/dist/server/index.js
CHANGED
|
@@ -459,19 +459,19 @@ var fund = {
|
|
|
459
459
|
// src/data/categories/kalshi.ts
|
|
460
460
|
var kalshi = {
|
|
461
461
|
/** Get Kalshi events with nested markets, optionally filtered by `event_ticker`. Each event includes market count and a list of markets. Data refresh: ~30 minutes */
|
|
462
|
-
events: (params) => get("kalshi/events", params),
|
|
462
|
+
events: (params) => get("prediction-market/kalshi/events", params),
|
|
463
463
|
/** Get Kalshi markets, optionally filtered by `market_ticker`. Each market includes price, volume, and status. Data refresh: ~30 minutes */
|
|
464
|
-
markets: (params) => get("kalshi/markets", params),
|
|
464
|
+
markets: (params) => get("prediction-market/kalshi/markets", params),
|
|
465
465
|
/** Get daily open interest history for a Kalshi market filtered by `time_range`. Data refresh: ~30 minutes */
|
|
466
|
-
open_interest: (params) => get("kalshi/open-interest", params),
|
|
466
|
+
open_interest: (params) => get("prediction-market/kalshi/open-interest", params),
|
|
467
467
|
/** Get price history for a Kalshi market. Use `interval=1d` for daily OHLC from market reports (~30 min delay), or `interval=latest` for real-time price from trades. Data refresh: ~30 minutes (daily), real-time (latest) */
|
|
468
|
-
prices: (params) => get("kalshi/prices", params),
|
|
468
|
+
prices: (params) => get("prediction-market/kalshi/prices", params),
|
|
469
469
|
/** Get top-ranked Kalshi markets by last day's `notional_volume_usd` or `open_interest`. Filter by `status`. Data refresh: ~30 minutes */
|
|
470
|
-
ranking: (params) => get("kalshi/ranking", params),
|
|
470
|
+
ranking: (params) => get("prediction-market/kalshi/ranking", params),
|
|
471
471
|
/** Get individual trade records for a Kalshi market. Filter by `taker_side`, `min_contracts`, and date range. Sort by `timestamp` or `num_contracts`. Data refresh: real-time */
|
|
472
|
-
trades: (params) => get("kalshi/trades", params),
|
|
472
|
+
trades: (params) => get("prediction-market/kalshi/trades", params),
|
|
473
473
|
/** Get daily trading volume history for a Kalshi market filtered by `time_range`. Data refresh: ~30 minutes */
|
|
474
|
-
volumes: (params) => get("kalshi/volumes", params)
|
|
474
|
+
volumes: (params) => get("prediction-market/kalshi/volumes", params)
|
|
475
475
|
};
|
|
476
476
|
|
|
477
477
|
// src/data/categories/market.ts
|
|
@@ -483,11 +483,11 @@ var market = {
|
|
|
483
483
|
/** Get futures market data across all tracked tokens — open interest, funding rate, long/short ratio, and 24h volume. Sort by `sort_by` (default: volume_24h). */
|
|
484
484
|
futures: (params) => get("market/futures", params),
|
|
485
485
|
/** Get OHLC-style aggregated liquidation data for a token on a specific exchange. Filter by `symbol`, `exchange`, and `interval`. Useful for charting liquidation volume over time. */
|
|
486
|
-
liquidation_chart: (params) => get("market/liquidation
|
|
486
|
+
liquidation_chart: (params) => get("market/liquidation/chart", params),
|
|
487
487
|
/** Get liquidation breakdown by exchange — total, long, and short volumes in USD. Filter by `symbol` and `time_range` (`1h`, `4h`, `12h`, `24h`). */
|
|
488
|
-
liquidation_exchange_list: (params) => get("market/liquidation
|
|
488
|
+
liquidation_exchange_list: (params) => get("market/liquidation/exchange-list", params),
|
|
489
489
|
/** Get individual large liquidation orders above a USD threshold (`min_amount`, default 10000). Filter by `exchange` and `symbol`. For aggregate totals and long/short breakdown by exchange, use `/market/liquidation/exchange-list`. For historical liquidation charts, use `/market/liquidation/chart`. */
|
|
490
|
-
liquidation_order: (params) => get("market/liquidation
|
|
490
|
+
liquidation_order: (params) => get("market/liquidation/order", params),
|
|
491
491
|
/** Get on-chain indicator time-series for BTC or ETH. Metrics: `nupl`, `sopr`, `mvrv`, `puell-multiple`, `nvm`, `nvt`, `nvt-golden-cross`, `exchange-flows` (inflow/outflow/netflow/reserve). */
|
|
492
492
|
onchain_indicator: (params) => get("market/onchain-indicator", params),
|
|
493
493
|
/** Get options market data — open interest, volume, put/call ratio, and max pain price for a `symbol`. */
|
|
@@ -511,41 +511,41 @@ var news = {
|
|
|
511
511
|
// src/data/categories/onchain.ts
|
|
512
512
|
var onchain = {
|
|
513
513
|
/** List bridge protocols ranked by total USD volume over a time range. */
|
|
514
|
-
bridge_ranking: (params) => get("onchain/bridge
|
|
514
|
+
bridge_ranking: (params) => get("onchain/bridge/ranking", params),
|
|
515
515
|
/** Get the current gas price for an EVM chain via `eth_gasPrice` JSON-RPC. Returns gas price in both wei (raw) and Gwei (human-readable). **Supported chains:** `ethereum`, `polygon`, `bsc`, `arbitrum`, `optimism`, `base`, `avalanche`, `fantom`, `linea`, `cyber`. */
|
|
516
516
|
gas_price: (params) => get("onchain/gas-price", params),
|
|
517
|
-
/** Execute 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. - Source format: `agent.<table_name>` like `agent.ethereum_transactions` or `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. */
|
|
518
|
-
structured_query: (body) => post("onchain/
|
|
517
|
+
/** Execute 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. - Source format: `agent.<table_name>` like `agent.ethereum_transactions` or `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 } ``` */
|
|
518
|
+
structured_query: (body) => post("onchain/query", body),
|
|
519
519
|
/** Get table metadata — database, table, column names, types, and comments for all available on-chain databases. */
|
|
520
520
|
schema: () => get("onchain/schema"),
|
|
521
|
-
/** Execute 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. */
|
|
521
|
+
/** Execute 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 ``` */
|
|
522
522
|
sql: (body) => post("onchain/sql", body),
|
|
523
523
|
/** Get 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. */
|
|
524
524
|
tx: (params) => get("onchain/tx", params),
|
|
525
525
|
/** List DeFi yield pools ranked by APY or TVL. Returns the latest snapshot. Filter by protocol. */
|
|
526
|
-
yield_ranking: (params) => get("onchain/yield
|
|
526
|
+
yield_ranking: (params) => get("onchain/yield/ranking", params)
|
|
527
527
|
};
|
|
528
528
|
|
|
529
529
|
// src/data/categories/polymarket.ts
|
|
530
530
|
var polymarket = {
|
|
531
531
|
/** Get trade and redemption activity for a Polymarket wallet. Data refresh: ~30 minutes */
|
|
532
|
-
activity: (params) => get("polymarket/activity", params),
|
|
532
|
+
activity: (params) => get("prediction-market/polymarket/activity", params),
|
|
533
533
|
/** Get 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 */
|
|
534
|
-
events: (params) => get("polymarket/events", params),
|
|
534
|
+
events: (params) => get("prediction-market/polymarket/events", params),
|
|
535
535
|
/** Get 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 */
|
|
536
|
-
markets: (params) => get("polymarket/markets", params),
|
|
536
|
+
markets: (params) => get("prediction-market/polymarket/markets", params),
|
|
537
537
|
/** Get daily open interest history for a Polymarket market. Data refresh: ~30 minutes */
|
|
538
|
-
open_interest: (params) => get("polymarket/open-interest", params),
|
|
538
|
+
open_interest: (params) => get("prediction-market/polymarket/open-interest", params),
|
|
539
539
|
/** Get wallet positions on Polymarket markets. Data refresh: ~30 minutes */
|
|
540
|
-
positions: (params) => get("polymarket/positions", params),
|
|
540
|
+
positions: (params) => get("prediction-market/polymarket/positions", params),
|
|
541
541
|
/** Get aggregated price history for a Polymarket market. Use `interval=latest` for the most recent price snapshot. Data refresh: ~30 minutes */
|
|
542
|
-
prices: (params) => get("polymarket/prices", params),
|
|
542
|
+
prices: (params) => get("prediction-market/polymarket/prices", params),
|
|
543
543
|
/** Get top-ranked Polymarket markets by `volume_24h`, `volume_7d`, `open_interest`, or `trade_count`. Filter by `status` and `end_before`. Data refresh: ~30 minutes */
|
|
544
|
-
ranking: (params) => get("polymarket/ranking", params),
|
|
544
|
+
ranking: (params) => get("prediction-market/polymarket/ranking", params),
|
|
545
545
|
/** Get paginated trade records for a Polymarket market or wallet. Filter by `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 by `newest`, `oldest`, or `largest`. Data refresh: ~30 minutes */
|
|
546
|
-
trades: (params) => get("polymarket/trades", params),
|
|
546
|
+
trades: (params) => get("prediction-market/polymarket/trades", params),
|
|
547
547
|
/** Get trading volume and trade count history for a Polymarket market. Data refresh: ~30 minutes */
|
|
548
|
-
volumes: (params) => get("polymarket/volumes", params)
|
|
548
|
+
volumes: (params) => get("prediction-market/polymarket/volumes", params)
|
|
549
549
|
};
|
|
550
550
|
|
|
551
551
|
// src/data/categories/prediction_market.ts
|
|
@@ -557,9 +557,9 @@ var prediction_market = {
|
|
|
557
557
|
// src/data/categories/project.ts
|
|
558
558
|
var project = {
|
|
559
559
|
/** Get 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. */
|
|
560
|
-
defi_metrics: (params) => get("project/defi
|
|
560
|
+
defi_metrics: (params) => get("project/defi/metrics", params),
|
|
561
561
|
/** Get top DeFi projects ranked by a protocol metric. Available metrics: `tvl`, `revenue`, `fees`, `volume`, `users`. */
|
|
562
|
-
defi_ranking: (params) => get("project/defi
|
|
562
|
+
defi_ranking: (params) => get("project/defi/ranking", params),
|
|
563
563
|
/** Get multiple project sub-resources in a single request. Use `fields` to select: `overview`, `token_info`, `tokenomics`, `funding`, `team`, `contracts`, `social`, `tge_status`. **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`. */
|
|
564
564
|
detail: (params) => get("project/detail", params)
|
|
565
565
|
};
|
|
@@ -581,9 +581,9 @@ var search = {
|
|
|
581
581
|
/** Search crypto projects by keyword. Returns matching projects with name, description, chains, and logo. */
|
|
582
582
|
project: (params) => get("search/project", params),
|
|
583
583
|
/** Search X (Twitter) users by keyword. Returns user profiles with handle, display name, bio, follower count, and avatar. */
|
|
584
|
-
social_people: (params) => get("search/social
|
|
584
|
+
social_people: (params) => get("search/social/people", params),
|
|
585
585
|
/** Search X (Twitter) posts by keyword or `from:handle` syntax. Returns posts with author, content, engagement metrics, and timestamp. To load more results, check `meta.has_more`; if true, pass `meta.next_cursor` as the `cursor` query parameter in the next request. */
|
|
586
|
-
social_posts: (params) => get("search/social
|
|
586
|
+
social_posts: (params) => get("search/social/posts", params),
|
|
587
587
|
/** Search wallets by ENS name, address label, or address prefix. Returns matching wallet addresses with entity labels. */
|
|
588
588
|
wallet: (params) => get("search/wallet", params),
|
|
589
589
|
/** Search web pages, articles, and content by keyword. Filter by domain with `site` like `coindesk.com`. Returns titles, URLs, and content snippets. */
|
|
@@ -599,21 +599,21 @@ var social = {
|
|
|
599
599
|
/** Get top crypto projects ranked by mindshare (social view count), sourced directly from Argus real-time data (refreshed every 5 minutes). Filter by `tag` to scope to a category (e.g. `dex`, `l1`, `meme`). Use `time_range` (`24h`, `48h`, `7d`, `30d`) to control the ranking window. Supports `limit`/`offset` pagination. */
|
|
600
600
|
ranking: (params) => get("social/ranking", params),
|
|
601
601
|
/** Get smart follower count time-series for a project, sorted by date descending. Lookup by X account ID (`x_id`) or project name (`q`). The `q` parameter must be a project name (e.g. `uniswap`, `ethereum`), not a personal X handle — use `x_id` for individual accounts. Returns 404 if the project has no linked X account. */
|
|
602
|
-
smart_followers_history: (params) => get("social/smart-followers
|
|
602
|
+
smart_followers_history: (params) => get("social/smart-followers/history", params),
|
|
603
603
|
/** Returns replies/comments on a specific tweet. Lookup by `tweet_id`. */
|
|
604
|
-
tweet_replies: (params) => get("social/tweet
|
|
604
|
+
tweet_replies: (params) => get("social/tweet/replies", params),
|
|
605
605
|
/** Get X (Twitter) posts by numeric post ID strings. Pass up to 100 comma-separated IDs via the `ids` query parameter. */
|
|
606
606
|
tweets: (params) => get("social/tweets", params),
|
|
607
607
|
/** Get an X (Twitter) user profile — display name, follower count, following count, and bio. Lookup by `handle` (without @). */
|
|
608
608
|
user: (params) => get("social/user", params),
|
|
609
609
|
/** Returns a list of followers for the specified handle on X (Twitter). Lookup by `handle` (without @). */
|
|
610
|
-
user_followers: (params) => get("social/user
|
|
610
|
+
user_followers: (params) => get("social/user/followers", params),
|
|
611
611
|
/** Returns a list of users that the specified handle follows on X (Twitter). Lookup by `handle` (without @). */
|
|
612
|
-
user_following: (params) => get("social/user
|
|
612
|
+
user_following: (params) => get("social/user/following", params),
|
|
613
613
|
/** Get recent X (Twitter) posts by a specific user, ordered by recency. Lookup by `handle` (without @). Use `filter=original` to exclude retweets. To load more results, check `meta.has_more`; if true, pass `meta.next_cursor` as the `cursor` query parameter in the next request. */
|
|
614
|
-
user_posts: (params) => get("social/user
|
|
614
|
+
user_posts: (params) => get("social/user/posts", params),
|
|
615
615
|
/** Returns recent replies by the specified handle on X (Twitter). Lookup by `handle` (without @). */
|
|
616
|
-
user_replies: (params) => get("social/user
|
|
616
|
+
user_replies: (params) => get("social/user/replies", params)
|
|
617
617
|
};
|
|
618
618
|
|
|
619
619
|
// src/data/categories/token.ts
|
|
@@ -635,7 +635,7 @@ var wallet = {
|
|
|
635
635
|
/** Get 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`. */
|
|
636
636
|
history: (params) => get("wallet/history", params),
|
|
637
637
|
/** Get entity labels for multiple wallet addresses. Pass up to 100 comma-separated addresses via the `addresses` query parameter. Returns entity name, type, and labels per address. */
|
|
638
|
-
labels_batch: (params) => get("wallet/labels
|
|
638
|
+
labels_batch: (params) => get("wallet/labels/batch", params),
|
|
639
639
|
/** Get a time-series of the wallet's total net worth in USD. Returns ~288 data points at 5-minute intervals covering the last 24 hours. Fixed window — no custom time range supported. */
|
|
640
640
|
net_worth: (params) => get("wallet/net-worth", params),
|
|
641
641
|
/** Get all DeFi protocol positions for a wallet — lending, staking, LP, and farming with token breakdowns and USD values. Lookup by `address`. */
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@surf-ai/sdk",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.4",
|
|
4
4
|
"description": "Surf platform SDK — data API client, server runtime, React hooks, and database helpers",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"build": "tsup",
|
|
29
29
|
"dev": "tsup --watch",
|
|
30
30
|
"typecheck": "tsc --noEmit",
|
|
31
|
-
"codegen": "python3
|
|
31
|
+
"codegen": "python3 scripts/gen_sdk.py --spec https://api.ask.surf/gateway/openapi.json"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
34
|
"express": "^4.22.0",
|
|
@@ -45,8 +45,12 @@
|
|
|
45
45
|
"react-dom": "^19.0.0"
|
|
46
46
|
},
|
|
47
47
|
"peerDependenciesMeta": {
|
|
48
|
-
"react": {
|
|
49
|
-
|
|
48
|
+
"react": {
|
|
49
|
+
"optional": true
|
|
50
|
+
},
|
|
51
|
+
"react-dom": {
|
|
52
|
+
"optional": true
|
|
53
|
+
}
|
|
50
54
|
},
|
|
51
55
|
"devDependencies": {
|
|
52
56
|
"tsup": "^8.0.0",
|