Repository navigation
Expand file tree
/
Copy pathindex.d.ts
More file actions
1316 lines (1106 loc) · 48.5 KB
/
Copy pathindex.d.ts
File metadata and controls
1316 lines (1106 loc) · 48.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// ═══════════════════════════════════════════════════════════════════════════════
// XActions — TypeScript Type Declarations
// The Complete X/Twitter Automation Toolkit
// by nichxbt
// ═══════════════════════════════════════════════════════════════════════════════
import type { Browser, Page } from 'puppeteer';
// ── Core Types ──────────────────────────────────────────────────────────────
export interface BrowserOptions {
headless?: boolean;
proxy?: string;
userDataDir?: string;
args?: string[];
}
export interface ScrapeOptions {
limit?: number;
format?: 'json' | 'csv';
output?: string;
}
// ── Profile ─────────────────────────────────────────────────────────────────
export interface ScrapedProfile {
name: string;
username: string;
bio: string;
location?: string;
website?: string;
joinDate?: string;
followers: number;
following: number;
tweets: number;
verified: boolean;
avatar?: string;
header?: string;
}
// ── User ────────────────────────────────────────────────────────────────────
export interface User {
name: string;
username: string;
bio?: string;
followers?: number;
following?: number;
verified?: boolean;
followsBack?: boolean;
}
// ── Tweet ───────────────────────────────────────────────────────────────────
export interface ScrapedTweet {
id: string;
text: string;
author: string;
authorUsername: string;
timestamp: string;
likes: number;
retweets: number;
replies: number;
views?: number;
url: string;
media?: MediaItem[];
isRetweet?: boolean;
isQuote?: boolean;
quotedTweet?: ScrapedTweet;
}
export interface MediaItem {
type: 'image' | 'video' | 'gif';
url: string;
thumbnailUrl?: string;
width?: number;
height?: number;
duration?: number;
}
// ── Thread ──────────────────────────────────────────────────────────────────
export interface Thread {
author: string;
tweets: ScrapedTweet[];
totalTweets: number;
text: string;
}
// ── Video ───────────────────────────────────────────────────────────────────
export interface VideoResult {
url: string;
variants: VideoVariant[];
thumbnail?: string;
duration?: number;
}
export interface VideoVariant {
url: string;
bitrate?: number;
contentType: string;
}
// ── Bookmark ────────────────────────────────────────────────────────────────
export interface Bookmark {
tweet: ScrapedTweet;
savedAt?: string;
}
// ── DM ──────────────────────────────────────────────────────────────────────
export interface Conversation {
id: string;
participants: User[];
lastMessage: string;
lastMessageTime: string;
unread: boolean;
}
export interface DirectMessage {
id: string;
text: string;
sender: string;
recipient: string;
timestamp: string;
media?: MediaItem[];
}
// ── Analytics ───────────────────────────────────────────────────────────────
export interface Analytics {
followers: number;
following: number;
tweets: number;
impressions?: number;
profileVisits?: number;
mentions?: number;
period?: string;
}
export interface PostAnalytics {
tweet: ScrapedTweet;
impressions: number;
engagements: number;
engagementRate: number;
likes: number;
retweets: number;
replies: number;
clicks?: number;
profileClicks?: number;
}
// ── Sentiment ───────────────────────────────────────────────────────────────
export interface SentimentResult {
score: number;
label: 'positive' | 'neutral' | 'negative';
confidence: number;
keywords: string[];
}
// ── Workflow ────────────────────────────────────────────────────────────────
export interface Workflow {
id: string;
name: string;
description?: string;
trigger: WorkflowTrigger;
steps: WorkflowStep[];
enabled: boolean;
createdAt: string;
}
export interface WorkflowTrigger {
type: 'manual' | 'schedule' | 'webhook';
cron?: string;
}
export interface WorkflowStep {
action?: string;
target?: string;
input?: string;
output?: string;
condition?: string;
limit?: number;
}
export interface WorkflowResult {
workflowId: string;
status: 'success' | 'error' | 'partial';
steps: WorkflowStepResult[];
duration: number;
}
export interface WorkflowStepResult {
step: number;
action: string;
status: 'success' | 'skipped' | 'error';
output?: unknown;
error?: string;
duration: number;
}
// ── Stream ──────────────────────────────────────────────────────────────────
export interface Stream {
id: string;
type: 'tweet' | 'follower' | 'mention';
username: string;
interval: number;
status: 'active' | 'stopped';
pollCount: number;
}
// ── Reputation ──────────────────────────────────────────────────────────────
export interface ReputationMonitor {
id: string;
target: string;
type: 'mentions' | 'keyword' | 'replies';
interval: number;
status: 'active' | 'stopped';
}
export interface ReputationReport {
username: string;
period: string;
sentimentDistribution: {
positive: number;
neutral: number;
negative: number;
};
topPositive: ScrapedTweet[];
topNegative: ScrapedTweet[];
timeline: Array<{ date: string; averageSentiment: number; count: number }>;
keywords: Array<{ word: string; count: number }>;
alerts: string[];
}
// ── Export ───────────────────────────────────────────────────────────────────
export interface ExportResult {
username: string;
formats: string[];
files: string[];
stats: {
profile: boolean;
tweets: number;
followers: number;
following: number;
bookmarks: number;
};
}
// ── Plugin ──────────────────────────────────────────────────────────────────
export interface Plugin {
name: string;
version: string;
description: string;
tools?: unknown[];
scrapers?: Record<string, Function>;
routes?: unknown[];
actions?: Record<string, Function>;
}
// ── Core Functions ──────────────────────────────────────────────────────────
/** Launch a Puppeteer browser with stealth mode */
export function createBrowser(options?: BrowserOptions): Promise<Browser>;
/** Create a new stealth page in the browser */
export function createPage(browser: Browser): Promise<Page>;
/** Scrape a user's profile data */
export function scrapeProfile(page: Page, username: string): Promise<ScrapedProfile>;
/** Scrape a user's followers */
export function scrapeFollowers(page: Page, username: string, options?: ScrapeOptions): Promise<User[]>;
/** Scrape a user's following list */
export function scrapeFollowing(page: Page, username: string, options?: ScrapeOptions): Promise<User[]>;
/** Scrape a user's tweets */
export function scrapeTweets(page: Page, username: string, options?: ScrapeOptions): Promise<ScrapedTweet[]>;
/** Search tweets by query */
export function searchTweets(page: Page, query: string, options?: ScrapeOptions): Promise<ScrapedTweet[]>;
/** Log a page in with an X auth_token cookie */
export function loginWithCookie(page: Page, authToken: string): Promise<void>;
/** Scrape every tweet in a thread, starting from the given tweet URL */
export function scrapeThread(page: Page, tweetUrl: string): Promise<ThreadTweet[]>;
/** Scrape the accounts that liked a tweet */
export function scrapeLikes(page: Page, tweetUrl: string, options?: ScrapeOptions): Promise<User[]>;
/** Scrape recent tweets for a hashtag */
export function scrapeHashtag(page: Page, hashtag: string, options?: ScrapeOptions): Promise<ScrapedTweet[]>;
/** Scrape the images and videos an account has posted */
export function scrapeMedia(page: Page, username: string, options?: ScrapeOptions): Promise<ScrapedMediaItem[]>;
/** Scrape the members of an X List by its URL */
export function scrapeListMembers(page: Page, listUrl: string, options?: ScrapeOptions): Promise<User[]>;
/** Scrape the logged-in account's bookmarks */
export function scrapeBookmarks(page: Page, options?: ScrapeOptions): Promise<ScrapedTweet[]>;
/** Scrape the logged-in account's notifications */
export function scrapeNotifications(page: Page, options?: ScrapeOptions): Promise<ScrapedNotification[]>;
/** Scrape the trending topics for the logged-in account */
export function scrapeTrending(page: Page, options?: ScrapeOptions): Promise<ScrapedTrend[]>;
/** Scrape the members of an X Community by its URL */
export function scrapeCommunityMembers(page: Page, communityUrl: string, options?: ScrapeOptions): Promise<User[]>;
/** Find live and scheduled X Spaces matching a search query */
export function scrapeSpaces(page: Page, query: string, options?: ScrapeOptions): Promise<ScrapedSpace[]>;
/** Write data to a JSON file; resolves with the filename */
export function exportToJSON(data: unknown, filename: string): Promise<string>;
/** Write an array of flat records to a CSV file; resolves with the filename */
export function exportToCSV(data: Record<string, unknown>[], filename: string): Promise<string>;
// ── Puppeteer scraper result shapes ─────────────────────────────────────────
export interface ThreadTweet {
id: string | null;
text: string | null;
timestamp: string | null;
url: string | null;
isMainAuthor: boolean;
platform: 'twitter';
}
export interface ScrapedMediaItem {
type: 'image' | 'video';
url: string;
tweetUrl?: string;
tweetId?: string;
platform?: 'twitter';
}
export interface ScrapedNotification {
text: string;
time: string | null;
links: string[];
platform: 'twitter';
}
export interface ScrapedTrend {
category: string | null;
topic: string;
posts: string | null;
platform: 'twitter';
}
export interface ScrapedSpace {
title: string | null;
host?: string | null;
status?: string | null;
link: string;
platform: 'twitter';
}
// ── Multi-platform scrape() and adapter system ──────────────────────────────
export type PlatformName = 'twitter' | 'x' | 'bluesky' | 'bsky' | 'mastodon' | 'masto' | 'threads';
export type ScrapeAction =
| 'profile' | 'followers' | 'following' | 'tweets' | 'posts' | 'search' | 'hashtag'
| 'trending' | 'thread' | 'likes' | 'media' | 'listMembers' | 'bookmarks'
| 'notifications' | 'communityMembers' | 'spaces' | 'feed';
export interface UnifiedScrapeOptions {
/** Target username (profile, followers, following, tweets, media) */
username?: string;
/** Search query (search action) */
query?: string;
/** Hashtag without the leading # (hashtag action) */
hashtag?: string;
/** Tweet, list, or community URL for URL-addressed actions */
url?: string;
listUrl?: string;
communityUrl?: string;
/** Bluesky feed URI (feed action) */
feedUri?: string;
/** Max results */
limit?: number;
/** Mastodon instance URL */
instance?: string;
/** Mastodon access token */
accessToken?: string;
/** Bluesky service URL, handle, and app password */
service?: string;
identifier?: string;
password?: string;
/** Existing Puppeteer page (Twitter, Threads); one is created when omitted */
page?: Page;
/** Options for the browser that is auto-created when no page is given */
browserOptions?: BrowserOptions;
/** X auth_token cookie applied to an auto-created page */
authToken?: string;
/** Existing API client (Bluesky, Mastodon) */
client?: unknown;
/** Close the auto-created browser when done (default true) */
autoClose?: boolean;
[key: string]: unknown;
}
/** A platform module: every scraper it implements plus its browser/client factories */
export type PlatformModule = Record<string, (...args: any[]) => any>;
/** Registry of platform modules, keyed by name and alias */
export declare const platforms: Record<PlatformName, PlatformModule>;
/** Look up a platform module by name; throws on an unknown platform */
export function getPlatform(platform: string): PlatformModule;
/**
* Unified scrape entry point. Dispatches to the platform module and, when no
* page or client is supplied, creates and tears down one for the call.
*/
export function scrape(platform: PlatformName | string, action: ScrapeAction | string, options?: UnifiedScrapeOptions): Promise<unknown>;
/** Resolve a plugin-contributed scraper's handler by name */
export function getPluginScraper(name: string): Promise<Function | undefined>;
export interface AdapterDependencyStatus {
available: boolean;
message?: string;
}
export interface AdapterInfo {
name: string;
description?: string;
supportsJavaScript?: boolean;
requiresBrowser?: boolean;
available: boolean;
installHint?: string | null;
error?: string;
}
/**
* Base class for scraping-framework adapters (Puppeteer, Playwright, HTTP).
* Subclass it and register the class with `registerAdapter`.
*/
export declare class BaseAdapter {
name: string;
description: string;
supportsJavaScript: boolean;
requiresBrowser: boolean;
checkDependencies(): Promise<AdapterDependencyStatus>;
launch(options?: Record<string, unknown>): Promise<unknown>;
newPage(browser: unknown, options?: Record<string, unknown>): Promise<unknown>;
goto(page: unknown, url: string, options?: Record<string, unknown>): Promise<unknown>;
evaluate<T = unknown>(page: unknown, fn: (...args: any[]) => T, ...args: unknown[]): Promise<T>;
queryAll<T = unknown>(page: unknown, selector: string, mapFn: (el: Element) => T): Promise<T[]>;
getContent(page: unknown): Promise<string>;
setCookie(page: unknown, cookie: CookieEntry): Promise<void>;
scroll(page: unknown, options?: Record<string, unknown>): Promise<void>;
screenshot(page: unknown, options?: Record<string, unknown>): Promise<unknown>;
waitForSelector(page: unknown, selector: string, options?: Record<string, unknown>): Promise<unknown>;
closePage(page: unknown): Promise<void>;
closeBrowser(browser: unknown): Promise<void>;
getInfo(): Pick<AdapterInfo, 'name' | 'description' | 'supportsJavaScript' | 'requiresBrowser'>;
}
/** Get an adapter instance by name (defaults to the global default adapter) */
export function getAdapter(name?: string): Promise<BaseAdapter>;
/** Get the first adapter whose dependencies are installed, preferring the given name */
export function getAvailableAdapter(preferred?: string): Promise<BaseAdapter>;
/** Set the global default adapter name */
export function setDefaultAdapter(name: string): void;
/** Read the global default adapter name */
export function getDefaultAdapterName(): string;
/** Register an adapter class under a name */
export function registerAdapter(name: string, AdapterClass: typeof BaseAdapter): void;
/** Names of every registered adapter */
export function listAdapters(): string[];
/** Info and availability for every registered adapter */
export function getAdapterInfo(): Promise<AdapterInfo[]>;
/** Dependency status keyed by adapter name */
export function checkAvailability(): Promise<Record<string, AdapterDependencyStatus>>;
// ── HTTP scraper (direct GraphQL, no browser) ───────────────────────────────
export interface HttpScraperOptions {
/** Browser cookie string for authentication, e.g. "auth_token=...; ct0=..." */
cookies?: string;
/** HTTP or SOCKS5 proxy URL */
proxy?: string;
/** How to handle rate limits: wait for the reset or throw */
rateLimitStrategy?: 'wait' | 'error';
[key: string]: unknown;
}
/**
* Scraper returned by `createHttpScraper`: every HTTP scraper function with
* the client argument already bound.
*/
export interface HttpScraper {
client: unknown;
scrapeProfile(username: string): Promise<Record<string, unknown>>;
scrapeProfileById(userId: string): Promise<Record<string, unknown>>;
parseUserData(raw: Record<string, unknown>): Record<string, unknown>;
scrapeFollowers(username: string, options?: ScrapeOptions): Promise<Record<string, unknown>[]>;
scrapeFollowing(username: string, options?: ScrapeOptions): Promise<Record<string, unknown>[]>;
scrapeNonFollowers(username: string, options?: ScrapeOptions): Promise<Record<string, unknown>[]>;
scrapeLikers(tweetId: string, options?: ScrapeOptions): Promise<Record<string, unknown>[]>;
scrapeRetweeters(tweetId: string, options?: ScrapeOptions): Promise<Record<string, unknown>[]>;
scrapeListMembers(listId: string, options?: ScrapeOptions): Promise<Record<string, unknown>[]>;
scrapeTweets(username: string, options?: ScrapeOptions): Promise<Record<string, unknown>[]>;
scrapeTweetsAndReplies(username: string, options?: ScrapeOptions): Promise<Record<string, unknown>[]>;
scrapeTweetById(tweetId: string): Promise<Record<string, unknown>>;
parseTweetData(raw: Record<string, unknown>): Record<string, unknown>;
parseTimelineInstructions(instructions: unknown[]): Record<string, unknown>[];
scrapeThread(tweetId: string, options?: Record<string, unknown>): Promise<Record<string, unknown>[]>;
scrapeFullThread(tweetId: string, options?: Record<string, unknown>): Promise<Record<string, unknown>[]>;
scrapeConversation(tweetId: string, options?: Record<string, unknown>): Promise<Record<string, unknown>[]>;
reconstructThread(tweets: Record<string, unknown>[]): Record<string, unknown>[];
parseConversationModule(module: Record<string, unknown>): Record<string, unknown>[];
postTweet(text: string, options?: Record<string, unknown>): Promise<Record<string, unknown>>;
postThread(tweets: string[], options?: Record<string, unknown>): Promise<Record<string, unknown>[]>;
deleteTweet(tweetId: string): Promise<Record<string, unknown>>;
replyToTweet(tweetId: string, text: string, options?: Record<string, unknown>): Promise<Record<string, unknown>>;
quoteTweet(tweetId: string, text: string, options?: Record<string, unknown>): Promise<Record<string, unknown>>;
schedulePost(text: string, scheduledAt: Date | number | string, options?: Record<string, unknown>): Promise<Record<string, unknown>>;
likeTweet(tweetId: string): Promise<Record<string, unknown>>;
unlikeTweet(tweetId: string): Promise<Record<string, unknown>>;
retweet(tweetId: string): Promise<Record<string, unknown>>;
unretweet(tweetId: string): Promise<Record<string, unknown>>;
followUser(userId: string): Promise<Record<string, unknown>>;
unfollowUser(userId: string): Promise<Record<string, unknown>>;
followByUsername(username: string): Promise<Record<string, unknown>>;
blockUser(userId: string): Promise<Record<string, unknown>>;
unblockUser(userId: string): Promise<Record<string, unknown>>;
muteUser(userId: string): Promise<Record<string, unknown>>;
unmuteUser(userId: string): Promise<Record<string, unknown>>;
bookmarkTweet(tweetId: string): Promise<Record<string, unknown>>;
unbookmarkTweet(tweetId: string): Promise<Record<string, unknown>>;
pinTweet(tweetId: string): Promise<Record<string, unknown>>;
unpinTweet(tweetId: string): Promise<Record<string, unknown>>;
bulkUnfollow(userIds: string[], options?: Record<string, unknown>): Promise<Record<string, unknown>>;
bulkLike(tweetIds: string[], options?: Record<string, unknown>): Promise<Record<string, unknown>>;
bulkBlock(userIds: string[], options?: Record<string, unknown>): Promise<Record<string, unknown>>;
uploadMedia(input: string | Buffer, options?: Record<string, unknown>): Promise<Record<string, unknown>>;
uploadImage(input: string | Buffer, options?: Record<string, unknown>): Promise<Record<string, unknown>>;
uploadVideo(input: string | Buffer, options?: Record<string, unknown>): Promise<Record<string, unknown>>;
uploadGif(input: string | Buffer, options?: Record<string, unknown>): Promise<Record<string, unknown>>;
setAltText(mediaId: string, altText: string): Promise<Record<string, unknown>>;
scrapeMedia(username: string, options?: ScrapeOptions): Promise<Record<string, unknown>[]>;
downloadMedia(url: string, options?: Record<string, unknown>): Promise<Buffer | string>;
getVideoUrl(tweetId: string): Promise<string | null>;
}
/** Create an HTTP scraper (no browser) with every method bound to one client */
export function createHttpScraper(options?: HttpScraperOptions): Promise<HttpScraper>;
// ── Scrapers Module ─────────────────────────────────────────────────────────
export declare const scrapers: {
createBrowser: typeof createBrowser;
createPage: typeof createPage;
loginWithCookie: typeof loginWithCookie;
scrapeProfile: typeof scrapeProfile;
scrapeFollowers: typeof scrapeFollowers;
scrapeFollowing: typeof scrapeFollowing;
scrapeTweets: typeof scrapeTweets;
searchTweets: typeof searchTweets;
scrapeThread: typeof scrapeThread;
scrapeLikes: typeof scrapeLikes;
scrapeHashtag: typeof scrapeHashtag;
scrapeMedia: typeof scrapeMedia;
scrapeListMembers: typeof scrapeListMembers;
scrapeBookmarks: typeof scrapeBookmarks;
scrapeNotifications: typeof scrapeNotifications;
scrapeTrending: typeof scrapeTrending;
scrapeCommunityMembers: typeof scrapeCommunityMembers;
scrapeSpaces: typeof scrapeSpaces;
exportToJSON: typeof exportToJSON;
exportToCSV: typeof exportToCSV;
scrape: typeof scrape;
platforms: typeof platforms;
getPlatform: typeof getPlatform;
twitter: PlatformModule;
bluesky: PlatformModule;
mastodon: PlatformModule;
threads: PlatformModule;
getPluginScraper: typeof getPluginScraper;
getAdapter: typeof getAdapter;
getAvailableAdapter: typeof getAvailableAdapter;
setDefaultAdapter: typeof setDefaultAdapter;
getDefaultAdapterName: typeof getDefaultAdapterName;
registerAdapter: typeof registerAdapter;
listAdapters: typeof listAdapters;
getAdapterInfo: typeof getAdapterInfo;
checkAvailability: typeof checkAvailability;
BaseAdapter: typeof BaseAdapter;
};
// ── Managers ────────────────────────────────────────────────────────────────
export declare const articlePublisher: unknown;
export declare const bookmarkManager: unknown;
export declare const businessTools: unknown;
export declare const creatorStudio: unknown;
export declare const discoveryExplore: unknown;
export declare const dmManager: unknown;
export declare const engagementManager: unknown;
export declare const grokIntegration: unknown;
export declare const notificationManager: unknown;
export declare const pollCreator: unknown;
export declare const postComposer: unknown;
export declare const premiumManager: unknown;
export declare const profileManager: unknown;
export declare const settingsManager: unknown;
export declare const spacesManager: unknown;
// ── Plugin System ───────────────────────────────────────────────────────────
export declare const plugins: unknown;
export function initializePlugins(): Promise<void>;
export function installPlugin(name: string): Promise<Plugin>;
export function removePlugin(name: string): Promise<void>;
export function listPlugins(): Plugin[];
export function getPluginTools(): unknown[];
export function getPluginScrapers(): Record<string, Function>;
export function getPluginRoutes(): unknown[];
export function getPluginActions(): Record<string, Function>;
// ── Browser Scripts Catalog ─────────────────────────────────────────────────
export declare const browserScripts: Record<string, {
file: string;
description: string;
}>;
// ═══════════════════════════════════════════════════════════════════════════════
// HTTP Client (Track 01 — Programmatic Scraper)
// No Puppeteer required. Uses Twitter's internal GraphQL API via HTTP.
// ═══════════════════════════════════════════════════════════════════════════════
// ── Search Mode ─────────────────────────────────────────────────────────────
export declare const SearchMode: {
readonly Top: 'Top';
readonly Latest: 'Latest';
readonly Photos: 'Photos';
readonly Videos: 'Videos';
};
export type SearchModeType = typeof SearchMode[keyof typeof SearchMode];
// ── Scraper Options ─────────────────────────────────────────────────────────
export interface ScraperOptions {
/** Cookies string or array of {name, value} pairs */
cookies?: string | CookieEntry[];
/** Proxy URL (http, https, or socks5) */
proxy?: string;
/** Custom fetch implementation */
fetch?: typeof globalThis.fetch;
/** Request transform function applied before each request */
transform?: (request: RequestInit) => RequestInit | void;
}
export interface CookieEntry {
name: string;
value: string;
domain?: string;
path?: string;
}
export interface LoginCredentials {
username: string;
password: string;
email?: string;
}
export interface SendTweetOptions {
/** Media entity IDs to attach */
mediaIds?: string[];
/** Tweet ID to reply to */
replyTo?: string;
}
// ── Trend ───────────────────────────────────────────────────────────────────
export interface Trend {
name: string;
tweetCount: string;
url: string;
context: string;
}
// ── Poll ────────────────────────────────────────────────────────────────────
export interface PollOption {
label: string;
votes: number;
}
export interface Poll {
id: string;
options: PollOption[];
endDatetime: string | null;
votingStatus: 'open' | 'closed';
totalVotes: number;
}
// ── Client Tweet Model ──────────────────────────────────────────────────────
export interface ClientMediaItem {
id: string;
type: string;
url: string;
preview: string;
width: number;
height: number;
duration: number | null;
altText: string | null;
}
/**
* Tweet data model returned by the HTTP client Scraper.
* Created via `Tweet.fromGraphQL(raw)`.
*/
export declare class Tweet {
id: string;
text: string;
fullText: string;
username: string;
userId: string;
timeParsed: Date | null;
timestamp: number | null;
hashtags: string[];
mentions: string[];
urls: string[];
photos: Array<{ id: string; url: string; alt: string | null }>;
videos: Array<{ id: string; url: string; preview: string; duration: number | null }>;
thread: ClientTweet[];
inReplyToStatusId: string | null;
inReplyToStatus: ClientTweet | null;
quotedStatusId: string | null;
quotedStatus: ClientTweet | null;
isRetweet: boolean;
isReply: boolean;
isQuote: boolean;
retweetedStatus: ClientTweet | null;
likes: number;
retweets: number;
replies: number;
views: number;
bookmarkCount: number;
place: Record<string, unknown> | null;
sensitiveContent: boolean;
conversationId: string;
poll: Poll | null;
/**
* Parse a tweet from a raw Twitter GraphQL "tweet_results.result" object.
*/
static fromGraphQL(raw: Record<string, unknown>): Tweet | null;
}
/** @deprecated Use `Tweet`; kept for callers that imported the old alias */
export type ClientTweet = Tweet;
// ── Client Profile Model ───────────────────────────────────────────────────
export interface Birthdate {
day: number | null;
month: number | null;
year: number | null;
visibility: string;
}
/**
* User profile returned by the HTTP client Scraper.
* Created via `Profile.fromGraphQL(raw)`.
*/
export declare class Profile {
id: string;
username: string;
name: string;
bio: string;
location: string;
website: string;
joined: Date | null;
followersCount: number;
followingCount: number;
tweetCount: number;
likesCount: number;
listedCount: number;
mediaCount: number;
avatar: string;
banner: string;
verified: boolean;
protected: boolean;
birthdate: Birthdate | null;
pinnedTweetIds: string[];
isBlueVerified: boolean;
isGovernment: boolean;
isBusiness: boolean;
affiliatesCount: number;
canDm: boolean;
platform: string;
/** Full URL to profile on X */
readonly profileUrl: string;
/**
* Parse a profile from a raw Twitter GraphQL "user_results.result" object.
*/
static fromGraphQL(raw: Record<string, unknown>): Profile | null;
/** JSON-serializable representation */
toJSON(): Record<string, unknown>;
}
/** @deprecated Use `Profile`; kept for callers that imported the old alias */
export type ClientProfile = Profile;
// ── Client Message Model ───────────────────────────────────────────────────
/**
* Direct message returned by the HTTP client Scraper.
*/
export declare class Message {
id: string;
text: string;
senderId: string;
recipientId: string;
createdAt: Date | null;
mediaUrls: string[];
conversationId: string;
/**
* Parse a DM from a raw Twitter inbox API entry.
*/
static fromRaw(raw: Record<string, unknown>, conversationId?: string): Message | null;
/** JSON-serializable representation */
toJSON(): Record<string, unknown>;
}
/** @deprecated Use `Message`; kept for callers that imported the old alias */
export type ClientMessage = Message;
/**
* DM conversation object.
*/
export interface ClientConversation {
id: string;
type: 'ONE_TO_ONE' | 'GROUP_DM';
participantIds: string[];
lastMessage: Message | null;
updatedAt: Date | null;
}
// ── Error Classes ───────────────────────────────────────────────────────────
/**
* Base error for all XActions client errors.
*/
export declare class ScraperError extends Error {
code: string;
endpoint: string | null;
httpStatus: number | null;
rateLimitReset: number | null;
timestamp: Date;
constructor(message: string, code?: string, details?: Record<string, unknown>);
toString(): string;
toJSON(): Record<string, unknown>;
}
/**
* Thrown when authentication fails or is required.
*/
export declare class AuthenticationError extends ScraperError {
constructor(message: string, code?: string, details?: Record<string, unknown>);
}
/**
* Thrown when Twitter rate limits are exceeded.
*/
export declare class RateLimitError extends ScraperError {
retryAfter: number | null;
limit: number | null;
remaining: number;
resetAt: Date | null;
readonly retryAfterMs: number;
constructor(message?: string, details?: Record<string, unknown>);
}
/**
* Thrown when a requested resource does not exist.
*/
export declare class NotFoundError extends ScraperError {
constructor(message: string, code?: string, details?: Record<string, unknown>);
}
/**
* Wraps raw Twitter API errors with structured metadata.
*/
export declare class TwitterApiError extends ScraperError {
twitterErrorCode: number | null;
twitterMessage: string | null;
constructor(message: string, details?: Record<string, unknown>);
static fromTwitterError(error: Record<string, unknown>, details?: Record<string, unknown>): ScraperError;
static fromResponse(body: Record<string, unknown>, details?: Record<string, unknown>): ScraperError;
}
// ── Scraper Class ───────────────────────────────────────────────────────────
/**
* The main entry point for programmatic Twitter/X access via HTTP.
* No Puppeteer or browser required.
*
* @example
* ```js
* import { Scraper, SearchMode } from 'xactions/client';
*
* const scraper = new Scraper();
* await scraper.loadCookies('./cookies.json');
* const profile = await scraper.getProfile('elonmusk');
* for await (const tweet of scraper.getTweets('elonmusk', 20)) {
* console.log(tweet.text);
* }
* ```
*/
export declare class Scraper {
constructor(options?: ScraperOptions);
// ── Authentication ──────────────────────────────────────────────────
/** Log in with credentials (placeholder — use cookie-based auth until Track 02) */
login(credentials: LoginCredentials): Promise<void>;
/** Log out and clear all auth state */
logout(): Promise<void>;
/** Check if the scraper is authenticated */
isLoggedIn(): Promise<boolean>;
/** Get current cookies */
getCookies(): Promise<CookieEntry[]>;
/** Set cookies for authentication */
setCookies(cookies: CookieEntry[] | string): Promise<void>;
/** Save current cookies to a JSON file */
saveCookies(filePath: string): Promise<void>;
/** Load cookies from a JSON file */
loadCookies(filePath: string): Promise<void>;
// ── Users ───────────────────────────────────────────────────────────
/** Get a user's profile by screen name */
getProfile(username: string): Promise<ClientProfile>;
/** Get the authenticated user's profile */
me(): Promise<ClientProfile>;
/** Get a user's followers (requires userId, not username) */
getFollowers(userId: string, count?: number): AsyncGenerator<ClientProfile, void, undefined>;
/** Get accounts a user follows */
getFollowing(userId: string, count?: number): AsyncGenerator<ClientProfile, void, undefined>;
/** Follow a user by username */
followUser(username: string): Promise<void>;
/** Unfollow a user by username */
unfollowUser(username: string): Promise<void>;
// ── Tweets ──────────────────────────────────────────────────────────
/** Get a single tweet by ID */
getTweet(id: string): Promise<ClientTweet>;
/** Get tweets from a user's timeline */
getTweets(username: string, count?: number): AsyncGenerator<ClientTweet, void, undefined>;
/** Get tweets and replies from a user's timeline */
getTweetsAndReplies(username: string, count?: number): AsyncGenerator<ClientTweet, void, undefined>;
/** Get a user's liked tweets */
getLikedTweets(username: string, count?: number): AsyncGenerator<ClientTweet, void, undefined>;
/** Get the latest tweet from a user */
getLatestTweet(username: string): Promise<ClientTweet | null>;