@structbuild/sdk 0.1.6 → 0.1.7

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
@@ -101,6 +101,45 @@ const tags = await client.tags.getTags();
101
101
  const bonds = await client.bonds.getBonds();
102
102
  ```
103
103
 
104
+ ### Webhooks
105
+
106
+ Manage webhook subscriptions for real-time event notifications. Webhook endpoints are platform-level (not venue-scoped).
107
+
108
+ ```typescript
109
+ const webhooks = await client.webhooks.list();
110
+ const webhook = await client.webhooks.create({
111
+ url: "https://example.com/webhook",
112
+ events: ["first_trade", "probability_spike"],
113
+ filters: {
114
+ condition_ids: ["0x..."],
115
+ min_usd_value: 100,
116
+ },
117
+ });
118
+ const detail = await client.webhooks.getWebhook({ webhookId: webhook.data.id });
119
+ await client.webhooks.update({ webhookId: webhook.data.id, events: ["first_trade"] });
120
+ await client.webhooks.test({ webhookId: webhook.data.id });
121
+ await client.webhooks.deleteWebhook({ webhookId: webhook.data.id });
122
+ ```
123
+
124
+ #### Webhook Payload Types
125
+
126
+ The SDK exports typed payload schemas for building webhook receivers:
127
+
128
+ ```typescript
129
+ import type {
130
+ FirstTradePayload,
131
+ ProbabilitySpikePayload,
132
+ GlobalPnlPayload,
133
+ VolumeMilestonePayload,
134
+ } from "@structbuild/sdk";
135
+
136
+ function handleWebhook(payload: FirstTradePayload) {
137
+ console.log(payload.trader, payload.price, payload.side);
138
+ }
139
+ ```
140
+
141
+ Available payload types: `FirstTradePayload`, `GlobalPnlPayload`, `MarketPnlPayload`, `EventPnlPayload`, `PositionPnlPayload`, `ConditionMetricsPayload`, `EventMetricsPayload`, `PositionMetricsPayload`, `VolumeMilestonePayload`, `EventVolumeMilestonePayload`, `PositionVolumeMilestonePayload`, `ProbabilitySpikePayload`.
142
+
104
143
  ## Pagination
105
144
 
106
145
  Use the `paginate` helper to iterate through all results:
package/dist/client.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import type { Venue } from "./types/common.js";
2
2
  import type { RetryConfig, RequestHookInfo, ResponseHookInfo } from "./types/index.js";
3
- import { HoldersNamespace, ScoringNamespace, TagsNamespace, EventsNamespace, MarketsNamespace, SeriesNamespace, TraderNamespace, BondsNamespace, SearchNamespace } from "./namespaces/index.js";
3
+ import { HoldersNamespace, TagsNamespace, EventsNamespace, MarketsNamespace, SeriesNamespace, TraderNamespace, BondsNamespace, SearchNamespace, WebhooksNamespace } from "./namespaces/index.js";
4
4
  export interface StructClientConfig {
5
5
  apiKey: string;
6
6
  baseUrl?: string;
@@ -13,7 +13,6 @@ export interface StructClientConfig {
13
13
  }
14
14
  export declare class StructClient {
15
15
  readonly holders: HoldersNamespace;
16
- readonly scoring: ScoringNamespace;
17
16
  readonly tags: TagsNamespace;
18
17
  readonly events: EventsNamespace;
19
18
  readonly markets: MarketsNamespace;
@@ -21,5 +20,6 @@ export declare class StructClient {
21
20
  readonly trader: TraderNamespace;
22
21
  readonly bonds: BondsNamespace;
23
22
  readonly search: SearchNamespace;
23
+ readonly webhooks: WebhooksNamespace;
24
24
  constructor(config: StructClientConfig);
25
25
  }
@@ -1028,7 +1028,15 @@ export interface components {
1028
1028
  image_url?: string | null;
1029
1029
  tags: string[];
1030
1030
  /** Format: int64 */
1031
- end_date?: number | null;
1031
+ created_time?: number | null;
1032
+ /** Format: int64 */
1033
+ start_time?: number | null;
1034
+ /** Format: int64 */
1035
+ game_start_time?: number | null;
1036
+ /** Format: int64 */
1037
+ closed_time?: number | null;
1038
+ /** Format: int64 */
1039
+ end_time?: number | null;
1032
1040
  title?: string | null;
1033
1041
  id?: string | null;
1034
1042
  /** Format: double */
@@ -1070,7 +1078,7 @@ export interface components {
1070
1078
  /** @enum {string} */
1071
1079
  MarketPnlSortBy: "realized_pnl_usd" | "buy_usd" | "total_buys" | "total_fees" | "outcomes_traded";
1072
1080
  /** @enum {string} */
1073
- MarketSortBy: "volume" | "txns" | "unique_traders" | "liquidity" | "holders" | "end_date" | "created_at" | "relevance";
1081
+ MarketSortBy: "volume" | "txns" | "unique_traders" | "liquidity" | "holders" | "end_time" | "start_time" | "created_time" | "created_at" | "relevance";
1074
1082
  /** @enum {string} */
1075
1083
  MarketStatus: "open" | "closed";
1076
1084
  MarketVolumeChartResponse: {
@@ -1244,6 +1252,8 @@ export interface components {
1244
1252
  neg_risk_market_id: string | null;
1245
1253
  /** @default null */
1246
1254
  game_status: string | null;
1255
+ /** @default false */
1256
+ show_market_images: boolean;
1247
1257
  /**
1248
1258
  * @description Event status: "open" or "closed"
1249
1259
  * @default null
@@ -1965,11 +1975,11 @@ export interface operations {
1965
1975
  event_slugs?: string;
1966
1976
  /** @description Filter by position ID(s) - comma-separated (max 50), resolved via market_outcomes table */
1967
1977
  position_ids?: string;
1968
- /** @description Search in title and description (3-100 characters) */
1978
+ /** @description Search in title (3-100 characters) */
1969
1979
  search?: string;
1970
1980
  /** @description Filter by status: open or closed */
1971
1981
  status?: components["schemas"]["MarketStatus"];
1972
- /** @description Sort: volume, txns, unique_traders, liquidity, holders, end_date, created_at, relevance */
1982
+ /** @description Sort: volume, txns, unique_traders, liquidity, holders, end_time, start_time, created_time, created_at, relevance */
1973
1983
  sort_by?: components["schemas"]["MarketSortBy"];
1974
1984
  /** @description Sort direction: asc, desc (default: desc) */
1975
1985
  sort_dir?: components["schemas"]["SortDirection"];
@@ -2003,9 +2013,9 @@ export interface operations {
2003
2013
  tags?: string;
2004
2014
  /** @description Comma-separated tags to exclude */
2005
2015
  exclude_tags?: string;
2006
- /** @description Filter markets with end_date >= start_time (Unix timestamp) */
2016
+ /** @description Filter markets with end_time >= start_time (Unix timestamp) */
2007
2017
  start_time?: number;
2008
- /** @description Filter markets with end_date <= end_time (Unix timestamp) */
2018
+ /** @description Filter markets with end_time <= end_time (Unix timestamp) */
2009
2019
  end_time?: number;
2010
2020
  /** @description Include tags array (default: true) */
2011
2021
  include_tags?: boolean;
@@ -2015,10 +2025,8 @@ export interface operations {
2015
2025
  include_metrics?: boolean;
2016
2026
  /** @description Results limit (default: 50, max: 100) */
2017
2027
  limit?: number;
2018
- /** @description Cursor value for pagination (sort column value) */
2019
- cursor_value?: string;
2020
- /** @description Cursor ID for pagination (condition_id) */
2021
- cursor_id?: string;
2028
+ /** @description Cursor-based pagination key (base64-encoded, obtained from previous response's pagination.pagination_key) */
2029
+ pagination_key?: string;
2022
2030
  };
2023
2031
  header?: never;
2024
2032
  path?: never;