rettiwt-api 6.3.0-alpha.1 → 7.0.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.
Files changed (138) hide show
  1. package/README.md +81 -31
  2. package/dist/Rettiwt.d.ts +6 -2
  3. package/dist/Rettiwt.js +7 -3
  4. package/dist/Rettiwt.js.map +1 -1
  5. package/dist/cli.js +3 -1
  6. package/dist/cli.js.map +1 -1
  7. package/dist/collections/Extractors.d.ts +15 -2
  8. package/dist/collections/Extractors.js +12 -1
  9. package/dist/collections/Extractors.js.map +1 -1
  10. package/dist/collections/Groups.js +8 -0
  11. package/dist/collections/Groups.js.map +1 -1
  12. package/dist/collections/Requests.js +8 -0
  13. package/dist/collections/Requests.js.map +1 -1
  14. package/dist/commands/Space.d.ts +10 -0
  15. package/dist/commands/Space.js +38 -0
  16. package/dist/commands/Space.js.map +1 -0
  17. package/dist/commands/User.js +139 -0
  18. package/dist/commands/User.js.map +1 -1
  19. package/dist/enums/Resource.d.ts +8 -1
  20. package/dist/enums/Resource.js +8 -0
  21. package/dist/enums/Resource.js.map +1 -1
  22. package/dist/index.d.ts +11 -1
  23. package/dist/index.js +6 -0
  24. package/dist/index.js.map +1 -1
  25. package/dist/models/RettiwtConfig.d.ts +26 -3
  26. package/dist/models/RettiwtConfig.js +68 -3
  27. package/dist/models/RettiwtConfig.js.map +1 -1
  28. package/dist/models/args/FetchArgs.d.ts +3 -0
  29. package/dist/models/args/FetchArgs.js +6 -0
  30. package/dist/models/args/FetchArgs.js.map +1 -1
  31. package/dist/models/args/PostArgs.d.ts +24 -1
  32. package/dist/models/args/PostArgs.js +52 -1
  33. package/dist/models/args/PostArgs.js.map +1 -1
  34. package/dist/models/data/Space.d.ts +70 -0
  35. package/dist/models/data/Space.js +177 -0
  36. package/dist/models/data/Space.js.map +1 -0
  37. package/dist/models/data/User.d.ts +1 -1
  38. package/dist/models/data/User.js +3 -3
  39. package/dist/models/data/User.js.map +1 -1
  40. package/dist/models/data/UserAbout.d.ts +44 -0
  41. package/dist/models/data/UserAbout.js +129 -0
  42. package/dist/models/data/UserAbout.js.map +1 -0
  43. package/dist/requests/Space.d.ts +15 -0
  44. package/dist/requests/Space.js +74 -0
  45. package/dist/requests/Space.js.map +1 -0
  46. package/dist/requests/Tweet.d.ts +4 -0
  47. package/dist/requests/Tweet.js +57 -0
  48. package/dist/requests/Tweet.js.map +1 -1
  49. package/dist/requests/User.d.ts +21 -0
  50. package/dist/requests/User.js +64 -0
  51. package/dist/requests/User.js.map +1 -1
  52. package/dist/services/internal/AuthService.d.ts +25 -0
  53. package/dist/services/internal/AuthService.js +121 -0
  54. package/dist/services/internal/AuthService.js.map +1 -1
  55. package/dist/services/public/DirectMessageService.js +3 -3
  56. package/dist/services/public/DirectMessageService.js.map +1 -1
  57. package/dist/services/public/FetcherService.d.ts +4 -3
  58. package/dist/services/public/FetcherService.js +22 -16
  59. package/dist/services/public/FetcherService.js.map +1 -1
  60. package/dist/services/public/ListService.js +5 -5
  61. package/dist/services/public/ListService.js.map +1 -1
  62. package/dist/services/public/SpaceService.d.ts +42 -0
  63. package/dist/services/public/SpaceService.js +60 -0
  64. package/dist/services/public/SpaceService.js.map +1 -0
  65. package/dist/services/public/TweetService.js +26 -23
  66. package/dist/services/public/TweetService.js.map +1 -1
  67. package/dist/services/public/UserService.d.ts +79 -0
  68. package/dist/services/public/UserService.js +203 -23
  69. package/dist/services/public/UserService.js.map +1 -1
  70. package/dist/types/RettiwtConfig.d.ts +33 -3
  71. package/dist/types/args/FetchArgs.d.ts +35 -1
  72. package/dist/types/args/PostArgs.d.ts +44 -1
  73. package/dist/types/data/Space.d.ts +89 -0
  74. package/dist/types/data/Space.js +3 -0
  75. package/dist/types/data/Space.js.map +1 -0
  76. package/dist/types/data/User.d.ts +2 -2
  77. package/dist/types/data/UserAbout.d.ts +68 -0
  78. package/dist/types/data/UserAbout.js +3 -0
  79. package/dist/types/data/UserAbout.js.map +1 -0
  80. package/dist/types/raw/base/Space.d.ts +43 -22
  81. package/dist/types/raw/base/User.d.ts +1 -1
  82. package/dist/types/raw/space/AudioSpaceById.d.ts +50 -0
  83. package/dist/types/raw/space/AudioSpaceById.js +4 -0
  84. package/dist/types/raw/space/AudioSpaceById.js.map +1 -0
  85. package/dist/types/raw/space/Details.d.ts +2 -309
  86. package/dist/types/raw/tweet/Post.d.ts +16 -1
  87. package/dist/types/raw/user/About.d.ts +65 -0
  88. package/dist/types/raw/user/About.js +4 -0
  89. package/dist/types/raw/user/About.js.map +1 -0
  90. package/dist/types/raw/user/ChangePassword.d.ts +8 -0
  91. package/dist/types/raw/user/ChangePassword.js +3 -0
  92. package/dist/types/raw/user/ChangePassword.js.map +1 -0
  93. package/dist/types/raw/user/ProfileUpdate.d.ts +1 -0
  94. package/dist/types/raw/user/Settings.d.ts +21 -0
  95. package/dist/types/raw/user/Settings.js +4 -0
  96. package/dist/types/raw/user/Settings.js.map +1 -0
  97. package/package.json +5 -3
  98. package/src/Rettiwt.ts +10 -3
  99. package/src/cli.ts +3 -1
  100. package/src/collections/Extractors.ts +22 -3
  101. package/src/collections/Groups.ts +8 -0
  102. package/src/collections/Requests.ts +11 -0
  103. package/src/commands/Space.ts +46 -0
  104. package/src/commands/User.ts +159 -0
  105. package/src/enums/Resource.ts +9 -0
  106. package/src/index.ts +11 -1
  107. package/src/models/RettiwtConfig.ts +81 -6
  108. package/src/models/args/FetchArgs.ts +6 -0
  109. package/src/models/args/PostArgs.ts +58 -1
  110. package/src/models/data/Space.ts +201 -0
  111. package/src/models/data/User.ts +3 -3
  112. package/src/models/data/UserAbout.ts +161 -0
  113. package/src/requests/Space.ts +76 -0
  114. package/src/requests/Tweet.ts +59 -0
  115. package/src/requests/User.ts +69 -0
  116. package/src/services/internal/AuthService.ts +149 -1
  117. package/src/services/public/DirectMessageService.ts +3 -3
  118. package/src/services/public/FetcherService.ts +25 -18
  119. package/src/services/public/ListService.ts +5 -5
  120. package/src/services/public/SpaceService.ts +65 -0
  121. package/src/services/public/TweetService.ts +27 -24
  122. package/src/services/public/UserService.ts +247 -23
  123. package/src/types/RettiwtConfig.ts +35 -3
  124. package/src/types/args/FetchArgs.ts +41 -1
  125. package/src/types/args/PostArgs.ts +50 -1
  126. package/src/types/data/Space.ts +122 -0
  127. package/src/types/data/User.ts +2 -2
  128. package/src/types/data/UserAbout.ts +87 -0
  129. package/src/types/raw/base/Space.ts +42 -22
  130. package/src/types/raw/base/User.ts +1 -1
  131. package/src/types/raw/space/AudioSpaceById.ts +57 -0
  132. package/src/types/raw/space/Details.ts +3 -352
  133. package/src/types/raw/tweet/Post.ts +19 -1
  134. package/src/types/raw/user/About.ts +77 -0
  135. package/src/types/raw/user/ChangePassword.ts +8 -0
  136. package/src/types/raw/user/ProfileUpdate.ts +1 -0
  137. package/src/types/raw/user/Settings.ts +23 -0
  138. package/tsconfig.json +2 -2
