x-twitter-scraper 0.20.0 → 0.22.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 (226) hide show
  1. package/CHANGELOG.md +65 -0
  2. package/README.md +121 -122
  3. package/client.d.mts +9 -3
  4. package/client.d.mts.map +1 -1
  5. package/client.d.ts +9 -3
  6. package/client.d.ts.map +1 -1
  7. package/client.js +2 -2
  8. package/client.js.map +1 -1
  9. package/client.mjs +2 -2
  10. package/client.mjs.map +1 -1
  11. package/package.json +1 -1
  12. package/resources/events.d.mts +8 -0
  13. package/resources/events.d.mts.map +1 -1
  14. package/resources/events.d.ts +8 -0
  15. package/resources/events.d.ts.map +1 -1
  16. package/resources/extractions.d.mts +105 -5
  17. package/resources/extractions.d.mts.map +1 -1
  18. package/resources/extractions.d.ts +105 -5
  19. package/resources/extractions.d.ts.map +1 -1
  20. package/resources/index.d.mts +1 -1
  21. package/resources/index.d.mts.map +1 -1
  22. package/resources/index.d.ts +1 -1
  23. package/resources/index.d.ts.map +1 -1
  24. package/resources/index.js.map +1 -1
  25. package/resources/index.mjs.map +1 -1
  26. package/resources/monitors/index.d.mts +1 -1
  27. package/resources/monitors/index.d.mts.map +1 -1
  28. package/resources/monitors/index.d.ts +1 -1
  29. package/resources/monitors/index.d.ts.map +1 -1
  30. package/resources/monitors/index.js.map +1 -1
  31. package/resources/monitors/index.mjs.map +1 -1
  32. package/resources/monitors/monitors.d.mts +38 -1
  33. package/resources/monitors/monitors.d.mts.map +1 -1
  34. package/resources/monitors/monitors.d.ts +38 -1
  35. package/resources/monitors/monitors.d.ts.map +1 -1
  36. package/resources/monitors/monitors.js +18 -0
  37. package/resources/monitors/monitors.js.map +1 -1
  38. package/resources/monitors/monitors.mjs +18 -0
  39. package/resources/monitors/monitors.mjs.map +1 -1
  40. package/resources/monitors/posts.d.mts +27 -0
  41. package/resources/monitors/posts.d.mts.map +1 -1
  42. package/resources/monitors/posts.d.ts +27 -0
  43. package/resources/monitors/posts.d.ts.map +1 -1
  44. package/resources/shared.d.mts +192 -5
  45. package/resources/shared.d.mts.map +1 -1
  46. package/resources/shared.d.ts +192 -5
  47. package/resources/shared.d.ts.map +1 -1
  48. package/resources/x/account-connection-attempts.d.mts +4 -0
  49. package/resources/x/account-connection-attempts.d.mts.map +1 -1
  50. package/resources/x/account-connection-attempts.d.ts +4 -0
  51. package/resources/x/account-connection-attempts.d.ts.map +1 -1
  52. package/resources/x/account-connection-links.d.mts +159 -0
  53. package/resources/x/account-connection-links.d.mts.map +1 -0
  54. package/resources/x/account-connection-links.d.ts +159 -0
  55. package/resources/x/account-connection-links.d.ts.map +1 -0
  56. package/resources/x/account-connection-links.js +82 -0
  57. package/resources/x/account-connection-links.js.map +1 -0
  58. package/resources/x/account-connection-links.mjs +78 -0
  59. package/resources/x/account-connection-links.mjs.map +1 -0
  60. package/resources/x/accounts.d.mts +13 -9
  61. package/resources/x/accounts.d.mts.map +1 -1
  62. package/resources/x/accounts.d.ts +13 -9
  63. package/resources/x/accounts.d.ts.map +1 -1
  64. package/resources/x/analysis.d.mts +540 -36
  65. package/resources/x/analysis.d.mts.map +1 -1
  66. package/resources/x/analysis.d.ts +540 -36
  67. package/resources/x/analysis.d.ts.map +1 -1
  68. package/resources/x/bookmarks.d.mts +5 -0
  69. package/resources/x/bookmarks.d.mts.map +1 -1
  70. package/resources/x/bookmarks.d.ts +5 -0
  71. package/resources/x/bookmarks.d.ts.map +1 -1
  72. package/resources/x/communities/communities.d.mts +2 -2
  73. package/resources/x/communities/communities.d.mts.map +1 -1
  74. package/resources/x/communities/communities.d.ts +2 -2
  75. package/resources/x/communities/communities.d.ts.map +1 -1
  76. package/resources/x/communities/communities.js.map +1 -1
  77. package/resources/x/communities/communities.mjs.map +1 -1
  78. package/resources/x/communities/join.d.mts +2 -2
  79. package/resources/x/communities/join.d.mts.map +1 -1
  80. package/resources/x/communities/join.d.ts +2 -2
  81. package/resources/x/communities/join.d.ts.map +1 -1
  82. package/resources/x/dm.d.mts +2 -2
  83. package/resources/x/dm.d.mts.map +1 -1
  84. package/resources/x/dm.d.ts +2 -2
  85. package/resources/x/dm.d.ts.map +1 -1
  86. package/resources/x/index.d.mts +3 -2
  87. package/resources/x/index.d.mts.map +1 -1
  88. package/resources/x/index.d.ts +3 -2
  89. package/resources/x/index.d.ts.map +1 -1
  90. package/resources/x/index.js +3 -1
  91. package/resources/x/index.js.map +1 -1
  92. package/resources/x/index.mjs +1 -0
  93. package/resources/x/index.mjs.map +1 -1
  94. package/resources/x/media.d.mts +48 -1
  95. package/resources/x/media.d.mts.map +1 -1
  96. package/resources/x/media.d.ts +48 -1
  97. package/resources/x/media.d.ts.map +1 -1
  98. package/resources/x/media.js.map +1 -1
  99. package/resources/x/media.mjs.map +1 -1
  100. package/resources/x/profile.d.mts +3 -3
  101. package/resources/x/profile.d.mts.map +1 -1
  102. package/resources/x/profile.d.ts +3 -3
  103. package/resources/x/profile.d.ts.map +1 -1
  104. package/resources/x/sports.d.mts +19 -1
  105. package/resources/x/sports.d.mts.map +1 -1
  106. package/resources/x/sports.d.ts +19 -1
  107. package/resources/x/sports.d.ts.map +1 -1
  108. package/resources/x/tweets/bookmark.d.mts +84 -0
  109. package/resources/x/tweets/bookmark.d.mts.map +1 -0
  110. package/resources/x/tweets/bookmark.d.ts +84 -0
  111. package/resources/x/tweets/bookmark.d.ts.map +1 -0
  112. package/resources/x/tweets/bookmark.js +55 -0
  113. package/resources/x/tweets/bookmark.js.map +1 -0
  114. package/resources/x/tweets/bookmark.mjs +51 -0
  115. package/resources/x/tweets/bookmark.mjs.map +1 -0
  116. package/resources/x/tweets/index.d.mts +1 -0
  117. package/resources/x/tweets/index.d.mts.map +1 -1
  118. package/resources/x/tweets/index.d.ts +1 -0
  119. package/resources/x/tweets/index.d.ts.map +1 -1
  120. package/resources/x/tweets/index.js +3 -1
  121. package/resources/x/tweets/index.js.map +1 -1
  122. package/resources/x/tweets/index.mjs +1 -0
  123. package/resources/x/tweets/index.mjs.map +1 -1
  124. package/resources/x/tweets/like.d.mts +2 -2
  125. package/resources/x/tweets/like.d.mts.map +1 -1
  126. package/resources/x/tweets/like.d.ts +2 -2
  127. package/resources/x/tweets/like.d.ts.map +1 -1
  128. package/resources/x/tweets/retweet.d.mts +2 -2
  129. package/resources/x/tweets/retweet.d.mts.map +1 -1
  130. package/resources/x/tweets/retweet.d.ts +2 -2
  131. package/resources/x/tweets/retweet.d.ts.map +1 -1
  132. package/resources/x/tweets/tweets.d.mts +45 -13
  133. package/resources/x/tweets/tweets.d.mts.map +1 -1
  134. package/resources/x/tweets/tweets.d.ts +45 -13
  135. package/resources/x/tweets/tweets.d.ts.map +1 -1
  136. package/resources/x/tweets/tweets.js +4 -0
  137. package/resources/x/tweets/tweets.js.map +1 -1
  138. package/resources/x/tweets/tweets.mjs +4 -0
  139. package/resources/x/tweets/tweets.mjs.map +1 -1
  140. package/resources/x/users/block.d.mts +84 -0
  141. package/resources/x/users/block.d.mts.map +1 -0
  142. package/resources/x/users/block.d.ts +84 -0
  143. package/resources/x/users/block.d.ts.map +1 -0
  144. package/resources/x/users/block.js +55 -0
  145. package/resources/x/users/block.js.map +1 -0
  146. package/resources/x/users/block.mjs +51 -0
  147. package/resources/x/users/block.mjs.map +1 -0
  148. package/resources/x/users/follow.d.mts +2 -2
  149. package/resources/x/users/follow.d.mts.map +1 -1
  150. package/resources/x/users/follow.d.ts +2 -2
  151. package/resources/x/users/follow.d.ts.map +1 -1
  152. package/resources/x/users/index.d.mts +3 -1
  153. package/resources/x/users/index.d.mts.map +1 -1
  154. package/resources/x/users/index.d.ts +3 -1
  155. package/resources/x/users/index.d.ts.map +1 -1
  156. package/resources/x/users/index.js +5 -1
  157. package/resources/x/users/index.js.map +1 -1
  158. package/resources/x/users/index.mjs +2 -0
  159. package/resources/x/users/index.mjs.map +1 -1
  160. package/resources/x/users/mute.d.mts +84 -0
  161. package/resources/x/users/mute.d.mts.map +1 -0
  162. package/resources/x/users/mute.d.ts +84 -0
  163. package/resources/x/users/mute.d.ts.map +1 -0
  164. package/resources/x/users/mute.js +55 -0
  165. package/resources/x/users/mute.js.map +1 -0
  166. package/resources/x/users/mute.mjs +51 -0
  167. package/resources/x/users/mute.mjs.map +1 -0
  168. package/resources/x/users/users.d.mts +359 -9
  169. package/resources/x/users/users.d.mts.map +1 -1
  170. package/resources/x/users/users.d.ts +359 -9
  171. package/resources/x/users/users.d.ts.map +1 -1
  172. package/resources/x/users/users.js +27 -1
  173. package/resources/x/users/users.js.map +1 -1
  174. package/resources/x/users/users.mjs +27 -1
  175. package/resources/x/users/users.mjs.map +1 -1
  176. package/resources/x/write-actions.d.mts +1 -1
  177. package/resources/x/write-actions.d.mts.map +1 -1
  178. package/resources/x/write-actions.d.ts +1 -1
  179. package/resources/x/write-actions.d.ts.map +1 -1
  180. package/resources/x/x.d.mts +17 -4
  181. package/resources/x/x.d.mts.map +1 -1
  182. package/resources/x/x.d.ts +17 -4
  183. package/resources/x/x.d.ts.map +1 -1
  184. package/resources/x/x.js +4 -0
  185. package/resources/x/x.js.map +1 -1
  186. package/resources/x/x.mjs +4 -0
  187. package/resources/x/x.mjs.map +1 -1
  188. package/src/client.ts +12 -2
  189. package/src/core/README.md +4 -0
  190. package/src/internal/README.md +6 -1
  191. package/src/resources/events.ts +10 -0
  192. package/src/resources/extractions.ts +125 -0
  193. package/src/resources/index.ts +2 -0
  194. package/src/resources/monitors/index.ts +2 -0
  195. package/src/resources/monitors/monitors.ts +49 -0
  196. package/src/resources/monitors/posts.ts +32 -0
  197. package/src/resources/shared.ts +223 -4
  198. package/src/resources/x/account-connection-attempts.ts +5 -0
  199. package/src/resources/x/account-connection-links.ts +215 -0
  200. package/src/resources/x/accounts.ts +15 -14
  201. package/src/resources/x/analysis.ts +618 -36
  202. package/src/resources/x/bookmarks.ts +6 -0
  203. package/src/resources/x/communities/communities.ts +12 -0
  204. package/src/resources/x/communities/join.ts +12 -0
  205. package/src/resources/x/dm.ts +12 -0
  206. package/src/resources/x/index.ts +16 -0
  207. package/src/resources/x/media.ts +64 -0
  208. package/src/resources/x/profile.ts +18 -0
  209. package/src/resources/x/sports.ts +22 -0
  210. package/src/resources/x/tweets/bookmark.ts +127 -0
  211. package/src/resources/x/tweets/index.ts +7 -0
  212. package/src/resources/x/tweets/like.ts +12 -0
  213. package/src/resources/x/tweets/retweet.ts +12 -0
  214. package/src/resources/x/tweets/tweets.ts +74 -10
  215. package/src/resources/x/users/block.ts +119 -0
  216. package/src/resources/x/users/follow.ts +12 -0
  217. package/src/resources/x/users/index.ts +20 -0
  218. package/src/resources/x/users/mute.ts +119 -0
  219. package/src/resources/x/users/users.ts +470 -7
  220. package/src/resources/x/write-actions.ts +6 -0
  221. package/src/resources/x/x.ts +50 -0
  222. package/src/version.ts +1 -1
  223. package/version.d.mts +1 -1
  224. package/version.d.ts +1 -1
  225. package/version.js +1 -1
  226. package/version.mjs +1 -1
