x-twitter-scraper 0.4.1 → 0.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +21 -0
- package/README.md +1 -0
- package/client.d.mts +1 -1
- package/client.d.ts +1 -1
- package/client.js +1 -1
- package/client.mjs +1 -1
- package/package.json +1 -1
- package/resources/account.d.mts +2 -2
- package/resources/account.d.ts +2 -2
- package/resources/compose.d.mts +186 -65
- package/resources/compose.d.mts.map +1 -1
- package/resources/compose.d.ts +186 -65
- package/resources/compose.d.ts.map +1 -1
- package/resources/compose.js +5 -2
- package/resources/compose.js.map +1 -1
- package/resources/compose.mjs +5 -2
- package/resources/compose.mjs.map +1 -1
- package/resources/credits.d.mts +1 -1
- package/resources/credits.d.ts +1 -1
- package/resources/extractions.d.mts +4 -4
- package/resources/extractions.d.ts +4 -4
- package/resources/guest-wallets.d.mts +2 -2
- package/resources/guest-wallets.d.ts +2 -2
- package/resources/monitors/keywords.d.mts +4 -4
- package/resources/monitors/keywords.d.ts +4 -4
- package/resources/monitors/keywords.js +4 -4
- package/resources/monitors/keywords.mjs +4 -4
- package/resources/monitors/monitors.d.mts +5 -4
- package/resources/monitors/monitors.d.mts.map +1 -1
- package/resources/monitors/monitors.d.ts +5 -4
- package/resources/monitors/monitors.d.ts.map +1 -1
- package/resources/monitors/monitors.js +5 -4
- package/resources/monitors/monitors.js.map +1 -1
- package/resources/monitors/monitors.mjs +5 -4
- package/resources/monitors/monitors.mjs.map +1 -1
- package/resources/shared.d.mts +24 -8
- package/resources/shared.d.mts.map +1 -1
- package/resources/shared.d.ts +24 -8
- package/resources/shared.d.ts.map +1 -1
- package/resources/support/tickets.d.mts +67 -4
- package/resources/support/tickets.d.mts.map +1 -1
- package/resources/support/tickets.d.ts +67 -4
- package/resources/support/tickets.d.ts.map +1 -1
- package/resources/support/tickets.js +22 -4
- package/resources/support/tickets.js.map +1 -1
- package/resources/support/tickets.mjs +22 -4
- package/resources/support/tickets.mjs.map +1 -1
- package/resources/x/account-connection-challenges.d.mts +1 -1
- package/resources/x/account-connection-challenges.d.ts +1 -1
- package/resources/x/account-connection-challenges.js +1 -1
- package/resources/x/account-connection-challenges.mjs +1 -1
- package/resources/x/accounts.d.mts +9 -6
- package/resources/x/accounts.d.mts.map +1 -1
- package/resources/x/accounts.d.ts +9 -6
- package/resources/x/accounts.d.ts.map +1 -1
- package/resources/x/accounts.js +4 -2
- package/resources/x/accounts.js.map +1 -1
- package/resources/x/accounts.mjs +4 -2
- package/resources/x/accounts.mjs.map +1 -1
- package/resources/x/communities/communities.d.mts +360 -10
- package/resources/x/communities/communities.d.mts.map +1 -1
- package/resources/x/communities/communities.d.ts +360 -10
- package/resources/x/communities/communities.d.ts.map +1 -1
- package/resources/x/communities/communities.js +17 -4
- package/resources/x/communities/communities.js.map +1 -1
- package/resources/x/communities/communities.mjs +17 -4
- package/resources/x/communities/communities.mjs.map +1 -1
- package/resources/x/communities/join.d.mts +361 -7
- package/resources/x/communities/join.d.mts.map +1 -1
- package/resources/x/communities/join.d.ts +361 -7
- package/resources/x/communities/join.d.ts.map +1 -1
- package/resources/x/communities/join.js +20 -5
- package/resources/x/communities/join.js.map +1 -1
- package/resources/x/communities/join.mjs +20 -5
- package/resources/x/communities/join.mjs.map +1 -1
- package/resources/x/dm.d.mts +183 -5
- package/resources/x/dm.d.mts.map +1 -1
- package/resources/x/dm.d.ts +183 -5
- package/resources/x/dm.d.ts.map +1 -1
- package/resources/x/dm.js +9 -2
- package/resources/x/dm.js.map +1 -1
- package/resources/x/dm.mjs +9 -2
- package/resources/x/dm.mjs.map +1 -1
- package/resources/x/media.d.mts +178 -10
- package/resources/x/media.d.mts.map +1 -1
- package/resources/x/media.d.ts +178 -10
- package/resources/x/media.d.ts.map +1 -1
- package/resources/x/media.js +9 -5
- package/resources/x/media.js.map +1 -1
- package/resources/x/media.mjs +9 -5
- package/resources/x/media.mjs.map +1 -1
- package/resources/x/profile.d.mts +545 -14
- package/resources/x/profile.d.mts.map +1 -1
- package/resources/x/profile.d.ts +545 -14
- package/resources/x/profile.d.ts.map +1 -1
- package/resources/x/profile.js +25 -6
- package/resources/x/profile.js.map +1 -1
- package/resources/x/profile.mjs +25 -6
- package/resources/x/profile.mjs.map +1 -1
- package/resources/x/tweets/like.d.mts +358 -6
- package/resources/x/tweets/like.d.mts.map +1 -1
- package/resources/x/tweets/like.d.ts +358 -6
- package/resources/x/tweets/like.d.ts.map +1 -1
- package/resources/x/tweets/like.js +17 -4
- package/resources/x/tweets/like.js.map +1 -1
- package/resources/x/tweets/like.mjs +17 -4
- package/resources/x/tweets/like.mjs.map +1 -1
- package/resources/x/tweets/retweet.d.mts +358 -6
- package/resources/x/tweets/retweet.d.mts.map +1 -1
- package/resources/x/tweets/retweet.d.ts +358 -6
- package/resources/x/tweets/retweet.d.ts.map +1 -1
- package/resources/x/tweets/retweet.js +17 -4
- package/resources/x/tweets/retweet.js.map +1 -1
- package/resources/x/tweets/retweet.mjs +17 -4
- package/resources/x/tweets/retweet.mjs.map +1 -1
- package/resources/x/tweets/tweets.d.mts +376 -18
- package/resources/x/tweets/tweets.d.mts.map +1 -1
- package/resources/x/tweets/tweets.d.ts +376 -18
- package/resources/x/tweets/tweets.d.ts.map +1 -1
- package/resources/x/tweets/tweets.js +25 -6
- package/resources/x/tweets/tweets.js.map +1 -1
- package/resources/x/tweets/tweets.mjs +25 -6
- package/resources/x/tweets/tweets.mjs.map +1 -1
- package/resources/x/users/follow.d.mts +361 -7
- package/resources/x/users/follow.d.mts.map +1 -1
- package/resources/x/users/follow.d.ts +361 -7
- package/resources/x/users/follow.d.ts.map +1 -1
- package/resources/x/users/follow.js +20 -5
- package/resources/x/users/follow.js.map +1 -1
- package/resources/x/users/follow.mjs +20 -5
- package/resources/x/users/follow.mjs.map +1 -1
- package/resources/x/users/users.d.mts +181 -5
- package/resources/x/users/users.d.mts.map +1 -1
- package/resources/x/users/users.d.ts +181 -5
- package/resources/x/users/users.d.ts.map +1 -1
- package/resources/x/users/users.js +9 -2
- package/resources/x/users/users.js.map +1 -1
- package/resources/x/users/users.mjs +9 -2
- package/resources/x/users/users.mjs.map +1 -1
- package/resources/x/write-actions.d.mts +155 -12
- package/resources/x/write-actions.d.mts.map +1 -1
- package/resources/x/write-actions.d.ts +155 -12
- package/resources/x/write-actions.d.ts.map +1 -1
- package/src/client.ts +1 -1
- package/src/resources/account.ts +2 -2
- package/src/resources/compose.ts +232 -65
- package/src/resources/credits.ts +1 -1
- package/src/resources/extractions.ts +4 -4
- package/src/resources/guest-wallets.ts +2 -2
- package/src/resources/monitors/keywords.ts +4 -4
- package/src/resources/monitors/monitors.ts +5 -4
- package/src/resources/shared.ts +93 -9
- package/src/resources/support/tickets.ts +122 -6
- package/src/resources/x/account-connection-challenges.ts +1 -1
- package/src/resources/x/accounts.ts +9 -6
- package/src/resources/x/communities/communities.ts +515 -12
- package/src/resources/x/communities/join.ts +518 -9
- package/src/resources/x/dm.ts +261 -6
- package/src/resources/x/media.ts +258 -11
- package/src/resources/x/profile.ts +786 -17
- package/src/resources/x/tweets/like.ts +515 -8
- package/src/resources/x/tweets/retweet.ts +523 -8
- package/src/resources/x/tweets/tweets.ts +529 -23
- package/src/resources/x/users/follow.ts +518 -9
- package/src/resources/x/users/users.ts +260 -6
- package/src/resources/x/write-actions.ts +207 -14
- package/src/version.ts +1 -1
- package/version.d.mts +1 -1
- package/version.d.ts +1 -1
- package/version.js +1 -1
- package/version.mjs +1 -1
package/resources/x/media.d.mts
CHANGED
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
import { APIResource } from "../../core/resource.mjs";
|
|
2
2
|
import { APIPromise } from "../../core/api-promise.mjs";
|
|
3
3
|
import { RequestOptions } from "../../internal/request-options.mjs";
|
|
4
|
-
/**
|
|
5
|
-
* Media upload and download
|
|
6
|
-
*/
|
|
7
4
|
export declare class Media extends APIResource {
|
|
8
5
|
/**
|
|
9
6
|
* Download images and videos from tweets
|
|
@@ -24,10 +21,11 @@ export declare class Media extends APIResource {
|
|
|
24
21
|
* const response = await client.x.media.upload({
|
|
25
22
|
* account: '@elonmusk',
|
|
26
23
|
* url: 'https://example.com/image.png',
|
|
24
|
+
* 'Idempotency-Key': 'Idempotency-Key',
|
|
27
25
|
* });
|
|
28
26
|
* ```
|
|
29
27
|
*/
|
|
30
|
-
upload(
|
|
28
|
+
upload(params: MediaUploadParams, options?: RequestOptions): APIPromise<MediaUploadResponse>;
|
|
31
29
|
}
|
|
32
30
|
export interface MediaDownloadResponse {
|
|
33
31
|
cacheHit?: boolean;
|
|
@@ -36,13 +34,176 @@ export interface MediaDownloadResponse {
|
|
|
36
34
|
totalTweets?: number;
|
|
37
35
|
tweetId?: string;
|
|
38
36
|
}
|
|
37
|
+
/**
|
|
38
|
+
* Durable write lifecycle record. Poll statusUrl until terminal is true. Reusing
|
|
39
|
+
* the original Idempotency-Key returns this same record. Submit a new write only
|
|
40
|
+
* when safeToRetry is true, using a new key.
|
|
41
|
+
*/
|
|
39
42
|
export interface MediaUploadResponse {
|
|
40
|
-
|
|
43
|
+
id: string;
|
|
44
|
+
/**
|
|
45
|
+
* Connected account selected for the write.
|
|
46
|
+
*/
|
|
47
|
+
account: MediaUploadResponse.Account | null;
|
|
48
|
+
action: 'create_tweet' | 'delete_tweet' | 'like' | 'unlike' | 'retweet' | 'unretweet' | 'follow' | 'unfollow' | 'remove_follower' | 'send_dm' | 'upload_media' | 'update_profile' | 'update_avatar' | 'update_banner' | 'create_community' | 'delete_community' | 'join_community' | 'leave_community';
|
|
49
|
+
/**
|
|
50
|
+
* plannedCredits is the approved maximum. chargedCredits comes from the settled
|
|
51
|
+
* credit ledger. Pending or failed writes are not charged.
|
|
52
|
+
*/
|
|
53
|
+
billing: MediaUploadResponse.Billing;
|
|
54
|
+
charged: boolean;
|
|
55
|
+
chargedCredits: string;
|
|
56
|
+
/**
|
|
57
|
+
* Exact follow-up an API client or agent should perform.
|
|
58
|
+
*/
|
|
59
|
+
nextAction: MediaUploadResponse.NextAction | null;
|
|
60
|
+
object: 'x_write_action';
|
|
61
|
+
pollAfterMs: number | null;
|
|
62
|
+
/**
|
|
63
|
+
* Stable fingerprint and sanitized payload for replay checks.
|
|
64
|
+
*/
|
|
65
|
+
request: MediaUploadResponse.Request;
|
|
66
|
+
/**
|
|
67
|
+
* Confirmed result produced by the write, when available.
|
|
68
|
+
*/
|
|
69
|
+
result: MediaUploadResponse.Result | null;
|
|
70
|
+
/**
|
|
71
|
+
* True only when a new attempt can reasonably succeed.
|
|
72
|
+
*/
|
|
73
|
+
retryable: boolean;
|
|
74
|
+
/**
|
|
75
|
+
* True only when no write was dispatched and a new idempotency key may be used.
|
|
76
|
+
*/
|
|
77
|
+
safeToRetry: boolean;
|
|
78
|
+
sendDispatched: boolean;
|
|
79
|
+
status: 'accepted' | 'dispatching' | 'pending_confirmation' | 'success' | 'failed' | 'expired';
|
|
80
|
+
statusUrl: string;
|
|
81
|
+
success: boolean;
|
|
82
|
+
/**
|
|
83
|
+
* Existing X resource targeted by the write, when applicable.
|
|
84
|
+
*/
|
|
85
|
+
target: MediaUploadResponse.Target | null;
|
|
86
|
+
targetId: string | null;
|
|
87
|
+
terminal: boolean;
|
|
88
|
+
writeActionId: string;
|
|
89
|
+
/**
|
|
90
|
+
* Compatibility field for a confirmed community ID.
|
|
91
|
+
*/
|
|
92
|
+
communityId?: string;
|
|
93
|
+
/**
|
|
94
|
+
* Confirmed community name when available.
|
|
95
|
+
*/
|
|
96
|
+
communityName?: string;
|
|
97
|
+
completedAt?: string;
|
|
98
|
+
confirmationAttempts?: number;
|
|
99
|
+
confirmationCheckedAt?: string;
|
|
100
|
+
confirmedAt?: string;
|
|
101
|
+
createdAt?: string;
|
|
102
|
+
/**
|
|
103
|
+
* Structured recovery context for a failed write.
|
|
104
|
+
*/
|
|
105
|
+
details?: {
|
|
106
|
+
[key: string]: unknown;
|
|
107
|
+
};
|
|
108
|
+
error?: string;
|
|
109
|
+
/**
|
|
110
|
+
* Deadline for resolving a non-terminal write. This is not the Idempotency-Key
|
|
111
|
+
* retention deadline.
|
|
112
|
+
*/
|
|
113
|
+
expiresAt?: string;
|
|
114
|
+
idempotent?: boolean;
|
|
41
115
|
/**
|
|
42
|
-
*
|
|
116
|
+
* Media count, kind, size, and billing details when used.
|
|
43
117
|
*/
|
|
44
|
-
|
|
45
|
-
|
|
118
|
+
media?: {
|
|
119
|
+
[key: string]: unknown;
|
|
120
|
+
};
|
|
121
|
+
/**
|
|
122
|
+
* Compatibility field for a confirmed media upload ID.
|
|
123
|
+
*/
|
|
124
|
+
mediaId?: string;
|
|
125
|
+
/**
|
|
126
|
+
* Public media URL when the upload creates one.
|
|
127
|
+
*/
|
|
128
|
+
mediaUrl?: string;
|
|
129
|
+
message?: string;
|
|
130
|
+
/**
|
|
131
|
+
* Compatibility field for a confirmed direct message ID.
|
|
132
|
+
*/
|
|
133
|
+
messageId?: string;
|
|
134
|
+
requestHash?: string;
|
|
135
|
+
requestId?: string;
|
|
136
|
+
/**
|
|
137
|
+
* Compatibility result ID for other write actions.
|
|
138
|
+
*/
|
|
139
|
+
resultId?: string;
|
|
140
|
+
/**
|
|
141
|
+
* Dispatch timestamp when the write reached execution.
|
|
142
|
+
*/
|
|
143
|
+
sendDispatchedAt?: string;
|
|
144
|
+
/**
|
|
145
|
+
* Compatibility field for a confirmed tweet result ID.
|
|
146
|
+
*/
|
|
147
|
+
tweetId?: string;
|
|
148
|
+
updatedAt?: string;
|
|
149
|
+
}
|
|
150
|
+
export declare namespace MediaUploadResponse {
|
|
151
|
+
/**
|
|
152
|
+
* Connected account selected for the write.
|
|
153
|
+
*/
|
|
154
|
+
interface Account {
|
|
155
|
+
id: string;
|
|
156
|
+
username: string;
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* plannedCredits is the approved maximum. chargedCredits comes from the settled
|
|
160
|
+
* credit ledger. Pending or failed writes are not charged.
|
|
161
|
+
*/
|
|
162
|
+
interface Billing {
|
|
163
|
+
charged: boolean;
|
|
164
|
+
chargedCredits: string;
|
|
165
|
+
plannedCredits: string;
|
|
166
|
+
status: 'not_charged' | 'pending' | 'charged' | 'charge_failed' | 'refunded';
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* Exact follow-up an API client or agent should perform.
|
|
170
|
+
*/
|
|
171
|
+
interface NextAction {
|
|
172
|
+
type: 'poll' | 'retry' | 'verify_result' | 'fix_request';
|
|
173
|
+
afterMs?: number;
|
|
174
|
+
requiresNewIdempotencyKey?: boolean;
|
|
175
|
+
url?: string;
|
|
176
|
+
}
|
|
177
|
+
/**
|
|
178
|
+
* Stable fingerprint and sanitized payload for replay checks.
|
|
179
|
+
*/
|
|
180
|
+
interface Request {
|
|
181
|
+
/**
|
|
182
|
+
* Stable hash of account, action, target, and payload.
|
|
183
|
+
*/
|
|
184
|
+
hash: string | null;
|
|
185
|
+
/**
|
|
186
|
+
* Exact sanitized payload dispatched for this action.
|
|
187
|
+
*/
|
|
188
|
+
payload: {
|
|
189
|
+
[key: string]: unknown;
|
|
190
|
+
} | null;
|
|
191
|
+
}
|
|
192
|
+
/**
|
|
193
|
+
* Confirmed result produced by the write, when available.
|
|
194
|
+
*/
|
|
195
|
+
interface Result {
|
|
196
|
+
id?: string;
|
|
197
|
+
state?: string;
|
|
198
|
+
type?: 'tweet' | 'direct_message' | 'media' | 'community' | 'state_change';
|
|
199
|
+
}
|
|
200
|
+
/**
|
|
201
|
+
* Existing X resource targeted by the write, when applicable.
|
|
202
|
+
*/
|
|
203
|
+
interface Target {
|
|
204
|
+
id: string;
|
|
205
|
+
type: 'tweet' | 'user' | 'community';
|
|
206
|
+
}
|
|
46
207
|
}
|
|
47
208
|
export interface MediaDownloadParams {
|
|
48
209
|
/**
|
|
@@ -64,13 +225,20 @@ export interface MediaDownloadParams {
|
|
|
64
225
|
}
|
|
65
226
|
export interface MediaUploadParams {
|
|
66
227
|
/**
|
|
67
|
-
* X account (@username or ID) uploading media from URL
|
|
228
|
+
* Body param: X account (@username or ID) uploading media from URL
|
|
68
229
|
*/
|
|
69
230
|
account: string;
|
|
70
231
|
/**
|
|
71
|
-
* HTTPS URL to download and upload as media
|
|
232
|
+
* Body param: HTTPS URL to download and upload as media
|
|
72
233
|
*/
|
|
73
234
|
url: string;
|
|
235
|
+
/**
|
|
236
|
+
* Header param: Generate one unique value for each intended write. Reuse it only
|
|
237
|
+
* when retrying the exact same account, action, target, and payload. A reused key
|
|
238
|
+
* returns the original action. Reusing it with different input returns 409. Replay
|
|
239
|
+
* protection remains active for at least 90 days.
|
|
240
|
+
*/
|
|
241
|
+
'Idempotency-Key': string;
|
|
74
242
|
}
|
|
75
243
|
export declare namespace Media {
|
|
76
244
|
export { type MediaDownloadResponse as MediaDownloadResponse, type MediaUploadResponse as MediaUploadResponse, type MediaDownloadParams as MediaDownloadParams, type MediaUploadParams as MediaUploadParams, };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"media.d.mts","sourceRoot":"","sources":["../../src/resources/x/media.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,gCAA4B;AAClD,OAAO,EAAE,UAAU,EAAE,mCAA+B;
|
|
1
|
+
{"version":3,"file":"media.d.mts","sourceRoot":"","sources":["../../src/resources/x/media.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,gCAA4B;AAClD,OAAO,EAAE,UAAU,EAAE,mCAA+B;AAEpD,OAAO,EAAE,cAAc,EAAE,2CAAuC;AAGhE,qBAAa,KAAM,SAAQ,WAAW;IACpC;;;;;;;;;OASG;IACH,QAAQ,CAAC,IAAI,EAAE,mBAAmB,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,UAAU,CAAC,qBAAqB,CAAC;IAIhG;;;;;;;;;;;OAWG;IACH,MAAM,CAAC,MAAM,EAAE,iBAAiB,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,UAAU,CAAC,mBAAmB,CAAC;CAc7F;AAED,MAAM,WAAW,qBAAqB;IACpC,QAAQ,CAAC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M,CAAC;IAEpB;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,iBAAiB;IAChC;;OAEG;IACH,OAAO,EAAE,MAAM,CAAC;IAEhB;;OAEG;IACH,GAAG,EAAE,MAAM,CAAC;IAEZ;;;;;OAKG;IACH,iBAAiB,EAAE,MAAM,CAAC;CAC3B;AAED,MAAM,CAAC,OAAO,WAAW,KAAK,CAAC;IAC7B,OAAO,EACL,KAAK,qBAAqB,IAAI,qBAAqB,EACnD,KAAK,mBAAmB,IAAI,mBAAmB,EAC/C,KAAK,mBAAmB,IAAI,mBAAmB,EAC/C,KAAK,iBAAiB,IAAI,iBAAiB,GAC5C,CAAC;CACH"}
|
package/resources/x/media.d.ts
CHANGED
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
import { APIResource } from "../../core/resource.js";
|
|
2
2
|
import { APIPromise } from "../../core/api-promise.js";
|
|
3
3
|
import { RequestOptions } from "../../internal/request-options.js";
|
|
4
|
-
/**
|
|
5
|
-
* Media upload and download
|
|
6
|
-
*/
|
|
7
4
|
export declare class Media extends APIResource {
|
|
8
5
|
/**
|
|
9
6
|
* Download images and videos from tweets
|
|
@@ -24,10 +21,11 @@ export declare class Media extends APIResource {
|
|
|
24
21
|
* const response = await client.x.media.upload({
|
|
25
22
|
* account: '@elonmusk',
|
|
26
23
|
* url: 'https://example.com/image.png',
|
|
24
|
+
* 'Idempotency-Key': 'Idempotency-Key',
|
|
27
25
|
* });
|
|
28
26
|
* ```
|
|
29
27
|
*/
|
|
30
|
-
upload(
|
|
28
|
+
upload(params: MediaUploadParams, options?: RequestOptions): APIPromise<MediaUploadResponse>;
|
|
31
29
|
}
|
|
32
30
|
export interface MediaDownloadResponse {
|
|
33
31
|
cacheHit?: boolean;
|
|
@@ -36,13 +34,176 @@ export interface MediaDownloadResponse {
|
|
|
36
34
|
totalTweets?: number;
|
|
37
35
|
tweetId?: string;
|
|
38
36
|
}
|
|
37
|
+
/**
|
|
38
|
+
* Durable write lifecycle record. Poll statusUrl until terminal is true. Reusing
|
|
39
|
+
* the original Idempotency-Key returns this same record. Submit a new write only
|
|
40
|
+
* when safeToRetry is true, using a new key.
|
|
41
|
+
*/
|
|
39
42
|
export interface MediaUploadResponse {
|
|
40
|
-
|
|
43
|
+
id: string;
|
|
44
|
+
/**
|
|
45
|
+
* Connected account selected for the write.
|
|
46
|
+
*/
|
|
47
|
+
account: MediaUploadResponse.Account | null;
|
|
48
|
+
action: 'create_tweet' | 'delete_tweet' | 'like' | 'unlike' | 'retweet' | 'unretweet' | 'follow' | 'unfollow' | 'remove_follower' | 'send_dm' | 'upload_media' | 'update_profile' | 'update_avatar' | 'update_banner' | 'create_community' | 'delete_community' | 'join_community' | 'leave_community';
|
|
49
|
+
/**
|
|
50
|
+
* plannedCredits is the approved maximum. chargedCredits comes from the settled
|
|
51
|
+
* credit ledger. Pending or failed writes are not charged.
|
|
52
|
+
*/
|
|
53
|
+
billing: MediaUploadResponse.Billing;
|
|
54
|
+
charged: boolean;
|
|
55
|
+
chargedCredits: string;
|
|
56
|
+
/**
|
|
57
|
+
* Exact follow-up an API client or agent should perform.
|
|
58
|
+
*/
|
|
59
|
+
nextAction: MediaUploadResponse.NextAction | null;
|
|
60
|
+
object: 'x_write_action';
|
|
61
|
+
pollAfterMs: number | null;
|
|
62
|
+
/**
|
|
63
|
+
* Stable fingerprint and sanitized payload for replay checks.
|
|
64
|
+
*/
|
|
65
|
+
request: MediaUploadResponse.Request;
|
|
66
|
+
/**
|
|
67
|
+
* Confirmed result produced by the write, when available.
|
|
68
|
+
*/
|
|
69
|
+
result: MediaUploadResponse.Result | null;
|
|
70
|
+
/**
|
|
71
|
+
* True only when a new attempt can reasonably succeed.
|
|
72
|
+
*/
|
|
73
|
+
retryable: boolean;
|
|
74
|
+
/**
|
|
75
|
+
* True only when no write was dispatched and a new idempotency key may be used.
|
|
76
|
+
*/
|
|
77
|
+
safeToRetry: boolean;
|
|
78
|
+
sendDispatched: boolean;
|
|
79
|
+
status: 'accepted' | 'dispatching' | 'pending_confirmation' | 'success' | 'failed' | 'expired';
|
|
80
|
+
statusUrl: string;
|
|
81
|
+
success: boolean;
|
|
82
|
+
/**
|
|
83
|
+
* Existing X resource targeted by the write, when applicable.
|
|
84
|
+
*/
|
|
85
|
+
target: MediaUploadResponse.Target | null;
|
|
86
|
+
targetId: string | null;
|
|
87
|
+
terminal: boolean;
|
|
88
|
+
writeActionId: string;
|
|
89
|
+
/**
|
|
90
|
+
* Compatibility field for a confirmed community ID.
|
|
91
|
+
*/
|
|
92
|
+
communityId?: string;
|
|
93
|
+
/**
|
|
94
|
+
* Confirmed community name when available.
|
|
95
|
+
*/
|
|
96
|
+
communityName?: string;
|
|
97
|
+
completedAt?: string;
|
|
98
|
+
confirmationAttempts?: number;
|
|
99
|
+
confirmationCheckedAt?: string;
|
|
100
|
+
confirmedAt?: string;
|
|
101
|
+
createdAt?: string;
|
|
102
|
+
/**
|
|
103
|
+
* Structured recovery context for a failed write.
|
|
104
|
+
*/
|
|
105
|
+
details?: {
|
|
106
|
+
[key: string]: unknown;
|
|
107
|
+
};
|
|
108
|
+
error?: string;
|
|
109
|
+
/**
|
|
110
|
+
* Deadline for resolving a non-terminal write. This is not the Idempotency-Key
|
|
111
|
+
* retention deadline.
|
|
112
|
+
*/
|
|
113
|
+
expiresAt?: string;
|
|
114
|
+
idempotent?: boolean;
|
|
41
115
|
/**
|
|
42
|
-
*
|
|
116
|
+
* Media count, kind, size, and billing details when used.
|
|
43
117
|
*/
|
|
44
|
-
|
|
45
|
-
|
|
118
|
+
media?: {
|
|
119
|
+
[key: string]: unknown;
|
|
120
|
+
};
|
|
121
|
+
/**
|
|
122
|
+
* Compatibility field for a confirmed media upload ID.
|
|
123
|
+
*/
|
|
124
|
+
mediaId?: string;
|
|
125
|
+
/**
|
|
126
|
+
* Public media URL when the upload creates one.
|
|
127
|
+
*/
|
|
128
|
+
mediaUrl?: string;
|
|
129
|
+
message?: string;
|
|
130
|
+
/**
|
|
131
|
+
* Compatibility field for a confirmed direct message ID.
|
|
132
|
+
*/
|
|
133
|
+
messageId?: string;
|
|
134
|
+
requestHash?: string;
|
|
135
|
+
requestId?: string;
|
|
136
|
+
/**
|
|
137
|
+
* Compatibility result ID for other write actions.
|
|
138
|
+
*/
|
|
139
|
+
resultId?: string;
|
|
140
|
+
/**
|
|
141
|
+
* Dispatch timestamp when the write reached execution.
|
|
142
|
+
*/
|
|
143
|
+
sendDispatchedAt?: string;
|
|
144
|
+
/**
|
|
145
|
+
* Compatibility field for a confirmed tweet result ID.
|
|
146
|
+
*/
|
|
147
|
+
tweetId?: string;
|
|
148
|
+
updatedAt?: string;
|
|
149
|
+
}
|
|
150
|
+
export declare namespace MediaUploadResponse {
|
|
151
|
+
/**
|
|
152
|
+
* Connected account selected for the write.
|
|
153
|
+
*/
|
|
154
|
+
interface Account {
|
|
155
|
+
id: string;
|
|
156
|
+
username: string;
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* plannedCredits is the approved maximum. chargedCredits comes from the settled
|
|
160
|
+
* credit ledger. Pending or failed writes are not charged.
|
|
161
|
+
*/
|
|
162
|
+
interface Billing {
|
|
163
|
+
charged: boolean;
|
|
164
|
+
chargedCredits: string;
|
|
165
|
+
plannedCredits: string;
|
|
166
|
+
status: 'not_charged' | 'pending' | 'charged' | 'charge_failed' | 'refunded';
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* Exact follow-up an API client or agent should perform.
|
|
170
|
+
*/
|
|
171
|
+
interface NextAction {
|
|
172
|
+
type: 'poll' | 'retry' | 'verify_result' | 'fix_request';
|
|
173
|
+
afterMs?: number;
|
|
174
|
+
requiresNewIdempotencyKey?: boolean;
|
|
175
|
+
url?: string;
|
|
176
|
+
}
|
|
177
|
+
/**
|
|
178
|
+
* Stable fingerprint and sanitized payload for replay checks.
|
|
179
|
+
*/
|
|
180
|
+
interface Request {
|
|
181
|
+
/**
|
|
182
|
+
* Stable hash of account, action, target, and payload.
|
|
183
|
+
*/
|
|
184
|
+
hash: string | null;
|
|
185
|
+
/**
|
|
186
|
+
* Exact sanitized payload dispatched for this action.
|
|
187
|
+
*/
|
|
188
|
+
payload: {
|
|
189
|
+
[key: string]: unknown;
|
|
190
|
+
} | null;
|
|
191
|
+
}
|
|
192
|
+
/**
|
|
193
|
+
* Confirmed result produced by the write, when available.
|
|
194
|
+
*/
|
|
195
|
+
interface Result {
|
|
196
|
+
id?: string;
|
|
197
|
+
state?: string;
|
|
198
|
+
type?: 'tweet' | 'direct_message' | 'media' | 'community' | 'state_change';
|
|
199
|
+
}
|
|
200
|
+
/**
|
|
201
|
+
* Existing X resource targeted by the write, when applicable.
|
|
202
|
+
*/
|
|
203
|
+
interface Target {
|
|
204
|
+
id: string;
|
|
205
|
+
type: 'tweet' | 'user' | 'community';
|
|
206
|
+
}
|
|
46
207
|
}
|
|
47
208
|
export interface MediaDownloadParams {
|
|
48
209
|
/**
|
|
@@ -64,13 +225,20 @@ export interface MediaDownloadParams {
|
|
|
64
225
|
}
|
|
65
226
|
export interface MediaUploadParams {
|
|
66
227
|
/**
|
|
67
|
-
* X account (@username or ID) uploading media from URL
|
|
228
|
+
* Body param: X account (@username or ID) uploading media from URL
|
|
68
229
|
*/
|
|
69
230
|
account: string;
|
|
70
231
|
/**
|
|
71
|
-
* HTTPS URL to download and upload as media
|
|
232
|
+
* Body param: HTTPS URL to download and upload as media
|
|
72
233
|
*/
|
|
73
234
|
url: string;
|
|
235
|
+
/**
|
|
236
|
+
* Header param: Generate one unique value for each intended write. Reuse it only
|
|
237
|
+
* when retrying the exact same account, action, target, and payload. A reused key
|
|
238
|
+
* returns the original action. Reusing it with different input returns 409. Replay
|
|
239
|
+
* protection remains active for at least 90 days.
|
|
240
|
+
*/
|
|
241
|
+
'Idempotency-Key': string;
|
|
74
242
|
}
|
|
75
243
|
export declare namespace Media {
|
|
76
244
|
export { type MediaDownloadResponse as MediaDownloadResponse, type MediaUploadResponse as MediaUploadResponse, type MediaDownloadParams as MediaDownloadParams, type MediaUploadParams as MediaUploadParams, };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"media.d.ts","sourceRoot":"","sources":["../../src/resources/x/media.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,+BAA4B;AAClD,OAAO,EAAE,UAAU,EAAE,kCAA+B;
|
|
1
|
+
{"version":3,"file":"media.d.ts","sourceRoot":"","sources":["../../src/resources/x/media.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,+BAA4B;AAClD,OAAO,EAAE,UAAU,EAAE,kCAA+B;AAEpD,OAAO,EAAE,cAAc,EAAE,0CAAuC;AAGhE,qBAAa,KAAM,SAAQ,WAAW;IACpC;;;;;;;;;OASG;IACH,QAAQ,CAAC,IAAI,EAAE,mBAAmB,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,UAAU,CAAC,qBAAqB,CAAC;IAIhG;;;;;;;;;;;OAWG;IACH,MAAM,CAAC,MAAM,EAAE,iBAAiB,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,UAAU,CAAC,mBAAmB,CAAC;CAc7F;AAED,MAAM,WAAW,qBAAqB;IACpC,QAAQ,CAAC,EAAE,OAAO,CAAC;IAEnB,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED;;;;GAIG;AACH,MAAM,WAAW,mBAAmB;IAClC,EAAE,EAAE,MAAM,CAAC;IAEX;;OAEG;IACH,OAAO,EAAE,mBAAmB,CAAC,OAAO,GAAG,IAAI,CAAC;IAE5C,MAAM,EACF,cAAc,GACd,cAAc,GACd,MAAM,GACN,QAAQ,GACR,SAAS,GACT,WAAW,GACX,QAAQ,GACR,UAAU,GACV,iBAAiB,GACjB,SAAS,GACT,cAAc,GACd,gBAAgB,GAChB,eAAe,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 -3,10 +3,8 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
4
|
exports.Media = void 0;
|
|
5
5
|
const resource_1 = require("../../core/resource.js");
|
|
6
|
+
const headers_1 = require("../../internal/headers.js");
|
|
6
7
|
const uploads_1 = require("../../internal/uploads.js");
|
|
7
|
-
/**
|
|
8
|
-
* Media upload and download
|
|
9
|
-
*/
|
|
10
8
|
class Media extends resource_1.APIResource {
|
|
11
9
|
/**
|
|
12
10
|
* Download images and videos from tweets
|
|
@@ -29,11 +27,17 @@ class Media extends resource_1.APIResource {
|
|
|
29
27
|
* const response = await client.x.media.upload({
|
|
30
28
|
* account: '@elonmusk',
|
|
31
29
|
* url: 'https://example.com/image.png',
|
|
30
|
+
* 'Idempotency-Key': 'Idempotency-Key',
|
|
32
31
|
* });
|
|
33
32
|
* ```
|
|
34
33
|
*/
|
|
35
|
-
upload(
|
|
36
|
-
|
|
34
|
+
upload(params, options) {
|
|
35
|
+
const { 'Idempotency-Key': idempotencyKey, ...body } = params;
|
|
36
|
+
return this._client.post('/x/media', (0, uploads_1.maybeMultipartFormRequestOptions)({
|
|
37
|
+
body,
|
|
38
|
+
...options,
|
|
39
|
+
headers: (0, headers_1.buildHeaders)([{ 'Idempotency-Key': idempotencyKey }, options?.headers]),
|
|
40
|
+
}, this._client));
|
|
37
41
|
}
|
|
38
42
|
}
|
|
39
43
|
exports.Media = Media;
|
package/resources/x/media.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"media.js","sourceRoot":"","sources":["../../src/resources/x/media.ts"],"names":[],"mappings":";AAAA,sFAAsF;;;AAEtF,qDAAkD;
|
|
1
|
+
{"version":3,"file":"media.js","sourceRoot":"","sources":["../../src/resources/x/media.ts"],"names":[],"mappings":";AAAA,sFAAsF;;;AAEtF,qDAAkD;AAElD,uDAAsD;AAEtD,uDAA0E;AAE1E,MAAa,KAAM,SAAQ,sBAAW;IACpC;;;;;;;;;OASG;IACH,QAAQ,CAAC,IAAyB,EAAE,OAAwB;QAC1D,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,mBAAmB,EAAE,EAAE,IAAI,EAAE,GAAG,OAAO,EAAE,CAAC,CAAC;IACtE,CAAC;IAED;;;;;;;;;;;OAWG;IACH,MAAM,CAAC,MAAyB,EAAE,OAAwB;QACxD,MAAM,EAAE,iBAAiB,EAAE,cAAc,EAAE,GAAG,IAAI,EAAE,GAAG,MAAM,CAAC;QAC9D,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CACtB,UAAU,EACV,IAAA,0CAAgC,EAC9B;YACE,IAAI;YACJ,GAAG,OAAO;YACV,OAAO,EAAE,IAAA,sBAAY,EAAC,CAAC,EAAE,iBAAiB,EAAE,cAAc,EAAE,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;SACjF,EACD,IAAI,CAAC,OAAO,CACb,CACF,CAAC;IACJ,CAAC;CACF;AAzCD,sBAyCC"}
|
package/resources/x/media.mjs
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
2
|
import { APIResource } from "../../core/resource.mjs";
|
|
3
|
+
import { buildHeaders } from "../../internal/headers.mjs";
|
|
3
4
|
import { maybeMultipartFormRequestOptions } from "../../internal/uploads.mjs";
|
|
4
|
-
/**
|
|
5
|
-
* Media upload and download
|
|
6
|
-
*/
|
|
7
5
|
export class Media extends APIResource {
|
|
8
6
|
/**
|
|
9
7
|
* Download images and videos from tweets
|
|
@@ -26,11 +24,17 @@ export class Media extends APIResource {
|
|
|
26
24
|
* const response = await client.x.media.upload({
|
|
27
25
|
* account: '@elonmusk',
|
|
28
26
|
* url: 'https://example.com/image.png',
|
|
27
|
+
* 'Idempotency-Key': 'Idempotency-Key',
|
|
29
28
|
* });
|
|
30
29
|
* ```
|
|
31
30
|
*/
|
|
32
|
-
upload(
|
|
33
|
-
|
|
31
|
+
upload(params, options) {
|
|
32
|
+
const { 'Idempotency-Key': idempotencyKey, ...body } = params;
|
|
33
|
+
return this._client.post('/x/media', maybeMultipartFormRequestOptions({
|
|
34
|
+
body,
|
|
35
|
+
...options,
|
|
36
|
+
headers: buildHeaders([{ 'Idempotency-Key': idempotencyKey }, options?.headers]),
|
|
37
|
+
}, this._client));
|
|
34
38
|
}
|
|
35
39
|
}
|
|
36
40
|
//# sourceMappingURL=media.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"media.mjs","sourceRoot":"","sources":["../../src/resources/x/media.ts"],"names":[],"mappings":"AAAA,sFAAsF;AAEtF,OAAO,EAAE,WAAW,EAAE,gCAA4B;
|
|
1
|
+
{"version":3,"file":"media.mjs","sourceRoot":"","sources":["../../src/resources/x/media.ts"],"names":[],"mappings":"AAAA,sFAAsF;AAEtF,OAAO,EAAE,WAAW,EAAE,gCAA4B;AAElD,OAAO,EAAE,YAAY,EAAE,mCAA+B;AAEtD,OAAO,EAAE,gCAAgC,EAAE,mCAA+B;AAE1E,MAAM,OAAO,KAAM,SAAQ,WAAW;IACpC;;;;;;;;;OASG;IACH,QAAQ,CAAC,IAAyB,EAAE,OAAwB;QAC1D,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,mBAAmB,EAAE,EAAE,IAAI,EAAE,GAAG,OAAO,EAAE,CAAC,CAAC;IACtE,CAAC;IAED;;;;;;;;;;;OAWG;IACH,MAAM,CAAC,MAAyB,EAAE,OAAwB;QACxD,MAAM,EAAE,iBAAiB,EAAE,cAAc,EAAE,GAAG,IAAI,EAAE,GAAG,MAAM,CAAC;QAC9D,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CACtB,UAAU,EACV,gCAAgC,CAC9B;YACE,IAAI;YACJ,GAAG,OAAO;YACV,OAAO,EAAE,YAAY,CAAC,CAAC,EAAE,iBAAiB,EAAE,cAAc,EAAE,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;SACjF,EACD,IAAI,CAAC,OAAO,CACb,CACF,CAAC;IACJ,CAAC;CACF"}
|