@@ -1,6 +1,6 @@
1
- import axios, { AxiosError, isAxiosError } from 'axios';
1
+ import axios, { AxiosError, AxiosResponse, isAxiosError } from 'axios';
2
2
  import { Cookie } from 'cookiejar';
3
- import { JSDOM } from 'jsdom';
3
+ import { parseHTML } from 'linkedom';
4
4
  import { ClientTransaction } from 'x-client-transaction-id';
5
5
 
6
6
  import { AllowGuestAuthenticationGroup, FetchResourcesGroup, PostResourcesGroup } from '../../collections/Groups';
@@ -128,13 +128,13 @@ export class FetcherService {
128
128
  // Fetch X.com homepage
129
129
  const homePageResponse = await axios.get<string>('https://x.com', {
130
130
  headers: this.config.headers,
131
- httpAgent: this.config.httpsAgent,
131
+ httpAgent: this.config.httpAgent,
132
132
  httpsAgent: this.config.httpsAgent,
133
+ proxy: this.config.axiosProxyConfig,
133
134
  });
134
135
 
135
136
  // Parse HTML using linkedom
136
- let dom = new JSDOM(homePageResponse.data);
137
- let document = dom.window.document;
137
+ let document = parseHTML(homePageResponse.data).document;
138
138
 
139
139
  // Check for migration redirection links
140
140
  const migrationRedirectionRegex = new RegExp(
@@ -151,12 +151,12 @@ export class FetcherService {
151
151
  if (migrationRedirectionUrl) {
152
152
  // Follow redirection URL
153
153
  const redirectResponse = await axios.get<string>(migrationRedirectionUrl[0], {
154
- httpAgent: this.config.httpsAgent,
154
+ httpAgent: this.config.httpAgent,
155
155
  httpsAgent: this.config.httpsAgent,
156
+ proxy: this.config.axiosProxyConfig,
156
157
  });
157
158
 
158
- dom = new JSDOM(redirectResponse.data);
159
- document = dom.window.document;
159
+ document = parseHTML(redirectResponse.data).document;
160
160
  }
161
161
 
162
162
  // Handle migration form if present
@@ -193,12 +193,12 @@ export class FetcherService {
193
193
 
194
194
  /* eslint-enable @typescript-eslint/naming-convention */
195
195
  },
196
- httpAgent: this.config.httpsAgent,
196
+ httpAgent: this.config.httpAgent,
197
197
  httpsAgent: this.config.httpsAgent,
198
+ proxy: this.config.axiosProxyConfig,
198
199
  });
199
200
 
200
- dom = new JSDOM(formResponse.data);
201
- document = dom.window.document;
201
+ document = parseHTML(formResponse.data).document;
202
202
  }