@@ -214,7 +214,7 @@ export interface Community {
214
214
  * The creator's public profile, or the ID, username and badge alone when X sends
215
215
  * no profile
216
216
  */
217
- creator?: UserProfile | Community.UnionMember1;
217
+ creator?: (UserProfile & { verified: boolean }) | Community.UnionMember1;
218
218
 
219
219
  /**
220
220
  * About text for the community
@@ -469,6 +469,16 @@ export namespace CommunityTopic {
469
469
  }
470
470
  }
471
471
 
472
+ /**
473
+ * Why X shows no Community for the post. Omitted when X names no reason.
474
+ */
475
+ export interface CommunityUnavailable {
476
+ /**
477
+ * X's reason, as X writes it.
478
+ */
479
+ reason: string;
480
+ }
481
+
472
482
  /**
473
483
  * Content disclosure metadata shown by X when a tweet is labeled as paid
474
484
  * partnership content or AI-generated media.
@@ -596,6 +606,11 @@ export interface EmbeddedTweet {
596
606
  */
597
607
  communityName?: string;
598
608
 
609
+ /**
610
+ * Why X shows no Community for the post. Omitted when X names no reason.
611
+ */
612
+ communityUnavailable?: CommunityUnavailable;
613
+
599
614
  /**
600
615
  * Community Note presentation metadata returned by X.
601
616
  */
@@ -871,6 +886,11 @@ export interface Error {
871
886
  */
872
887
  reason?: string;
873
888
 
889
+ /**
890
+ * With insufficient_scope, the scope the API key needs for this route.
891
+ */
892
+ requiredScope?: 'write' | 'monitors' | 'exports' | 'billing' | 'full';
893
+
874
894
  /**
875
895
  * Seconds until the next permitted request.
876
896
  */
@@ -918,6 +938,7 @@ export namespace Error {
918
938
  | 'login_cooldown'
919
939
  | 'login_failed'
920
940
  | 'media_download_failed'
941
+ | 'media_not_uploaded'
921
942
  | 'media_too_large'
922
943
  | 'media_unavailable'
923
944
  | 'missing_params'
@@ -1140,6 +1161,86 @@ export type EventType =
1140
1161
  | 'profile.followers.changed'
1141
1162
  | 'profile.following.changed';
1142
1163
 
1164
+ /**
1165
+ * A page of posts from a read that takes the topic and imageShows filters. Without a
1166
+ * filter it is a PaginatedTweets page. With topic it holds topicFilter and each
1167
+ * post's topicScore. With imageShows it holds imageFilter and each post's
1168
+ * imageScore.
1169
+ */
1170
+ export type FilterablePaginatedTweets = PaginatedTweets | TopicFilteredTweets | ImageFilteredTweets;
1171
+
1172
+ /**
1173
+ * Posts kept by the image filter. Each kept post carries its imageScore. Follow
1174
+ * next_cursor to check the next posts.
1175
+ */
1176
+ export interface ImageFilteredTweets extends PaginatedTweets {
1177
+ /**
1178
+ * What the image filter asked & how many posts it kept.
1179
+ */
1180
+ imageFilter: ImageFilterSummary;
1181
+
1182
+ tweets: Array<ImageFilteredTweets.Tweet>;
1183
+ }
1184
+
1185
+ export namespace ImageFilteredTweets {
1186
+ /**
1187
+ * A post the image filter kept, with its score.
1188
+ */
1189
+ export interface Tweet extends SearchTweet {
1190
+ /**
1191
+ * How likely a photo shows what you asked for, from 0.5 to 1.
1192
+ */
1193
+ imageScore: number;
1194
+ }
1195
+ }
1196
+
1197
+ /**
1198
+ * What the image filter asked & how many posts it kept.
1199
+ */
1200
+ export interface ImageFilterSummary {
1201
+ /**
1202
+ * Posts whose photos were checked. Only kept posts are billed.
1203
+ */
1204
+ checked: number;
1205
+
1206
+ /**
1207
+ * The lowest imageScore a kept post has.
1208
+ */
1209
+ cutoff: 0.5;
1210
+
1211
+ /**
1212
+ * What you asked the photos to show.
1213
+ */
1214
+ imageShows: string;
1215
+
1216
+ /**
1217
+ * Posts whose photos show it, all returned & billed at 2 credits each.
1218
+ */
1219
+ kept: number;
1220
+
1221
+ /**
1222
+ * The question asked of each post's photos.
1223
+ */
1224
+ question: string;
1225
+
1226
+ /**
1227
+ * Posts without a safe photo & posts the check couldn't answer. They aren't
1228
+ * billed or returned.
1229
+ */
1230
+ unchecked: Array<ImageFilterSummary.Unchecked>;
1231
+ }
1232
+
1233
+ export namespace ImageFilterSummary {
1234
+ /**
1235
+ * A post the image filter left out without a score, with the reason.
1236
+ */
1237
+ export interface Unchecked {
1238
+ id: string;
1239
+
1240
+ reason: string;
1241
+ }
1242
+ }
1243
+
1143
1244
  /**
1144
1245
  * The other account of a following or follower event, with the profile fields a
1145
1246
  * user lookup returns. It holds the ID alone when X fails the profile lookup.
@@ -1163,14 +1264,29 @@ export interface MonitorFollow {
1163
1264
  */
1164
1265
  followedAtExact?: boolean;
1165
1266
 
1267
+ /**
1268
+ * Why a removed account is back, on following.added & follower.added. refollow
1269
+ * means the account followed again. return means X lists the old follow again, so
1270
+ * it never ended. It covers removals the monitor reported in the last 30 days. It
1271
+ * is missing on a first follow.
1272
+ */
1273
+ followKind?: 'refollow' | 'return';
1274
+
1166
1275
  /**
1167
1276
  * Why the account left the list, on following.removed & follower.removed.
1168
- * unavailable means X no longer serves the account. unfollowed means X's follow
1169
- * check says the follow ended. It is missing when X fails the check. Xquik sends no
1170
- * removal while X still confirms the follow.
1277
+ * unavailable means X shows no account for it, and unavailableReason says why.
1278
+ * unfollowed means the follow ended. It is missing when the cause isn't known.
1171
1279
  */
1172
1280
  reason?: 'unavailable' | 'unfollowed';
1173
1281
 
1282
+ /**
1283
+ * Why X shows no account, when reason is unavailable. not_found means the account
1284
+ * no longer exists, as X answers for a deactivated or deleted account. suspended
1285
+ * means X suspended it. A user lookup of the ID answers user_not_found with the
1286
+ * same reason.
1287
+ */
1288
+ unavailableReason?: 'not_found' | 'suspended';
1289
+
1174
1290
  [k: string]: unknown;
1175
1291
  }
1176
1292
 
@@ -1200,11 +1316,25 @@ export interface PaginatedTweets {
1200
1316
 
1201
1317
  tweets: Array<SearchTweet>;
1202
1318
 
1319
+ /**
1320
+ * Present on a last page that X cut short. `stalled` means X returned no new
1321
+ * results 2 times in a row, 30 s apart. The list may hold more. Read it again
1322
+ * later without cursor.
1323
+ */
1324
+ endReason?: 'stalled';
1325
+
1203
1326
  /**
1204
1327
  * Whole number from 0.
1205
1328
  */
1206
1329
  filtered_count?: number;
1207
1330
 
1331
+ /**
1332
+ * Present on an empty last page when X shows this account's timeline to nobody.
1333
+ * The page is empty because of that, so it doesn't mean the account posted
1334
+ * nothing. A retry returns the same page.
1335
+ */
1336
+ hiddenTimeline?: true;
1337
+
1208
1338
  /**
1209
1339
  * How far back a filtered Latest search has read, in UTC. Every newer post was
1210
1340
  * checked, so an empty page still moves this time back.
@@ -1290,6 +1420,13 @@ export interface PaginatedUsers {
1290
1420
 
1291
1421
  users: Array<UserProfile>;
1292
1422
 
1423
+ /**
1424
+ * Present on a last page that X cut short. `stalled` means X returned no new
1425
+ * results 2 times in a row, 30 s apart. The list may hold more. Read it again
1426
+ * later without cursor.
1427
+ */
1428
+ endReason?: 'stalled';
1429
+
1293
1430
  /**
1294
1431
  * Whole number from 0.
1295
1432
  */
@@ -1354,6 +1491,11 @@ export interface SearchTweet {
1354
1491
  */
1355
1492
  communityName?: string;
1356
1493
 
1494
+ /**
1495
+ * Why X shows no Community for the post. Omitted when X names no reason.
1496
+ */
1497
+ communityUnavailable?: CommunityUnavailable;
1498
+
1357
1499
  /**
1358
1500
  * Community Note presentation metadata returned by X.
1359
1501
  */
@@ -2820,6 +2962,77 @@ export namespace SoftIntervention {
2820
2962
  }
2821
2963
  }
2822
2964
 
2965
+ /**
2966
+ * Posts kept by the topic filter. Each kept post carries its topicScore. Follow
2967
+ * next_cursor to check the next posts.
2968
+ */
2969
+ export interface TopicFilteredTweets extends PaginatedTweets {
2970
+ /**
2971
+ * What the topic filter asked & how many posts it kept.
2972
+ */
2973
+ topicFilter: TopicFilterSummary;
2974
+
2975
+ tweets: Array<TopicFilteredTweets.Tweet>;
2976
+ }
2977
+
2978
+ export namespace TopicFilteredTweets {
2979
+ /**
2980
+ * A post the topic filter kept, with its score.
2981
+ */
2982
+ export interface Tweet extends SearchTweet {
2983
+ /**
2984
+ * How likely the post is about the topic, from 0.5 to 1.
2985
+ */
2986
+ topicScore: number;
2987
+ }
2988
+ }
2989
+
2990
+ /**
2991
+ * What the topic filter asked & how many posts it kept.
2992
+ */
2993
+ export interface TopicFilterSummary {
2994
+ /**
2995
+ * Posts checked. Only kept posts are billed.
2996
+ */
2997
+ checked: number;
2998
+
2999
+ /**
3000
+ * The lowest topicScore a kept post has.
3001
+ */
3002
+ cutoff: 0.5;
3003
+
3004
+ /**
3005
+ * Posts about the topic, all returned & billed at 2 credits each.
3006
+ */
3007
+ kept: number;
3008
+
3009
+ /**
3010
+ * The question asked of each post.
3011
+ */
3012
+ question: string;
3013
+
3014
+ /**
3015
+ * The topic you sent.
3016
+ */
3017
+ topic: string;
3018
+
3019
+ /**
3020
+ * Posts the check couldn't answer. They aren't billed or returned.
3021
+ */
3022
+ unchecked: Array<TopicFilterSummary.Unchecked>;
3023
+ }
3024
+
3025
+ export namespace TopicFilterSummary {
3026
+ /**
3027
+ * A post the topic filter left out without a score, with the reason.
3028
+ */
3029
+ export interface Unchecked {
3030
+ id: string;
3031
+
3032
+ reason: string;
3033
+ }
3034
+ }
3035
+
2823
3036
  /**
2824
3037
  * Tweet media.
2825
3038
  */
@@ -3109,6 +3322,12 @@ export interface UserListPage extends PaginatedUsers {
3109
3322
  * list's last.
3110
3323
  */
3111
3324
  scanLimit?: UserListPage.ScanLimit;
3325
+
3326
+ /**
3327
+ * Present on the last page of an empty list whose profile counts 0 accounts in
3328
+ * it.
3329
+ */
3330
+ windowComplete?: true;
3112
3331
  }
3113
3332
 
3114
3333
  export namespace UserListPage {
@@ -55,6 +55,11 @@ export namespace AccountConnectionAttemptRetrieveResponse {
55
55
  object: 'x_account_connection_attempt';
56
56
 
57
57
  status: 'success';
58
+
59
+ /**
60
+ * The connected account's ID.
61
+ */
62
+ accountId?: string;
58
63
  }
59
64
 
60
65
  /**
@@ -0,0 +1,215 @@
1
+ // SPDX-FileCopyrightText: 2026 Xquik contributors
2
+ //
3
+ // SPDX-License-Identifier: Apache-2.0
4
+
5
+ import { APIResource } from '../../core/resource';
6
+ import { APIPromise } from '../../core/api-promise';
7
+ import { RequestOptions } from '../../internal/request-options';
8
+ import { path } from '../../internal/utils/path';
9
+
10
+ /**
11
+ * Connected X account management
12
+ */
13
+ export class AccountConnectionLinks extends APIResource {
14
+ /**
15
+ * Creates a link to a page Xquik hosts, where a person connects an X account with
16
+ * no Xquik signup. Your backend never receives their password or 2FA secret, and
17
+ * the account belongs to you. Send `accountId` to reconnect 1 of your accounts
18
+ * instead. Connecting is free. Takes a Full access API key holding
19
+ * `connectsXAccounts`, or a dashboard session. The link works for 30 minutes, &
20
+ * the response is the only place its token appears. A link a key made stops while
21
+ * that key is paused or loses `connectsXAccounts`, & for good once it's revoked,
22
+ * rotated, expired or deleted.
23
+ *
24
+ * @example
25
+ * ```ts
26
+ * const accountConnectionLink =
27
+ * await client.x.accountConnectionLinks.create({
28
+ * reference: 'user-42',
29
+ * });
30
+ * ```
31
+ */
32
+ create(
33
+ body: AccountConnectionLinkCreateParams | null | undefined = {},
34
+ options?: RequestOptions,
35
+ ): APIPromise<AccountConnectionLinkCreateResponse> {
36
+ return this._client.post('/x/account-connection-links', { body, ...options });
37
+ }
38
+
39
+ /**
40
+ * Reads what happened on a link. `status` reads `connected` once the person
41
+ * finishes, with `xUserId`, `xUsername` & `health`. It never holds the token.
42
+ * Takes a Full access API key holding `connectsXAccounts`, or a dashboard session.
43
+ *
44
+ * @example
45
+ * ```ts
46
+ * const accountConnectionLink =
47
+ * await client.x.accountConnectionLinks.retrieve(
48
+ * 'xlink_AAAAAAAAAAAAAAAA',
49
+ * );
50
+ * ```
51
+ */
52
+ retrieve(id: string, options?: RequestOptions): APIPromise<XAccountConnectionLink> {
53
+ return this._client.get(path`/x/account-connection-links/${id}`, options);
54
+ }
55
+
56
+ /**
57
+ * Lists your connect links, newest first, with `apiKeyId` naming the API key that
58
+ * made each one, or null for a dashboard session. Use it to find and revoke the
59
+ * links a leaked key made. It never holds a token. Takes a Full access API key
60
+ * holding `connectsXAccounts`, or a dashboard session.
61
+ *
62
+ * @example
63
+ * ```ts
64
+ * const accountConnectionLinks =
65
+ * await client.x.accountConnectionLinks.list();
66
+ * ```
67
+ */
68
+ list(
69
+ query: AccountConnectionLinkListParams | null | undefined = {},
70
+ options?: RequestOptions,
71
+ ): APIPromise<AccountConnectionLinkListResponse> {
72
+ return this._client.get('/x/account-connection-links', { query, ...options });
73
+ }
74
+
75
+ /**
76
+ * Stops a link working. An account it already connected stays connected. Takes a
77
+ * Full access API key holding `connectsXAccounts`, or a dashboard session.
78
+ *
79
+ * @example
80
+ * ```ts
81
+ * const accountConnectionLink =
82
+ * await client.x.accountConnectionLinks.delete(
83
+ * 'xlink_AAAAAAAAAAAAAAAA',
84
+ * );
85
+ * ```
86
+ */
87
+ delete(id: string, options?: RequestOptions): APIPromise<AccountConnectionLinkDeleteResponse> {
88
+ return this._client.delete(path`/x/account-connection-links/${id}`, options);
89
+ }
90
+ }
91
+
92
+ /**
93
+ * A link where a person connects an X account on Xquik's page.
94
+ */
95
+ export interface XAccountConnectionLink {
96
+ id: string;
97
+
98
+ accountId: string | null;
99
+
100
+ /**
101
+ * The ID of the API key that made the link, or null when a dashboard session made
102
+ * it.
103
+ */
104
+ apiKeyId: string | null;
105
+
106
+ completedAt: string | null;
107
+
108
+ createdAt: string;
109
+
110
+ expiresAt: string;
111
+
112
+ /**
113
+ * Why the last login didn't finish.
114
+ */
115
+ failure: string | null;
116
+
117
+ health: string | null;
118
+
119
+ object: 'x_account_connection_link';
120
+
121
+ purpose: 'connect' | 'reconnect';
122
+
123
+ reference: string | null;
124
+
125
+ returnUrl: string | null;
126
+
127
+ /**
128
+ * `failed` means 5 logins were refused, so make a new link. `revoked` means you
129
+ * revoked it, or the key that made it is paused, revoked, expired, no longer Full
130
+ * access or without `connectsXAccounts`. A link whose key resumes within its 30
131
+ * minutes reads `pending` again.
132
+ */
133
+ status: 'pending' | 'connecting' | 'requires_email_code' | 'connected' | 'failed' | 'expired' | 'revoked';
134
+
135
+ xUserId: string | null;
136
+
137
+ xUsername: string | null;
138
+
139
+ /**
140
+ * Present only in the response that creates the link.
141
+ */
142
+ url?: string;
143
+ }
144
+
145
+ /**
146
+ * A link where a person connects an X account on Xquik's page.
147
+ */
148
+ export interface AccountConnectionLinkCreateResponse extends XAccountConnectionLink {
149
+ /**
150
+ * The page to open. Its fragment holds the token, so treat it as a secret & keep
151
+ * it out of logs.
152
+ */
153
+ url: string;
154
+ }
155
+
156
+ /**
157
+ * Your connect links, newest first.
158
+ */
159
+ export interface AccountConnectionLinkListResponse {
160
+ hasMore: boolean;
161
+
162
+ links: Array<XAccountConnectionLink>;
163
+
164
+ /**
165
+ * Pass unchanged as cursor while hasMore is true.
166
+ */
167
+ nextCursor?: string;
168
+ }
169
+
170
+ export interface AccountConnectionLinkDeleteResponse {
171
+ success: true;
172
+ }
173
+
174
+ export interface AccountConnectionLinkCreateParams {
175
+ /**
176
+ * The ID of 1 of your X accounts. The link then reconnects that account.
177
+ */
178
+ accountId?: string;
179
+
180
+ /**
181
+ * Your own ID for this person. It comes back when you read the link.
182
+ */
183
+ reference?: string;
184
+
185
+ /**
186
+ * A public https URL the page offers as a button once the account connects. Xquik
187
+ * never redirects by itself, & never adds the token.
188
+ */
189
+ returnUrl?: string;
190
+ }
191
+
192
+ export interface AccountConnectionLinkListParams {
193
+ /**
194
+ * Previous nextCursor. The after alias also works. Offset pagination is not
195
+ * supported.
196
+ */
197
+ cursor?: string;
198
+
199
+ /**
200
+ * Maximum items per page, from 1 to 10,000. Default 200. Pass nextCursor as cursor
201
+ * for the next page.
202
+ */
203
+ limit?: number;
204
+ }
205
+
206
+ export declare namespace AccountConnectionLinks {
207
+ export {
208
+ type XAccountConnectionLink as XAccountConnectionLink,
209
+ type AccountConnectionLinkCreateResponse as AccountConnectionLinkCreateResponse,
210
+ type AccountConnectionLinkListResponse as AccountConnectionLinkListResponse,
211
+ type AccountConnectionLinkDeleteResponse as AccountConnectionLinkDeleteResponse,
212
+ type AccountConnectionLinkCreateParams as AccountConnectionLinkCreateParams,
213
+ type AccountConnectionLinkListParams as AccountConnectionLinkListParams,
214
+ };
215
+ }
@@ -243,21 +243,10 @@ export interface AccountBulkRetryResponse {
243
243
  }
244
244
 
245
245
  /**
246
- * Sanitized X account summary returned by connect and reauth.
246
+ * The account once the sign-in finishes. While it still runs or waits on an email
247
+ * code, the same pending attempt or challenge that `create` returns.
247
248
  */
248
- export interface AccountReauthResponse {
249
- id: string;
250
-
251
- createdAt: string;
252
-
253
- health: 'healthy' | 'locked' | 'needsReauth' | 'recovering' | 'suspended' | 'temporaryIssue';
254
-
255
- status: 'active';
256
-
257
- xUserId: string;
258
-
259
- xUsername: string;
260
- }
249
+ export type AccountReauthResponse = AccountCreateResponse;
261
250
 
262
251
  export interface AccountCreateParams {
263
252
  /**
@@ -279,6 +268,12 @@ export interface AccountCreateParams {
279
268
  * X username of the account to connect, with or without @
280
269
  */
281
270
  username: string;
271
+
272
+ /**
273
+ * An ID you generate to read this attempt's status, even if the response never
274
+ * reaches you. Leave it out to get one in a pending response.
275
+ */
276
+ connection_attempt_id?: string;
282
277
  }
283
278
 
284
279
  export interface AccountListParams {
@@ -310,6 +305,12 @@ export interface AccountReauthParams {
310
305
  */
311
306
  password: string;
312
307
 
308
+ /**
309
+ * An ID you generate to read this reconnect's status, even if the response never
310
+ * reaches you. Leave it out to get one in a pending response.
311
+ */
312
+ connection_attempt_id?: string;
313
+
313
314
  /**
314
315
  * Email for the X account (updates stored email)
315
316
  */