@structbuild/sdk 0.2.8 → 0.2.10

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
@@ -139,6 +139,28 @@ function handleWebhook(payload: FirstTradePayload) {
139
139
 
140
140
  Available payload types: `FirstTradePayload`, `GlobalPnlPayload`, `MarketPnlPayload`, `EventPnlPayload`, `PositionPnlPayload`, `ConditionMetricsPayload`, `EventMetricsPayload`, `PositionMetricsPayload`, `VolumeMilestonePayload`, `EventVolumeMilestonePayload`, `PositionVolumeMilestonePayload`, `ProbabilitySpikePayload`.
141
141
 
142
+ ## JWT Auth
143
+
144
+ Let your end users authenticate directly using JWTs from their own auth provider (Privy, Auth0, Google, Turnkey, etc.) without exposing your `sk_*` API key client-side.
145
+
146
+ Create a JWT public key (`pk_jwt_*`) in your [Struct dashboard](https://struct.to), then pass it alongside the user's JWT:
147
+
148
+ ```typescript
149
+ import { StructClient, StructWebSocket } from "@structbuild/sdk";
150
+
151
+ const client = new StructClient({
152
+ apiKey: "pk_jwt_a1b2c3d4e5f6a1b2c3d4e5f6a1b2c3d4",
153
+ jwt: userAccessToken,
154
+ });
155
+
156
+ const ws = new StructWebSocket({
157
+ apiKey: "pk_jwt_a1b2c3d4e5f6a1b2c3d4e5f6a1b2c3d4",
158
+ jwt: userAccessToken,
159
+ });
160
+ ```
161
+
162
+ The `pk_jwt_*` key is safe to hardcode in frontend bundles — it is useless without a valid JWT from your configured auth provider.
163
+
142
164
  ## Pagination
143
165
 
144
166
  Use the `paginate` helper to iterate through all results:
@@ -103,7 +103,7 @@ export interface paths {
103
103
  patch?: never;
104
104
  trace?: never;
105
105
  };
106
- "/polymarket/events/slug/{slug}": {
106
+ "/polymarket/events/slug/{event_slug}": {
107
107
  parameters: {
108
108
  query?: never;
109
109
  header?: never;
@@ -403,7 +403,7 @@ export interface paths {
403
403
  patch?: never;
404
404
  trace?: never;
405
405
  };
406
- "/polymarket/market/slug/{slug}": {
406
+ "/polymarket/market/slug/{market_slug}": {
407
407
  parameters: {
408
408
  query?: never;
409
409
  header?: never;
@@ -961,6 +961,18 @@ export interface components {
961
961
  rewards_daily_rate?: number | null;
962
962
  start_date?: string | null;
963
963
  end_date?: string | null;
964
+ /** Format: double */
965
+ rewards_max_spread?: number | null;
966
+ /** Format: double */
967
+ rewards_min_size?: number | null;
968
+ /** Format: double */
969
+ native_daily_rate?: number | null;
970
+ /** Format: double */
971
+ sponsored_daily_rate?: number | null;
972
+ /** Format: double */
973
+ total_daily_rate?: number | null;
974
+ /** Format: int32 */
975
+ sponsors_count?: number | null;
964
976
  };
965
977
  /** @description Response type for condition metrics query */
966
978
  ConditionMetricsResponse: {
@@ -1098,12 +1110,12 @@ export interface components {
1098
1110
  /** @enum {string} */
1099
1111
  EventSortBy: "volume" | "txns" | "unique_traders" | "title" | "creation_date" | "start_date" | "end_date" | "relevance";
1100
1112
  /** @enum {string} */
1101
- GlobalPnlSortBy: "pnl_usd" | "buys" | "sells" | "redemptions" | "merges" | "avg_hold_time" | "markets_traded" | "events_traded" | "markets_won" | "volume_usd" | "fees" | "best_trade" | "worst_trade";
1113
+ GlobalPnlSortBy: "realized_pnl_usd" | "buys" | "sells" | "redemptions" | "merges" | "avg_hold_time" | "markets_traded" | "events_traded" | "markets_won" | "volume_usd" | "fees" | "best_trade";
1102
1114
  /** @description Individual trader entry in the global PnL leaderboard */
1103
1115
  GlobalPnlTrader: {
1104
1116
  trader: components["schemas"]["TraderInfo"];
1105
1117
  /** Format: double */
1106
- pnl_usd?: number | null;
1118
+ realized_pnl_usd?: number | null;
1107
1119
  /** Format: int64 */
1108
1120
  events_traded?: number | null;
1109
1121
  /** Format: int64 */
@@ -1145,9 +1157,6 @@ export interface components {
1145
1157
  /** Format: double */
1146
1158
  best_trade_pnl_usd?: number | null;
1147
1159
  best_trade_condition_id?: string | null;
1148
- /** Format: double */
1149
- worst_trade_pnl_usd?: number | null;
1150
- worst_trade_condition_id?: string | null;
1151
1160
  /** Format: int64 */
1152
1161
  first_trade_at?: number | null;
1153
1162
  /** Format: int64 */
@@ -1828,6 +1837,7 @@ export interface components {
1828
1837
  question?: string | null;
1829
1838
  image_url?: string | null;
1830
1839
  slug?: string | null;
1840
+ event_slug?: string | null;
1831
1841
  /** Format: double */
1832
1842
  usd_amount: number;
1833
1843
  /** Format: double */
@@ -1936,7 +1946,7 @@ export interface components {
1936
1946
  /** @enum {string} */
1937
1947
  TradeSide: "0" | "1";
1938
1948
  /** @enum {string} */
1939
- TradeType: "0" | "1" | "2" | "4" | "6";
1949
+ TradeType: "0" | "1" | "2" | "3" | "4" | "5" | "6";
1940
1950
  /**
1941
1951
  * @description Trader profile info embedded in API responses
1942
1952
  *
@@ -2154,9 +2164,6 @@ export interface components {
2154
2164
  /** Format: double */
2155
2165
  best_trade_pnl_usd?: number | null;
2156
2166
  best_trade_condition_id?: string | null;
2157
- /** Format: double */
2158
- worst_trade_pnl_usd?: number | null;
2159
- worst_trade_condition_id?: string | null;
2160
2167
  /** Format: int64 */
2161
2168
  first_trade_at?: number | null;
2162
2169
  /** Format: int64 */
@@ -2226,6 +2233,8 @@ export interface operations {
2226
2233
  * @example 10
2227
2234
  */
2228
2235
  limit?: number;
2236
+ /** @description Cursor from previous response for keyset pagination. Pass the pagination_key from the previous page to fetch the next page. */
2237
+ pagination_key?: string;
2229
2238
  };
2230
2239
  header?: never;
2231
2240
  path?: never;
@@ -2444,7 +2453,7 @@ export interface operations {
2444
2453
  header?: never;
2445
2454
  path: {
2446
2455
  /** @description Event slug */
2447
- slug: string;
2456
+ event_slug: string;
2448
2457
  };
2449
2458
  cookie?: never;
2450
2459
  };
@@ -2726,6 +2735,8 @@ export interface operations {
2726
2735
  limit?: number;
2727
2736
  /** @description Cursor-based pagination key */
2728
2737
  pagination_key?: string;
2738
+ /** @description Only return markets that have CLOB rewards (default: false) */
2739
+ has_rewards?: boolean;
2729
2740
  /** @description Return truncated response optimized for AI consumers (default: false) */
2730
2741
  ai?: boolean;
2731
2742
  };
@@ -3016,7 +3027,7 @@ export interface operations {
3016
3027
  header?: never;
3017
3028
  path: {
3018
3029
  /** @description Market slug (e.g. `will-trump-win`) */
3019
- slug: string;
3030
+ market_slug: string;
3020
3031
  };
3021
3032
  cookie?: never;
3022
3033
  };
@@ -3103,8 +3114,8 @@ export interface operations {
3103
3114
  outcome?: string;
3104
3115
  /** @description Outcome index: 0 (Yes), 1 (No) */
3105
3116
  outcome_index?: components["schemas"]["OutcomeIndex"];
3106
- /** @description Trade type: 0 (OrderFilled), 1 (Redemption), 2 (Merge) */
3107
- trade_type?: components["schemas"]["TradeType"];
3117
+ /** @description Comma-separated trade types: OrderFilled, Redemption, Merge, Split, Cancelled, PositionsConverted, OrdersMatched */
3118
+ trade_types?: string;
3108
3119
  /** @description Min USD amount */
3109
3120
  min_usd_amount?: number;
3110
3121
  /** @description Max USD amount */
@@ -3702,7 +3713,7 @@ export interface operations {
3702
3713
  query?: {
3703
3714
  /** @description Timeframe: 1d, 7d, 30d, lifetime (default: lifetime) */
3704
3715
  timeframe?: components["schemas"]["PnlTimeframe"];
3705
- /** @description Sort: pnl_usd, buys, sells, redemptions, merges, avg_hold_time, markets_traded, events_traded, markets_won, volume_usd, fees, best_trade, worst_trade (default: pnl_usd) */
3716
+ /** @description Sort: realized_pnl_usd, buys, sells, redemptions, merges, avg_hold_time, markets_traded, events_traded, markets_won, volume_usd, fees, best_trade (default: realized_pnl_usd) */
3706
3717
  sort_by?: components["schemas"]["GlobalPnlSortBy"];
3707
3718
  /** @description Sort direction: asc, desc (default: desc) */
3708
3719
  sort_direction?: components["schemas"]["SortDirection"];
@@ -3913,6 +3924,8 @@ export interface operations {
3913
3924
  market_slug?: string;
3914
3925
  /** @description Filter by specific outcome token (position ID) */
3915
3926
  position_id?: string;
3927
+ /** @description Minimum shares balance to include (e.g. 1.0 to filter out dust positions) */
3928
+ min_shares?: number;
3916
3929
  };
3917
3930
  header?: never;
3918
3931
  path: {
@@ -4002,8 +4015,8 @@ export interface operations {
4002
4015
  outcome?: string;
4003
4016
  /** @description Outcome index: 0 (Yes), 1 (No) */
4004
4017
  outcome_index?: components["schemas"]["OutcomeIndex"];
4005
- /** @description Trade type: 0 (OrderFilled), 1 (Redemption), 2 (Merge) */
4006
- trade_type?: components["schemas"]["TradeType"];
4018
+ /** @description Comma-separated trade types: OrderFilled, Redemption, Merge, Split, Cancelled, PositionsConverted, OrdersMatched */
4019
+ trade_types?: string;
4007
4020
  /** @description Min USD amount */
4008
4021
  min_usd_amount?: number;
4009
4022
  /** @description Max USD amount */
@@ -924,10 +924,6 @@ export interface components {
924
924
  best_trade_pnl_usd?: number | null;
925
925
  /** @description Condition ID of the best trade */
926
926
  best_trade_condition_id?: string | null;
927
- /** @description Worst single-trade PnL in USD */
928
- worst_trade_pnl_usd?: number | null;
929
- /** @description Condition ID of the worst trade */
930
- worst_trade_condition_id?: string | null;
931
927
  /**
932
928
  * Format: int64
933
929
  * @description Timestamp of the first trade (Unix seconds)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@structbuild/sdk",
3
- "version": "0.2.8",
3
+ "version": "0.2.10",
4
4
  "type": "module",
5
5
  "main": "./dist/index.cjs",
6
6
  "module": "./dist/index.js",