203
203
 
204
204
  // Return final DOM document
@@ -254,11 +254,11 @@ export class FetcherService {
254
254
  * Makes an HTTP request according to the given parameters.
255
255
  *
256
256
  * @param resource - The requested resource.
257
- * @param config - The request configuration.
257
+ * @param args - The args to be used for the request.
258
258
  *
259
259
  * @typeParam T - The type of the returned response data.
260
260
  *
261
- * @returns The raw data response received.
261
+ * @returns The raw Axios response.
262
262
  *
263
263
  * @example
264
264
  *
@@ -279,7 +279,7 @@ export class FetcherService {
279
279
  * });
280
280
  * ```
281
281
  */
282
- public async request<T = unknown>(resource: ResourceType, args: IFetchArgs | IPostArgs): Promise<T> {
282
+ public async request<T = unknown>(resource: ResourceType, args: IFetchArgs | IPostArgs): Promise<AxiosResponse<T>> {
283
283
  /** The current retry number. */
284
284
  let retry = 0;
285
285
 
@@ -307,8 +307,9 @@ export class FetcherService {
307
307
  ...cred.toHeader(),
308
308
  ...this.config.headers,
309
309
  };
310
- config.httpAgent = this.config.httpsAgent;
310
+ config.httpAgent = this.config.httpAgent;
311
311
  config.httpsAgent = this.config.httpsAgent;
312
+ config.proxy = this.config.axiosProxyConfig;
312
313
  config.timeout = this._timeout;
313
314
 
314
315
  // Using retries for error 404
@@ -325,7 +326,8 @@ export class FetcherService {
325
326
  await this._wait();
326
327
 
327
328
  // Getting the response body
328
- const responseData = (await axios<T>(config)).data;
329
+ const response = await axios<T>(config);
330
+ const responseData = response.data;
329
331
 
330
332
  // Check for Twitter API errors in response body
331
333
  // Type guard to check if response contains errors
@@ -348,8 +350,13 @@ export class FetcherService {
348
350
  throw new TwitterError(axiosError);
349
351
  }
350
352
 
351
- // Returning the reponse body
352
- return responseData;
353
+ // Calling the request middleware, if configured
354
+ if (this.config.responseMiddleware !== undefined) {
355
+ await this.config.responseMiddleware(response);
356
+ }
357
+
358
+ // Returning the response
359
+ return response;
353
360
  } catch (err) {
354
361
  // If it's an error 404, retry
355
362
  if (isAxiosError(err) && err.status === 404) {
@@ -59,7 +59,7 @@ export class ListService extends FetcherService {
59
59
  });
60
60
 
61
61
  // Deserializing response
62
- const data = Extractors[resource](response);
62
+ const data = Extractors[resource](response.data);
63
63
 
64
64
  return data;
65
65
  }
@@ -100,7 +100,7 @@ export class ListService extends FetcherService {
100
100
  const response = await this.request<IListDetailsResponse>(resource, { id: id });
101
101
 
102
102
  // Deserializing response
103
- const data = Extractors[resource](response, id);
103
+ const data = Extractors[resource](response.data, id);
104
104
 
105
105
  return data;
106
106
  }
@@ -145,7 +145,7 @@ export class ListService extends FetcherService {
145
145
  });
146
146
 
147
147
  // Deserializing response
148
- const data = Extractors[resource](response);
148
+ const data = Extractors[resource](response.data);
149
149
 
150
150
  return data;
151
151
  }
@@ -186,7 +186,7 @@ export class ListService extends FetcherService {
186
186
  });
187
187
 
188
188
  // Deserializing response
189
- const data = Extractors[resource](response);
189
+ const data = Extractors[resource](response.data);
190
190
 
191
191
  return data;
192
192
  }
@@ -231,7 +231,7 @@ export class ListService extends FetcherService {
231
231
  });
232
232
 
233
233
  // Deserializing response
234
- const data = Extractors[resource](response);
234
+ const data = Extractors[resource](response.data);
235
235
 
236
236
  // Sorting the tweets by date, from recent to oldest
237
237
  data.list.sort((a, b) => new Date(b.createdAt).valueOf() - new Date(a.createdAt).valueOf());
@@ -0,0 +1,65 @@
1
+ import { Extractors } from '../../collections/Extractors';
2
+ import { ResourceType } from '../../enums/Resource';
3
+ import { Space } from '../../models/data/Space';
4
+ import { RettiwtConfig } from '../../models/RettiwtConfig';
5
+ import { ISpaceDetailsOptions } from '../../types/args/FetchArgs';
6
+ import { IAudioSpaceByIdResponse } from '../../types/raw/space/AudioSpaceById';
7
+
8
+ import { FetcherService } from './FetcherService';
9
+
10
+ /**
11
+ * Handles interacting with resources related to spaces.
12
+ *
13
+ * @public
14
+ */
15
+ export class SpaceService extends FetcherService {
16
+ /**
17
+ * @param config - The config object for configuring the Rettiwt instance.
18
+ *
19
+ * @internal
20
+ */
21
+ public constructor(config: RettiwtConfig) {
22
+ super(config);
23
+ }
24
+
25
+ /**
26
+ * Get the details of a space.
27
+ *
28
+ * @param id - The ID of the target space.
29
+ * @param options - Additional options for the fetch.
30
+ *
31
+ * @returns The details of the space with the given ID.
32
+ *
33
+ * @example
34
+ *
35
+ * ```ts
36
+ * import { Rettiwt } from 'rettiwt-api';
37
+ *
38
+ * const rettiwt = new Rettiwt({ apiKey: API_KEY });
39
+ *
40
+ * rettiwt.space.details('1YqJDNEzvoVKV', { withListeners: true })
41
+ * .then(res => {
42
+ * console.log(res);
43
+ * })
44
+ * .catch(err => {
45
+ * console.log(err);
46
+ * });
47
+ * ```
48
+ */
49
+ public async details(id: string, options?: ISpaceDetailsOptions): Promise<Space | undefined> {
50
+ const resource = ResourceType.SPACE_DETAILS;
51
+
52
+ // Fetching raw space details
53
+ const response = await this.request<IAudioSpaceByIdResponse>(resource, {
54
+ id: id,
55
+ withReplays: options?.withReplays,
56
+ withListeners: options?.withListeners,
57
+ isMetatagsQuery: options?.isMetatagsQuery,
58
+ });
59
+
60
+ // Deserializing response
61
+ const data = Extractors[resource](response.data);
62
+
63
+ return data;
64
+ }
65
+ }
@@ -17,7 +17,7 @@ import { ITweetDetailsResponse } from '../../types/raw/tweet/Details';
17
17
  import { ITweetDetailsBulkResponse } from '../../types/raw/tweet/DetailsBulk';
18
18
  import { ITweetLikeResponse } from '../../types/raw/tweet/Like';
19
19
  import { ITweetLikersResponse } from '../../types/raw/tweet/Likers';
20
- import { ITweetPostResponse } from '../../types/raw/tweet/Post';
20
+ import { ITweetPostNoteResponse, ITweetPostResponse } from '../../types/raw/tweet/Post';
21
21
  import { ITweetRepliesResponse } from '../../types/raw/tweet/Replies';
22
22
  import { ITweetRetweetResponse } from '../../types/raw/tweet/Retweet';
23
23
  import { ITweetRetweetersResponse } from '../../types/raw/tweet/Retweeters';
@@ -80,7 +80,7 @@ export class TweetService extends FetcherService {
80
80
  });
81
81
 
82
82
  // Deserializing response
83
- const data = Extractors[resource](response) ?? false;
83
+ const data = Extractors[resource](response.data) ?? false;
84
84
 
85
85
  return data;
86
86
  }
@@ -146,7 +146,7 @@ export class TweetService extends FetcherService {
146
146
  const response = await this.request<ITweetRepliesResponse>(resource, { id: id });
147
147
 
148
148
  // Deserializing response
149
- const data = Extractors[resource](response, id);
149
+ const data = Extractors[resource](response.data, id);
150
150
 
151
151
  return data as T extends string ? Tweet | undefined : Tweet[];
152
152
  }
@@ -158,7 +158,7 @@ export class TweetService extends FetcherService {
158
158
  const response = await this.request<ITweetDetailsBulkResponse>(resource, { ids: id });
159
159
 
160
160
  // Deserializing response
161
- const data = Extractors[resource](response, id);
161
+ const data = Extractors[resource](response.data, id);
162
162
 
163
163
  return data as T extends string ? Tweet | undefined : Tweet[];
164
164
  }
@@ -170,7 +170,7 @@ export class TweetService extends FetcherService {
170
170
  const response = await this.request<ITweetDetailsResponse>(resource, { id: String(id) });
171
171
 
172
172
  // Deserializing response
173
- const data = Extractors[resource](response, String(id));
173
+ const data = Extractors[resource](response.data, String(id));
174
174
 
175
175
  return data as T extends string ? Tweet | undefined : Tweet[];
176
176
  }
@@ -210,7 +210,7 @@ export class TweetService extends FetcherService {
210
210
  });
211
211
 
212
212
  // Deserializing response
213
- const data = Extractors[resource](response) ?? false;
213
+ const data = Extractors[resource](response.data) ?? false;
214
214
 
215
215
  return data;
216
216
  }
@@ -253,7 +253,7 @@ export class TweetService extends FetcherService {
253
253
  });
254
254
 
255
255
  // Deserializing response
256
- const data = Extractors[resource](response);
256
+ const data = Extractors[resource](response.data);
257
257
 
258
258
  return data;
259
259
  }
@@ -342,15 +342,18 @@ export class TweetService extends FetcherService {
342
342
  * ```
