x-twitter-scraper 0.16.0 → 0.18.0

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.
Files changed (198) hide show
  1. package/CHANGELOG.md +44 -5
  2. package/README.md +1 -0
  3. package/client.d.mts +8 -2
  4. package/client.d.mts.map +1 -1
  5. package/client.d.ts +8 -2
  6. package/client.d.ts.map +1 -1
  7. package/client.js.map +1 -1
  8. package/client.mjs.map +1 -1
  9. package/internal/detect-platform.d.mts +3 -1
  10. package/internal/detect-platform.d.mts.map +1 -1
  11. package/internal/detect-platform.d.ts +3 -1
  12. package/internal/detect-platform.d.ts.map +1 -1
  13. package/internal/detect-platform.js +1 -1
  14. package/internal/detect-platform.js.map +1 -1
  15. package/internal/detect-platform.mjs +1 -1
  16. package/internal/detect-platform.mjs.map +1 -1
  17. package/package.json +1 -1
  18. package/resources/events.d.mts +50 -11
  19. package/resources/events.d.mts.map +1 -1
  20. package/resources/events.d.ts +50 -11
  21. package/resources/events.d.ts.map +1 -1
  22. package/resources/events.js.map +1 -1
  23. package/resources/events.mjs.map +1 -1
  24. package/resources/index.d.mts +1 -1
  25. package/resources/index.d.mts.map +1 -1
  26. package/resources/index.d.ts +1 -1
  27. package/resources/index.d.ts.map +1 -1
  28. package/resources/index.js.map +1 -1
  29. package/resources/index.mjs.map +1 -1
  30. package/resources/monitors/index.d.mts +2 -1
  31. package/resources/monitors/index.d.mts.map +1 -1
  32. package/resources/monitors/index.d.ts +2 -1
  33. package/resources/monitors/index.d.ts.map +1 -1
  34. package/resources/monitors/index.js +3 -1
  35. package/resources/monitors/index.js.map +1 -1
  36. package/resources/monitors/index.mjs +1 -0
  37. package/resources/monitors/index.mjs.map +1 -1
  38. package/resources/monitors/keywords.d.mts +10 -96
  39. package/resources/monitors/keywords.d.mts.map +1 -1
  40. package/resources/monitors/keywords.d.ts +10 -96
  41. package/resources/monitors/keywords.d.ts.map +1 -1
  42. package/resources/monitors/monitors.d.mts +6 -2
  43. package/resources/monitors/monitors.d.mts.map +1 -1
  44. package/resources/monitors/monitors.d.ts +6 -2
  45. package/resources/monitors/monitors.d.ts.map +1 -1
  46. package/resources/monitors/monitors.js +4 -0
  47. package/resources/monitors/monitors.js.map +1 -1
  48. package/resources/monitors/monitors.mjs +4 -0
  49. package/resources/monitors/monitors.mjs.map +1 -1
  50. package/resources/monitors/posts.d.mts +344 -0
  51. package/resources/monitors/posts.d.mts.map +1 -0
  52. package/resources/monitors/posts.d.ts +344 -0
  53. package/resources/monitors/posts.d.ts.map +1 -0
  54. package/resources/monitors/posts.js +94 -0
  55. package/resources/monitors/posts.js.map +1 -0
  56. package/resources/monitors/posts.mjs +90 -0
  57. package/resources/monitors/posts.mjs.map +1 -0
  58. package/resources/shared.d.mts +577 -2
  59. package/resources/shared.d.mts.map +1 -1
  60. package/resources/shared.d.ts +577 -2
  61. package/resources/shared.d.ts.map +1 -1
  62. package/resources/support/index.d.mts +1 -1
  63. package/resources/support/index.d.mts.map +1 -1
  64. package/resources/support/index.d.ts +1 -1
  65. package/resources/support/index.d.ts.map +1 -1
  66. package/resources/support/index.js.map +1 -1
  67. package/resources/support/index.mjs.map +1 -1
  68. package/resources/support/support.d.mts +2 -2
  69. package/resources/support/support.d.mts.map +1 -1
  70. package/resources/support/support.d.ts +2 -2
  71. package/resources/support/support.d.ts.map +1 -1
  72. package/resources/support/support.js.map +1 -1
  73. package/resources/support/support.mjs.map +1 -1
  74. package/resources/support/tickets.d.mts +12 -20
  75. package/resources/support/tickets.d.mts.map +1 -1
  76. package/resources/support/tickets.d.ts +12 -20
  77. package/resources/support/tickets.d.ts.map +1 -1
  78. package/resources/webhooks.d.mts +5 -4
  79. package/resources/webhooks.d.mts.map +1 -1
  80. package/resources/webhooks.d.ts +5 -4
  81. package/resources/webhooks.d.ts.map +1 -1
  82. package/resources/webhooks.js.map +1 -1
  83. package/resources/webhooks.mjs.map +1 -1
  84. package/resources/x/accounts.d.mts +14 -4
  85. package/resources/x/accounts.d.mts.map +1 -1
  86. package/resources/x/accounts.d.ts +14 -4
  87. package/resources/x/accounts.d.ts.map +1 -1
  88. package/resources/x/accounts.js +6 -4
  89. package/resources/x/accounts.js.map +1 -1
  90. package/resources/x/accounts.mjs +6 -4
  91. package/resources/x/accounts.mjs.map +1 -1
  92. package/resources/x/broadcasts.d.mts +3 -131
  93. package/resources/x/broadcasts.d.mts.map +1 -1
  94. package/resources/x/broadcasts.d.ts +3 -131
  95. package/resources/x/broadcasts.d.ts.map +1 -1
  96. package/resources/x/communities/communities.d.mts +92 -1
  97. package/resources/x/communities/communities.d.mts.map +1 -1
  98. package/resources/x/communities/communities.d.ts +92 -1
  99. package/resources/x/communities/communities.d.ts.map +1 -1
  100. package/resources/x/communities/communities.js +14 -0
  101. package/resources/x/communities/communities.js.map +1 -1
  102. package/resources/x/communities/communities.mjs +14 -0
  103. package/resources/x/communities/communities.mjs.map +1 -1
  104. package/resources/x/communities/index.d.mts +1 -1
  105. package/resources/x/communities/index.d.mts.map +1 -1
  106. package/resources/x/communities/index.d.ts +1 -1
  107. package/resources/x/communities/index.d.ts.map +1 -1
  108. package/resources/x/communities/index.js.map +1 -1
  109. package/resources/x/communities/index.mjs.map +1 -1
  110. package/resources/x/community-notes.d.mts +122 -510
  111. package/resources/x/community-notes.d.mts.map +1 -1
  112. package/resources/x/community-notes.d.ts +122 -510
  113. package/resources/x/community-notes.d.ts.map +1 -1
  114. package/resources/x/community-notes.js.map +1 -1
  115. package/resources/x/community-notes.mjs.map +1 -1
  116. package/resources/x/index.d.mts +7 -6
  117. package/resources/x/index.d.mts.map +1 -1
  118. package/resources/x/index.d.ts +7 -6
  119. package/resources/x/index.d.ts.map +1 -1
  120. package/resources/x/index.js +3 -1
  121. package/resources/x/index.js.map +1 -1
  122. package/resources/x/index.mjs +1 -0
  123. package/resources/x/index.mjs.map +1 -1
  124. package/resources/x/jobs.d.mts +144 -291
  125. package/resources/x/jobs.d.mts.map +1 -1
  126. package/resources/x/jobs.d.ts +144 -291
  127. package/resources/x/jobs.d.ts.map +1 -1
  128. package/resources/x/jobs.js.map +1 -1
  129. package/resources/x/jobs.mjs.map +1 -1
  130. package/resources/x/lists.d.mts +21 -419
  131. package/resources/x/lists.d.mts.map +1 -1
  132. package/resources/x/lists.d.ts +21 -419
  133. package/resources/x/lists.d.ts.map +1 -1
  134. package/resources/x/spaces.d.mts +213 -693
  135. package/resources/x/spaces.d.mts.map +1 -1
  136. package/resources/x/spaces.d.ts +213 -693
  137. package/resources/x/spaces.d.ts.map +1 -1
  138. package/resources/x/spaces.js.map +1 -1
  139. package/resources/x/spaces.mjs.map +1 -1
  140. package/resources/x/sports.d.mts +1512 -0
  141. package/resources/x/sports.d.mts.map +1 -0
  142. package/resources/x/sports.d.ts +1512 -0
  143. package/resources/x/sports.d.ts.map +1 -0
  144. package/resources/x/sports.js +91 -0
  145. package/resources/x/sports.js.map +1 -0
  146. package/resources/x/sports.mjs +87 -0
  147. package/resources/x/sports.mjs.map +1 -0
  148. package/resources/x/tweets/tweets.d.mts +11 -13
  149. package/resources/x/tweets/tweets.d.mts.map +1 -1
  150. package/resources/x/tweets/tweets.d.ts +11 -13
  151. package/resources/x/tweets/tweets.d.ts.map +1 -1
  152. package/resources/x/users/users.d.mts +29 -585
  153. package/resources/x/users/users.d.mts.map +1 -1
  154. package/resources/x/users/users.d.ts +29 -585
  155. package/resources/x/users/users.d.ts.map +1 -1
  156. package/resources/x/users/users.js.map +1 -1
  157. package/resources/x/users/users.mjs.map +1 -1
  158. package/resources/x/x.d.mts +55 -118
  159. package/resources/x/x.d.mts.map +1 -1
  160. package/resources/x/x.d.ts +55 -118
  161. package/resources/x/x.d.ts.map +1 -1
  162. package/resources/x/x.js +4 -0
  163. package/resources/x/x.js.map +1 -1
  164. package/resources/x/x.mjs +4 -0
  165. package/resources/x/x.mjs.map +1 -1
  166. package/skills/x-twitter-scraper/references/api-endpoints-x-api.md +1 -0
  167. package/src/client.ts +8 -0
  168. package/src/internal/detect-platform.ts +2 -2
  169. package/src/resources/events.ts +72 -10
  170. package/src/resources/index.ts +1 -0
  171. package/src/resources/monitors/index.ts +21 -0
  172. package/src/resources/monitors/keywords.ts +10 -118
  173. package/src/resources/monitors/monitors.ts +46 -0
  174. package/src/resources/monitors/posts.ts +463 -0
  175. package/src/resources/shared.ts +773 -200
  176. package/src/resources/support/index.ts +1 -0
  177. package/src/resources/support/support.ts +2 -0
  178. package/src/resources/support/tickets.ts +14 -21
  179. package/src/resources/webhooks.ts +5 -4
  180. package/src/resources/x/accounts.ts +19 -4
  181. package/src/resources/x/broadcasts.ts +3 -159
  182. package/src/resources/x/communities/communities.ts +113 -0
  183. package/src/resources/x/communities/index.ts +3 -0
  184. package/src/resources/x/community-notes.ts +137 -582
  185. package/src/resources/x/index.ts +70 -0
  186. package/src/resources/x/jobs.ts +160 -334
  187. package/src/resources/x/lists.ts +21 -493
  188. package/src/resources/x/spaces.ts +227 -817
  189. package/src/resources/x/sports.ts +1877 -0
  190. package/src/resources/x/tweets/tweets.ts +15 -15
  191. package/src/resources/x/users/users.ts +29 -693
  192. package/src/resources/x/x.ts +191 -128
  193. package/src/version.ts +1 -1
  194. package/version.d.mts +1 -1
  195. package/version.d.ts +1 -1
  196. package/version.js +1 -1
  197. package/version.mjs +1 -1
  198. package/src/lib/.keep +0 -2