343
343
  */
344
344
  public async post(options: INewTweet): Promise<string | undefined> {
345
- const resource = ResourceType.TWEET_POST;
345
+ // Use CreateNoteTweet endpoint for long-form tweets (X Premium, >280 chars)
346
+ if ((options.text?.length ?? 0) > 280) {
347
+ const response = await this.request<ITweetPostNoteResponse>(ResourceType.TWEET_POST_NOTE, {
348
+ tweet: options,
349
+ });
346
350
 
347
- // Posting the tweet
348
- const response = await this.request<ITweetPostResponse>(resource, { tweet: options });
351
+ return Extractors[ResourceType.TWEET_POST_NOTE](response.data);
352
+ }
349
353
 
350
- // Deserializing response
351
- const data = Extractors[resource](response);
354
+ const response = await this.request<ITweetPostResponse>(ResourceType.TWEET_POST, { tweet: options });
352
355
 
353
- return data;
356
+ return Extractors[ResourceType.TWEET_POST](response.data);
354
357
  }
355
358
 
356
359
  /**
@@ -403,7 +406,7 @@ export class TweetService extends FetcherService {
403
406
  });
404
407
 
405
408
  // Deserializing response
406
- const data = Extractors[resource](response);
409
+ const data = Extractors[resource](response.data);
407
410
 
408
411
  return data;
409
412
  }
@@ -440,7 +443,7 @@ export class TweetService extends FetcherService {
440
443
  const response = await this.request<ITweetRetweetResponse>(resource, { id: id });
441
444
 
442
445
  // Deserializing response
443
- const data = Extractors[resource](response) ?? false;
446
+ const data = Extractors[resource](response.data) ?? false;
444
447
 
445
448
  return data;
446
449
  }
@@ -483,7 +486,7 @@ export class TweetService extends FetcherService {
483
486
  });
484
487
 
485
488
  // Deserializing response
486
- const data = Extractors[resource](response);
489
+ const data = Extractors[resource](response.data);
487
490
 
488
491
  return data;
489
492
  }
@@ -525,7 +528,7 @@ export class TweetService extends FetcherService {
525
528
  const response = await this.request<ITweetScheduleResponse>(resource, { tweet: options });
526
529
 
527
530
  // Deserializing response
528
- const data = Extractors[resource](response);
531
+ const data = Extractors[resource](response.data);
529
532
 
530
533
  return data;
531
534
  }
@@ -573,7 +576,7 @@ export class TweetService extends FetcherService {
573
576
  });
574
577
 
575
578
  // Deserializing response
576
- const data = Extractors[resource](response);
579
+ const data = Extractors[resource](response.data);
577
580
 
578
581
  // Sorting the tweets by date, from recent to oldest
579
582
  data.list.sort((a, b) => new Date(b.createdAt).valueOf() - new Date(a.createdAt).valueOf());
@@ -682,7 +685,7 @@ export class TweetService extends FetcherService {
682
685
  const response = await this.request<ITweetUnbookmarkResponse>(resource, { id: id });
683
686
 
684
687
  // Deserializing the response
685
- const data = Extractors[resource](response) ?? false;
688
+ const data = Extractors[resource](response.data) ?? false;
686
689
 
687
690
  return data;
688
691
  }
@@ -719,7 +722,7 @@ export class TweetService extends FetcherService {
719
722
  const response = await this.request<ITweetUnlikeResponse>(resource, { id: id });
720
723
 
721
724
  // Deserializing the response
722
- const data = Extractors[resource](response) ?? false;
725
+ const data = Extractors[resource](response.data) ?? false;
723
726
 
724
727
  return data;
725
728
  }
@@ -756,7 +759,7 @@ export class TweetService extends FetcherService {
756
759
  const response = await this.request<ITweetUnpostResponse>(resource, { id: id });
757
760
 
758
761
  // Deserializing the response
759
- const data = Extractors[resource](response) ?? false;
762
+ const data = Extractors[resource](response.data) ?? false;
760
763
 
761
764
  return data;
762
765
  }
@@ -793,7 +796,7 @@ export class TweetService extends FetcherService {
793
796
  const response = await this.request<ITweetUnretweetResponse>(resource, { id: id });
794
797
 
795
798
  // Deserializing the response
796
- const data = Extractors[resource](response) ?? false;
799
+ const data = Extractors[resource](response.data) ?? false;
797
800
 
798
801
  return data;
799
802
  }
@@ -830,7 +833,7 @@ export class TweetService extends FetcherService {
830
833
  const response = await this.request<ITweetUnscheduleResponse>(resource, { id: id });
831
834
 
832
835
  // Deserializing the response
833
- const data = Extractors[resource](response) ?? false;
836
+ const data = Extractors[resource](response.data) ?? false;
834
837
 
835
838
  return data;
836
839
  }
@@ -873,7 +876,7 @@ export class TweetService extends FetcherService {
873
876
  await this.request<IMediaInitializeUploadResponse>(ResourceType.MEDIA_UPLOAD_INITIALIZE, {
874
877
  upload: { size: size },
875
878
  })
876
- ).media_id_string;
879
+ ).data.media_id_string;
877
880
 
878
881
  // APPEND
879
882
  await this.request<unknown>(ResourceType.MEDIA_UPLOAD_APPEND, { upload: { id: id, media: media } });