@@ -6,6 +6,7 @@ export { Attachments, type AttachmentDownloadParams } from './attachments';
6
6
  export { Support } from './support';
7
7
  export {
8
8
  Tickets,
9
+ type SupportReceipt,
9
10
  type TicketCreateResponse,
10
11
  type TicketRetrieveResponse,
11
12
  type TicketUpdateResponse,
@@ -7,6 +7,7 @@ import * as AttachmentsAPI from './attachments';
7
7
  import { AttachmentDownloadParams, Attachments } from './attachments';
8
8
  import * as TicketsAPI from './tickets';
9
9
  import {
10
+ SupportReceipt,
10
11
  TicketCreateParams,
11
12
  TicketCreateResponse,
12
13
  TicketListParams,
@@ -32,6 +33,7 @@ export declare namespace Support {
32
33
 
33
34
  export {
34
35
  Tickets as Tickets,
36
+ type SupportReceipt as SupportReceipt,
35
37
  type TicketCreateResponse as TicketCreateResponse,
36
38
  type TicketRetrieveResponse as TicketRetrieveResponse,
37
39
  type TicketUpdateResponse as TicketUpdateResponse,
@@ -25,7 +25,7 @@ export class Tickets extends APIResource {
25
25
  * });
26
26
  * ```
27
27
  */
28
- create(params: TicketCreateParams, options?: RequestOptions): APIPromise<TicketCreateResponse> {
28
+ create(params: TicketCreateParams, options?: RequestOptions): APIPromise<SupportReceipt> {
29
29
  const { 'Idempotency-Key': idempotencyKey, ...body } = params;
30
30
  return this._client.post(
31
31
  '/support/tickets',
@@ -98,7 +98,7 @@ export class Tickets extends APIResource {
98
98
  * );
99
99
  * ```
100
100
  */
101
- reply(id: string, params: TicketReplyParams, options?: RequestOptions): APIPromise<TicketReplyResponse> {
101
+ reply(id: string, params: TicketReplyParams, options?: RequestOptions): APIPromise<SupportReceipt> {
102
102
  const { 'Idempotency-Key': idempotencyKey, ...body } = params;
103
103
  return this._client.post(
104
104
  path`/support/tickets/${id}/messages`,
@@ -120,13 +120,13 @@ export class Tickets extends APIResource {
120
120
  /**
121
121
  * Support submission receipt.
122
122
  */
123
- export interface TicketCreateResponse {
124
- attachments: Array<TicketCreateResponse.Attachment>;
123
+ export interface SupportReceipt {
124
+ attachments: Array<SupportReceipt.Attachment>;
125
125
 
126
126
  publicId: string;
127
127
  }
128
128
 
129
- export namespace TicketCreateResponse {
129
+ export namespace SupportReceipt {
130
130
  /**
131
131
  * Attachment identifier and initial processing state.
132
132
  */
@@ -137,6 +137,12 @@ export namespace TicketCreateResponse {
137
137
  }
138
138
  }
139
139
 
140
+ export type TicketCreateResponse = SupportReceipt;
141
+
142
+ export namespace TicketCreateResponse {
143
+ export type Attachment = SupportReceipt.Attachment;
144
+ }
145
+
140
146
  export interface TicketRetrieveResponse {
141
147
  createdAt: string;
142
148
 
@@ -230,24 +236,10 @@ export namespace TicketListResponse {
230
236
  }
231
237
  }
232
238
 
233
- /**
234
- * Support submission receipt.
235
- */
236
- export interface TicketReplyResponse {
237
- attachments: Array<TicketReplyResponse.Attachment>;
238
-
239
- publicId: string;
240
- }
239
+ export type TicketReplyResponse = SupportReceipt;
241
240
 
242
241
  export namespace TicketReplyResponse {
243
- /**
244
- * Attachment identifier and initial processing state.
245
- */
246
- export interface Attachment {
247
- publicId: string;
248
-
249
- status: 'pending' | 'ready' | 'failed';
250
- }
242
+ export type Attachment = SupportReceipt.Attachment;
251
243
  }
252
244
 
253
245
  export interface TicketCreateParams {
@@ -311,6 +303,7 @@ export interface TicketReplyParams {
311
303
 
312
304
  export declare namespace Tickets {
313
305
  export {
306
+ type SupportReceipt as SupportReceipt,
314
307
  type TicketCreateResponse as TicketCreateResponse,
315
308
  type TicketRetrieveResponse as TicketRetrieveResponse,
316
309
  type TicketUpdateResponse as TicketUpdateResponse,
@@ -4,6 +4,7 @@
4
4
 
5
5
  import { APIResource } from '../core/resource';
6
6
  import * as Shared from './shared';
7
+ import * as PostsAPI from './monitors/posts';
7
8
  import { APIPromise } from '../core/api-promise';
8
9
  import { RequestOptions } from '../internal/request-options';
9
10
  import { path } from '../internal/utils/path';
@@ -179,7 +180,7 @@ export interface Webhook {
179
180
  /**
180
181
  * Array of event types to subscribe to.
181
182
  */
182
- eventTypes: Array<Shared.EventType>;
183
+ eventTypes: Array<Shared.EventType | PostsAPI.PostEventType>;
183
184
 
184
185
  /**
185
186
  * Maximum reported failures before needs_attention. It does not pause delivery.
@@ -199,7 +200,7 @@ export interface WebhookCreateResponse {
199
200
  /**
200
201
  * Array of event types to subscribe to.
201
202
  */
202
- eventTypes: Array<Shared.EventType>;
203
+ eventTypes: Array<Shared.EventType | PostsAPI.PostEventType>;
203
204
 
204
205
  /**
205
206
  * Plaintext HMAC signing secret returned only at creation.
@@ -270,7 +271,7 @@ export interface WebhookCreateParams {
270
271
  /**
271
272
  * Array of event types to subscribe to.
272
273
  */
273
- eventTypes: Array<Shared.EventType>;
274
+ eventTypes: Array<Shared.EventType | PostsAPI.PostEventType>;
274
275
 
275
276
  /**
276
277
  * HTTPS URL. A Discord channel webhook URL gets each event as a Discord message, &
@@ -284,7 +285,7 @@ export interface WebhookUpdateParams {
284
285
  /**
285
286
  * Array of event types to subscribe to.
286
287
  */
287
- eventTypes?: Array<Shared.EventType>;
288
+ eventTypes?: Array<Shared.EventType | PostsAPI.PostEventType>;
288
289
 
289
290
  isActive?: boolean;
290
291
 
@@ -71,16 +71,21 @@ export class Accounts extends APIResource {
71
71
  }
72
72
 
73
73
  /**
74
- * Clears loginFailedAt and loginFailureReason for all accounts with transient or
75
- * automated failure reasons, making them eligible for retry on next use.
74
+ * Clears loginFailedAt and loginFailureReason for every account with a transient
75
+ * or automated failure reason. Each can then retry on its next use. Name accounts
76
+ * in accountIds to retry only those. Needs a dashboard session, since each retry
77
+ * signs in to X again.
76
78
  *
77
79
  * @example
78
80
  * ```ts
79
81
  * const response = await client.x.accounts.bulkRetry();
80
82
  * ```
81
83
  */
82
- bulkRetry(options?: RequestOptions): APIPromise<AccountBulkRetryResponse> {
83
- return this._client.post('/x/accounts/bulk-retry', options);
84
+ bulkRetry(
85
+ body: AccountBulkRetryParams | null | undefined = {},
86
+ options?: RequestOptions,
87
+ ): APIPromise<AccountBulkRetryResponse> {
88
+ return this._client.post('/x/accounts/bulk-retry', { body, ...options });
84
89
  }
85
90
 
86
91
  /**
@@ -290,6 +295,15 @@ export interface AccountListParams {
290
295
  limit?: number;
291
296
  }
292
297
 
298
+ export interface AccountBulkRetryParams {
299
+ /**
300
+ * IDs of the X accounts to retry. Accounts that failed for another reason, or
301
+ * belong to someone else, stay as they are. Accepts 1 to 1,000 IDs. Omit accountIds
302
+ * to retry every account with a transient or automated failure.
303
+ */
304
+ accountIds?: Array<string>;
305
+ }
306
+
293
307
  export interface AccountReauthParams {
294
308
  /**
295
309
  * Updated account password
@@ -318,6 +332,7 @@ export declare namespace Accounts {
318
332
  type AccountReauthResponse as AccountReauthResponse,
319
333
  type AccountCreateParams as AccountCreateParams,
320
334
  type AccountListParams as AccountListParams,
335
+ type AccountBulkRetryParams as AccountBulkRetryParams,
321
336
  type AccountReauthParams as AccountReauthParams,
322
337
  };
323
338
  }
@@ -35,170 +35,14 @@ export interface BroadcastRetrieveResponse {
35
35
  /**
36
36
  * X broadcast, a live video
37
37
  */
38
- broadcast: BroadcastRetrieveResponse.Broadcast;
38
+ broadcast: Shared.Broadcast;
39
39
  }
40
40
 
41
41
  export namespace BroadcastRetrieveResponse {
42
- /**
43
- * X broadcast, a live video
44
- */
45
- export interface Broadcast {
46
- /**
47
- * Broadcast ID
48
- */
49
- id: string;
50
-
51
- /**
52
- * Camera rotation in degrees
53
- */
54
- cameraRotation?: number;
55
-
56
- /**
57
- * X's code for who may chat
58
- */
59
- chatOption?: number;
60
-
61
- /**
62
- * Public X profile.
63
- */
64
- creator?: Shared.UserProfile;
65
-
66
- /**
67
- * When the broadcast ended
68
- */
69
- endedAt?: string;
70
-
71
- /**
72
- * Video height in pixels
73
- */
74
- height?: number;
75
-
76
- /**
77
- * Whether X offers a recording of the broadcast
78
- */
79
- isAvailableForReplay?: boolean;
80
-
81
- /**
82
- * Whether the video stream runs in high-latency mode
83
- */
84
- isHighLatency?: boolean;
85
-
86
- /**
87
- * Whether X marks the chat private
88
- */
89
- isPrivateChat?: boolean;
90
-
91
- /**
92
- * Whether the broadcaster edited the title of the replay
93
- */
94
- isTitleEdited?: boolean;
95
-
96
- /**
97
- * When the video stream last reached X
98
- */
99
- lastPingAt?: string;
100
-
101
- /**
102
- * X's media key for the video
103
- */
104
- mediaKey?: string;
105
-
106
- /**
107
- * Broadcaster, as X's live video service names the account
108
- */
109
- periscopeUser?: Broadcast.PeriscopeUser;
110
-
111
- /**
112
- * Image X shows before the broadcast starts
113
- */
114
- preLiveSlateUrl?: string;
115
-
116
- /**
117
- * When the broadcast was set to start
118
- */
119
- scheduledStart?: string;
120
-
121
- /**
122
- * What produced the video stream, as X names it
123
- */
124
- source?: string;
125
-
126
- /**
127
- * When the broadcast went live
128
- */
129
- startedAt?: string;
130
-
131
- /**
132
- * Such as NotStarted, Running or Ended, as X names it
133
- */
134
- state?: string;
135
-
136
- /**
137
- * Broadcast title
138
- */
139
- title?: string;
140
-
141
- /**
142
- * Accounts that watched, live or after
143
- */
144
- totalWatched?: number;
145
-
146
- /**
147
- * Accounts watching, as X counts them
148
- */
149
- totalWatching?: number;
150
-
151
- /**
152
- * Search tweet with author. Zero metrics may mean X omitted counts.
153
- */
154
- tweet?: Shared.SearchTweet;
155
-
156
- /**
157
- * ID of the post that announces the broadcast
158
- */
159
- tweetId?: string;
160
-
161
- /**
162
- * X's revision number of the broadcast
163
- */
164
- version?: number;
165
-
166
- /**
167
- * Video width in pixels
168
- */
169
- width?: number;
170
- }
42
+ export type Broadcast = Shared.Broadcast;
171
43
 
172
44
  export namespace Broadcast {
173
- /**
174
- * Broadcaster, as X's live video service names the account
175
- */
176
- export interface PeriscopeUser {
177
- /**
178
- * Live video account ID
179
- */
180
- id?: string;
181
-
182
- /**
183
- * Live video display name
184
- */
185
- displayName?: string;
186
-
187
- /**
188
- * Live video avatar URL
189
- */
190
- profilePicture?: string;
191
-
192
- /**
193
- * The broadcaster's avatar at full size
194
- */
195
- profilePictureOriginal?: string;
196
-
197
- /**
198
- * Live video username
199
- */
200
- username?: string;
201
- }
45
+ export type PeriscopeUser = Shared.Broadcast.PeriscopeUser;
202
46
  }
203
47
  }
204
48
 
@@ -144,6 +144,25 @@ export class Communities extends APIResource {
144
144
  return this._client.get('/x/communities/topics', { query, ...options });
145
145
  }
146
146
 
147
+ /**
148
+ * Returns community activity for X's latest period. Includes likes, new members,
149
+ * posts, replies & unique posters. Each metric has a count and a changePercent.
150
+ * Each request costs 1 credit.
151
+ *
152
+ * @example
153
+ * ```ts
154
+ * const communityAnalytics =
155
+ * await client.x.communities.retrieveAnalytics('id');
156
+ * ```
157
+ */
158
+ retrieveAnalytics(
159
+ id: string,
160
+ query: CommunityRetrieveAnalyticsParams | null | undefined = {},
161
+ options?: RequestOptions,
162
+ ): APIPromise<CommunityAnalytics> {
163
+ return this._client.get(path`/x/communities/${id}/analytics`, { query, ...options });
164
+ }
165
+
147
166
  /**
148
167
  * Returns one community's public identity, rules, join question, search tags,
149
168
  * membership counts, and the profiles of its creator, admin and previewed members.
@@ -238,6 +257,79 @@ export class Communities extends APIResource {
238
257
  }
239
258
  }
240
259
 
260
+ /**
261
+ * Community activity & growth for X's latest period.
262
+ */
263
+ export interface CommunityAnalytics {
264
+ /**
265
+ * The community ID from your request.
266
+ */
267
+ id: string;
268
+
269
+ /**
270
+ * The period's activity, each metric with its count and changePercent. likes
271
+ * counts likes on community posts and newMembers the accounts that joined. posts
272
+ * counts the community posts and replies the replies to them. uniquePosters counts
273
+ * the distinct accounts that posted.
274
+ */
275
+ metrics: CommunityAnalytics.Metrics;
276
+
277
+ /**
278
+ * The end of X's latest period, in UTC.
279
+ */
280
+ periodEndsAt: string;
281
+ }
282
+
283
+ export namespace CommunityAnalytics {
284
+ /**
285
+ * The period's activity, each metric with its count and changePercent. likes
286
+ * counts likes on community posts and newMembers the accounts that joined. posts
287
+ * counts the community posts and replies the replies to them. uniquePosters counts
288
+ * the distinct accounts that posted.
289
+ */
290
+ export interface Metrics {
291
+ /**
292
+ * A community metric for X's latest period & its percent change.
293
+ */
294
+ likes: CommunityAnalyticsMetric;
295
+
296
+ /**
297
+ * A community metric for X's latest period & its percent change.
298
+ */
299
+ newMembers: CommunityAnalyticsMetric;
300
+
301
+ /**
302
+ * A community metric for X's latest period & its percent change.
303
+ */
304
+ posts: CommunityAnalyticsMetric;
305
+
306
+ /**
307
+ * A community metric for X's latest period & its percent change.
308
+ */
309
+ replies: CommunityAnalyticsMetric;
310
+
311
+ /**
312
+ * A community metric for X's latest period & its percent change.
313
+ */
314
+ uniquePosters: CommunityAnalyticsMetric;
315
+ }
316
+ }
317
+
318
+ /**
319
+ * A community metric for X's latest period & its percent change.
320
+ */
321
+ export interface CommunityAnalyticsMetric {
322
+ /**
323
+ * Change in percent from the same figure 1 day earlier. Values stay unrounded.
324
+ */
325
+ changePercent: number;
326
+
327
+ /**
328
+ * Total for this metric during X's latest period.
329
+ */
330
+ count: number;
331
+ }
332
+
241
333
  /**
242
334
  * Durable write record. Poll statusUrl until terminal is true. Reusing its
243
335
  * Idempotency-Key returns this record. Create another action only when safeToRetry
@@ -955,6 +1047,24 @@ export interface CommunityListTopicsParams {
955
1047
  omit?: string;
956
1048
  }
957
1049
 
1050
+ export interface CommunityRetrieveAnalyticsParams {
1051
+ /**
1052
+ * Fields to keep in each row, comma-separated. Use dots for nested fields, such as
1053
+ * author.username. A list keeps the field in each item. Case & underscores do not
1054
+ * matter. A row that lacks a field leaves it out. Cursors, counts & diagnostics
1055
+ * always stay. An unknown name answers 400 unknown_field with the valid names,
1056
+ * before any read. The price stays the same. SDK row types then hold only the
1057
+ * named fields.
1058
+ */
1059
+ fields?: string;
1060
+
1061
+ /**
1062
+ * Fields to drop from each row, comma-separated. It takes the same names as
1063
+ * fields. With fields, it drops from the kept fields.
1064
+ */
1065
+ omit?: string;
1066
+ }
1067
+
958
1068
  export interface CommunityRetrieveInfoParams {
959
1069
  /**
960
1070
  * Fields to keep in each row, comma-separated. Use dots for nested fields, such as
@@ -1561,6 +1671,8 @@ Communities.Media = Media;
1561
1671
 
1562
1672
  export declare namespace Communities {
1563
1673
  export {
1674
+ type CommunityAnalytics as CommunityAnalytics,
1675
+ type CommunityAnalyticsMetric as CommunityAnalyticsMetric,
1564
1676
  type CommunityCreateResponse as CommunityCreateResponse,
1565
1677
  type CommunityDeleteResponse as CommunityDeleteResponse,
1566
1678
  type CommunityListSuggestedResponse as CommunityListSuggestedResponse,
@@ -1572,6 +1684,7 @@ export declare namespace Communities {
1572
1684
  type CommunityListPopularParams as CommunityListPopularParams,
1573
1685
  type CommunityListSuggestedParams as CommunityListSuggestedParams,
1574
1686
  type CommunityListTopicsParams as CommunityListTopicsParams,
1687
+ type CommunityRetrieveAnalyticsParams as CommunityRetrieveAnalyticsParams,
1575
1688
  type CommunityRetrieveInfoParams as CommunityRetrieveInfoParams,
1576
1689
  type CommunityRetrieveMembersParams as CommunityRetrieveMembersParams,
1577
1690
  type CommunityRetrieveModeratorsParams as CommunityRetrieveModeratorsParams,
@@ -4,6 +4,8 @@
4
4
 
5
5
  export {
6
6
  Communities,
7
+ type CommunityAnalytics,
8
+ type CommunityAnalyticsMetric,
7
9
  type CommunityCreateResponse,
8
10
  type CommunityDeleteResponse,
9
11
  type CommunityListSuggestedResponse,
@@ -15,6 +17,7 @@ export {
15
17
  type CommunityListPopularParams,
16
18
  type CommunityListSuggestedParams,
17
19
  type CommunityListTopicsParams,
20
+ type CommunityRetrieveAnalyticsParams,
18
21
  type CommunityRetrieveInfoParams,
19
22
  type CommunityRetrieveMembersParams,
20
23
  type CommunityRetrieveModeratorsParams,