@youmind-openlab/rettiwt-api 1.0.3 → 1.0.4

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 (61) hide show
  1. package/.devcontainer/devcontainer.json +20 -0
  2. package/README.md +326 -256
  3. package/dist/collections/Extractors.d.ts +9 -2
  4. package/dist/collections/Extractors.js +8 -1
  5. package/dist/collections/Extractors.js.map +1 -1
  6. package/dist/collections/Groups.js +5 -0
  7. package/dist/collections/Groups.js.map +1 -1
  8. package/dist/collections/Requests.js +5 -0
  9. package/dist/collections/Requests.js.map +1 -1
  10. package/dist/commands/User.js +126 -0
  11. package/dist/commands/User.js.map +1 -1
  12. package/dist/enums/Resource.d.ts +6 -1
  13. package/dist/enums/Resource.js +5 -0
  14. package/dist/enums/Resource.js.map +1 -1
  15. package/dist/index.d.ts +2 -0
  16. package/dist/index.js.map +1 -1
  17. package/dist/models/args/PostArgs.d.ts +16 -1
  18. package/dist/models/args/PostArgs.js +44 -1
  19. package/dist/models/args/PostArgs.js.map +1 -1
  20. package/dist/requests/Tweet.d.ts +4 -0
  21. package/dist/requests/Tweet.js +57 -0
  22. package/dist/requests/Tweet.js.map +1 -1
  23. package/dist/requests/User.d.ts +25 -0
  24. package/dist/requests/User.js +59 -0
  25. package/dist/requests/User.js.map +1 -1
  26. package/dist/services/public/FetcherService.d.ts +14 -2
  27. package/dist/services/public/FetcherService.js +21 -6
  28. package/dist/services/public/FetcherService.js.map +1 -1
  29. package/dist/services/public/TweetService.js +9 -6
  30. package/dist/services/public/TweetService.js.map +1 -1
  31. package/dist/services/public/UserService.d.ts +45 -0
  32. package/dist/services/public/UserService.js +211 -0
  33. package/dist/services/public/UserService.js.map +1 -1
  34. package/dist/types/args/PostArgs.d.ts +44 -1
  35. package/dist/types/raw/tweet/Post.d.ts +16 -1
  36. package/dist/types/raw/user/ChangePassword.d.ts +8 -0
  37. package/dist/types/raw/user/ChangePassword.js +3 -0
  38. package/dist/types/raw/user/ChangePassword.js.map +1 -0
  39. package/dist/types/raw/user/ProfileUpdate.d.ts +1 -0
  40. package/dist/types/raw/user/Settings.d.ts +21 -0
  41. package/dist/types/raw/user/Settings.js +4 -0
  42. package/dist/types/raw/user/Settings.js.map +1 -0
  43. package/package.json +4 -2
  44. package/src/collections/Extractors.ts +15 -3
  45. package/src/collections/Groups.ts +5 -0
  46. package/src/collections/Requests.ts +6 -0
  47. package/src/commands/User.ts +146 -0
  48. package/src/enums/Resource.ts +5 -0
  49. package/src/index.ts +2 -0
  50. package/src/models/args/PostArgs.ts +49 -1
  51. package/src/requests/Tweet.ts +59 -0
  52. package/src/requests/User.ts +63 -0
  53. package/src/services/public/FetcherService.ts +27 -7
  54. package/src/services/public/TweetService.ts +10 -7
  55. package/src/services/public/UserService.ts +265 -0
  56. package/src/types/args/PostArgs.ts +50 -1
  57. package/src/types/raw/tweet/Post.ts +19 -1
  58. package/src/types/raw/user/ChangePassword.ts +8 -0
  59. package/src/types/raw/user/ProfileUpdate.ts +1 -0
  60. package/src/types/raw/user/Settings.ts +23 -0
  61. package/.claude/settings.local.json +0 -9
package/README.md CHANGED
@@ -1,252 +1,18 @@
1
- # @youmind-openlab/rettiwt-api
1
+ # Rettiwt-API
2
2
 
3
- YouMind Open Lab fork - An API for fetching data from Twitter/X, **with browser extension support!**
4
-
5
- This is a fork of [Rettiwt-API](https://github.com/Rishikant181/Rettiwt-API) that adds browser extension compatibility. You can now use this library directly in browser extensions without needing to pass API keys - it automatically retrieves authentication from browser cookies.
6
-
7
- ## What's New in This Fork
8
-
9
- - 🌐 **Browser Extension Support** - Use directly in Chrome/Firefox extensions
10
- - 🔐 **Automatic Cookie Authentication** - No need to manually extract API keys
11
- - 📦 **Separate Browser Entry Point** - Import from `@youmind-openlab/rettiwt-api/browser`
12
- - ✨ **Zero Configuration** - Just `new RettiwtBrowser()` and you're ready to go
13
-
14
- ## Installation
15
-
16
- ```bash
17
- npm install @youmind-openlab/rettiwt-api
18
- ```
19
-
20
- ## Quick Start
21
-
22
- ### For Browser Extensions
23
-
24
- ```typescript
25
- import { RettiwtBrowser } from '@youmind-openlab/rettiwt-api/browser';
26
-
27
- const rettiwt = new RettiwtBrowser();
28
-
29
- // Check if user is logged in to X.com
30
- if (await rettiwt.isLoggedIn()) {
31
- // Initialize and verify authentication
32
- const user = await rettiwt.initialize();
33
- console.log(`Logged in as: ${user.userName}`);
34
-
35
- // Fetch bookmarks
36
- const bookmarks = await rettiwt.user.bookmarks(20);
37
- console.log(`Found ${bookmarks.list.length} bookmarks`);
38
-
39
- // Search tweets
40
- const results = await rettiwt.tweet.search({ includeWords: ['javascript'] }, 20);
41
- console.log(`Found ${results.list.length} tweets`);
42
- }
43
- ```
44
-
45
- ### For Node.js (Original Usage)
46
-
47
- ```typescript
48
- import { Rettiwt } from '@youmind-openlab/rettiwt-api';
49
-
50
- // Guest authentication (limited access)
51
- const rettiwt = new Rettiwt();
52
-
53
- // User authentication (full access)
54
- const rettiwt = new Rettiwt({ apiKey: 'YOUR_API_KEY' });
55
-
56
- // Fetch user details
57
- const user = await rettiwt.user.details('elonmusk');
58
- console.log(user);
59
- ```
60
-
61
- ## Browser Extension Usage
62
-
63
- ### Prerequisites
64
-
65
- Your browser extension needs the following permissions in `manifest.json`:
66
-
67
- ```json
68
- {
69
- "manifest_version": 3,
70
- "permissions": ["cookies"],
71
- "host_permissions": [
72
- "https://*.x.com/*",
73
- "https://*.twitter.com/*"
74
- ]
75
- }
76
- ```
77
-
78
- ### RettiwtBrowser API
79
-
80
- #### `isLoggedIn(): Promise<boolean>`
81
-
82
- Checks if the user is logged in to X.com by checking for required cookies. **Does NOT make any API calls.**
83
-
84
- ```typescript
85
- const rettiwt = new RettiwtBrowser();
86
- if (await rettiwt.isLoggedIn()) {
87
- // User is logged in
88
- }
89
- ```
90
-
91
- #### `initialize(): Promise<User>`
92
-
93
- Initializes the library and verifies authentication. Must be called before using other methods.
94
-
95
- ```typescript
96
- const rettiwt = new RettiwtBrowser();
97
- const user = await rettiwt.initialize();
98
- console.log(`Welcome, ${user.fullName}!`);
99
- ```
100
-
101
- #### Available Services
102
-
103
- After initialization, you can access:
104
-
105
- - `rettiwt.user` - User-related operations (bookmarks, followers, following, etc.)
106
- - `rettiwt.tweet` - Tweet-related operations (search, details, like, retweet, etc.)
107
- - `rettiwt.list` - List-related operations
108
- - `rettiwt.dm` - Direct message operations
109
-
110
- ### Example: Fetching Bookmarks with Pagination
111
-
112
- ```typescript
113
- import { RettiwtBrowser, Tweet } from '@youmind-openlab/rettiwt-api/browser';
114
-
115
- const rettiwt = new RettiwtBrowser();
116
- await rettiwt.initialize();
117
-
118
- const allBookmarks: Tweet[] = [];
119
- let cursor: string | undefined;
120
-
121
- do {
122
- const result = await rettiwt.user.bookmarks(20, cursor);
123
- allBookmarks.push(...result.list);
124
- cursor = result.next || undefined;
125
- } while (cursor);
126
-
127
- console.log(`Total bookmarks: ${allBookmarks.length}`);
128
- ```
129
-
130
- ### Example: Searching Tweets
131
-
132
- ```typescript
133
- const results = await rettiwt.tweet.search({
134
- includeWords: ['typescript', 'react'],
135
- fromUsers: ['dan_abramov'],
136
- minLikes: 100
137
- }, 20);
138
-
139
- for (const tweet of results.list) {
140
- console.log(`@${tweet.tweetBy?.userName}: ${tweet.fullText}`);
141
- }
142
- ```
143
-
144
- ### Configuration Options
145
-
146
- ```typescript
147
- const rettiwt = new RettiwtBrowser({
148
- timeout: 30000, // Request timeout in ms
149
- logging: true, // Enable debug logging
150
- maxRetries: 5, // Retries on 404 errors (default: 5)
151
- delay: 1000, // Delay between requests in ms
152
- });
153
- ```
154
-
155
- ## Building Your Own Extension
156
-
157
- ### 1. Set up webpack for browser bundling
158
-
159
- ```javascript
160
- // webpack.config.js
161
- const webpack = require('webpack');
162
-
163
- module.exports = {
164
- entry: './src/popup.ts',
165
- output: {
166
- filename: 'popup.js',
167
- path: __dirname + '/dist',
168
- },
169
- resolve: {
170
- extensions: ['.ts', '.js'],
171
- fallback: {
172
- fs: false,
173
- path: false,
174
- crypto: false,
175
- stream: require.resolve('stream-browserify'),
176
- buffer: require.resolve('buffer/'),
177
- },
178
- },
179
- plugins: [
180
- new webpack.ProvidePlugin({
181
- Buffer: ['buffer', 'Buffer'],
182
- }),
183
- ],
184
- module: {
185
- rules: [
186
- { test: /\.ts$/, use: 'ts-loader', exclude: /node_modules/ },
187
- ],
188
- },
189
- };
190
- ```
191
-
192
- ### 2. Install browser polyfills
193
-
194
- ```bash
195
- npm install --save-dev buffer stream-browserify
196
- ```
197
-
198
- ### 3. Create your extension popup
199
-
200
- ```typescript
201
- // popup.ts
202
- import { RettiwtBrowser } from '@youmind-openlab/rettiwt-api/browser';
203
-
204
- async function main() {
205
- const rettiwt = new RettiwtBrowser();
206
-
207
- if (!(await rettiwt.isLoggedIn())) {
208
- document.body.innerHTML = '<p>Please log in to X.com first</p>';
209
- return;
210
- }
211
-
212
- const user = await rettiwt.initialize();
213
- document.body.innerHTML = `<p>Welcome, ${user.fullName}!</p>`;
214
- }
215
-
216
- main();
217
- ```
218
-
219
- ## Exported Types
220
-
221
- The browser entry point exports the following:
222
-
223
- ```typescript
224
- import {
225
- RettiwtBrowser, // Main browser class
226
- User, // User data type
227
- Tweet, // Tweet data type
228
- CursoredData, // Paginated response type
229
- // ... and more
230
- } from '@youmind-openlab/rettiwt-api/browser';
231
- ```
232
-
233
- ---
234
-
235
- # Original Rettiwt-API Documentation
236
-
237
- The sections below are from the original Rettiwt-API documentation for Node.js usage.
3
+ A CLI tool and an API for fetching data from Twitter for free!
238
4
 
239
5
  ## Prerequisites
240
6
 
241
7
  - NodeJS 22
242
8
  - A working Twitter account (optional)
243
9
 
244
- ## Installation (CLI)
10
+ ## Installation
245
11
 
246
12
  It is recommended to install the package globally, if you want to use it from the CLI. Use the following steps to install the package and ensure it's installed correctly:
247
13
 
248
14
  1. Open a terminal.
249
- 2. Install the package using the command `npm install -g @youmind-openlab/rettiwt-api`.
15
+ 2. Install the package using the command `npm install -g rettiwt-api`.
250
16
  3. Check if the package is installed correctly using the command `rettiwt help`.
251
17
 
252
18
  For using the package in your own project, you can install it as a [dependency](https://rishikant181.github.io/Rettiwt-API/#md:usage-as-a-dependency).
@@ -258,6 +24,7 @@ Rettiwt-API can be used with or without logging in to Twitter. As such, the two
258
24
  - 'Guest' authentication (without logging in) grants access to the following resources/actions:
259
25
 
260
26
  - Tweet Details
27
+ - Space Details
261
28
  - User Details (by username)
262
29
  - User Timeline
263
30
 
@@ -290,6 +57,7 @@ Rettiwt-API can be used with or without logging in to Twitter. As such, the two
290
57
  - Tweet Unschedule
291
58
  - User Affiliates
292
59
  - User Analytics (Only for Premium accounts)
60
+ - User About Profile (by username)
293
61
  - User Bookmarks
294
62
  - User Bookmark Folders
295
63
  - User Bookmark Folder Tweets
@@ -310,6 +78,10 @@ Rettiwt-API can be used with or without logging in to Twitter. As such, the two
310
78
  - User Timeline
311
79
  - User Unfollow
312
80
  - User Profile Update
81
+ - User Profile Image Update
82
+ - User Profile Banner Update
83
+ - User Username Change
84
+ - User Password Change
313
85
 
314
86
  By default, Rettiwt-API uses 'guest' authentication. If however, access to the full set of resources is required, 'user' authentication can be used. This is done by using the cookies associated with your Twitter/X account, and encoding them into an `API_KEY` for convenience. The said `API_KEY` can be obtained by using a browser extension, as follows:
315
87
 
@@ -345,15 +117,21 @@ The API_KEY generated by logging in is what allows Rettiwt-API to authenticate a
345
117
  - The API_KEY is actually a base64 encoding of the account's cookies.
346
118
  - The API_KEY provides the same level of authorization as any standard Twitter account, nothing more, nothing less.
347
119
 
120
+ ## Notes for non-programmers
121
+
122
+ - If you have no idea of programming, it's recommended to use the CLI.
123
+ - The CLI provides an easy to use interface which does not require any knowledge of JavaScript or programming
124
+ - Please skip to [CLI-Usage](https://rishikant181.github.io/Rettiwt-API/#md:cli-usage) for details.
125
+
348
126
  ## Usage as a dependency
349
127
 
350
128
  Rettiwt-API can be used as a dependency for your NodeJS project. In such a case, it is not required to install Rettiwt-API globally and you may install it locally in the root of your project using the command:
351
129
 
352
- - `npm install --save @youmind-openlab/rettiwt-api` (using npm)
130
+ - `npm install --save rettiwt-api` (using npm)
353
131
 
354
132
  or
355
133
 
356
- - `yarn add @youmind-openlab/rettiwt-api` (using yarn)
134
+ - `yarn add rettiwt-api` (using yarn)
357
135
 
358
136
  However, in this case, for accessing the CLI, you will be required to prepend the CLI commands with `npx` in order to tell NodeJS to use the locally installed package.
359
137
 
@@ -366,10 +144,11 @@ A new Rettiwt instance can be initialized using the following code snippets:
366
144
  - `const rettiwt = new Rettiwt()` (for 'guest' authentication)
367
145
  - `const rettiwt = new Rettiwt({ apiKey: API_KEY })` (for 'user' authentication)
368
146
 
369
- The Rettiwt class has four members:
147
+ The Rettiwt class has five members:
370
148
 
371
149
  - `dm` member, for accessing resources related to direct messages.
372
150
  - `list` member, for accessing resources related to lists.
151
+ - `space` member, for accessing resources related to spaces.
373
152
  - `tweet` member, for accessing resources related to tweets.
374
153
  - `user` member, for accessing resources related to users.
375
154
 
@@ -395,12 +174,34 @@ Of these parameters, the following are hot-swappable, using their respective set
395
174
  - `headers`
396
175
  - `proxyUrl`
397
176
 
398
- ## Usage Examples
177
+ The following example demonstrates changing the API key on the fly:
178
+
179
+ ```ts
180
+ import { Rettiwt } from 'rettiwt-api';
181
+
182
+ // Initializing a new Rettiwt instance with API key 1
183
+ const rettiwt = new Rettiwt({ apiKey: '<API_KEY_1>' });
184
+
185
+ rettiwt.user.details().then((res) => {
186
+ console.log(res); // Returns details of the user associated with API_KEY_1
187
+ });
188
+
189
+ // Changing API key to API key 2
190
+ rettiwt.apiKey = '<API_KEY_2>';
191
+
192
+ rettiwt.user.details().then((res) => {
193
+ console.log(res); // Returns details of the user associated with API_KEY_2
194
+ });
195
+ ```
196
+
197
+ ## Usage
198
+
199
+ The following examples may help you to get started using the library:
399
200
 
400
201
  ### 1. Getting the details of a target Twitter user
401
202
 
402
203
  ```ts
403
- import { Rettiwt } from '@youmind-openlab/rettiwt-api';
204
+ import { Rettiwt } from 'rettiwt-api';
404
205
 
405
206
  // Creating a new Rettiwt instance
406
207
  // Note that for accessing user details, 'guest' authentication can be used
@@ -409,17 +210,17 @@ const rettiwt = new Rettiwt();
409
210
  // Fetching the details of the user whose username is <username>
410
211
  rettiwt.user.details('<username>')
411
212
  .then(details => {
412
- console.log(details);
213
+ ...
413
214
  })
414
215
  .catch(error => {
415
- console.error(error);
216
+ ...
416
217
  });
417
218
  ```
418
219
 
419
220
  ### 2. Getting the list of tweets that match a given filter
420
221
 
421
222
  ```ts
422
- import { Rettiwt } from '@youmind-openlab/rettiwt-api';
223
+ import { Rettiwt } from 'rettiwt-api';
423
224
 
424
225
  // Creating a new Rettiwt instance using the API_KEY
425
226
  const rettiwt = new Rettiwt({ apiKey: API_KEY });
@@ -434,10 +235,10 @@ rettiwt.tweet.search({
434
235
  includeWords: ['<word1>', '<word2>']
435
236
  })
436
237
  .then(data => {
437
- console.log(data);
238
+ ...
438
239
  })
439
240
  .catch(err => {
440
- console.error(err);
241
+ ...
441
242
  });
442
243
  ```
443
244
 
@@ -445,8 +246,10 @@ For more information regarding the different available filter options, please re
445
246
 
446
247
  ### 3. Getting the next batch of data using a cursor
447
248
 
249
+ The previous example fetches the the list of tweets matching the given filter. Since no count is specified, in this case, a default of 20 such Tweets are fetched initially. The following example demonstrates how to use the [cursor string](https://rishikant181.github.io/Rettiwt-API/classes/Cursor.html#value) obtained from the [response](https://rishikant181.github.io/Rettiwt-API/classes/CursoredData.html) object's [next](https://rishikant181.github.io/Rettiwt-API/classes/CursoredData.html#next) field, from the previous example, to fetch the next batch of tweets:
250
+
448
251
  ```ts
449
- import { Rettiwt } from '@youmind-openlab/rettiwt-api';
252
+ import { Rettiwt } from 'rettiwt-api';
450
253
 
451
254
  // Creating a new Rettiwt instance using the API_KEY
452
255
  const rettiwt = new Rettiwt({ apiKey: API_KEY });
@@ -465,13 +268,68 @@ rettiwt.tweet.search({
465
268
  includeWords: ['<word1>', '<word2>']
466
269
  }, count, data.next.value)
467
270
  .then(data => {
468
- console.log(data);
271
+ ...
469
272
  })
470
273
  .catch(err => {
471
- console.error(err);
274
+ ...
472
275
  });
473
276
  ```
474
277
 
278
+ ### 4. Getting an API_KEY during runtime, using 'user' authentication (Borked)
279
+
280
+ Sometimes, you might want to generate an API_KEY on the fly, in situations such as implementing Twitter login in your application. The following example demonstrates how to generate an API_KEY during runtime:
281
+
282
+ ```ts
283
+ import { Rettiwt } from 'rettiwt-api';
284
+
285
+ // Creating a new Rettiwt instance
286
+ const rettiwt = new Rettiwt();
287
+
288
+ // Logging in an getting the API_KEY
289
+ rettiwt.auth.login('<email>', '<username>', '<password>')
290
+ .then(apiKey => {
291
+ // Use the API_KEY
292
+ ...
293
+ })
294
+ .catch(err => {
295
+ console.log(err);
296
+ });
297
+ ```
298
+
299
+ Where,
300
+
301
+ - `<email>` is the email associated with the Twitter account to be logged into.
302
+ - `<username>` is the username associated with the Twitter account.
303
+ - `<password>` is the password to the Twitter account.
304
+
305
+ ## Using a custom error handler
306
+
307
+ Out of the box, `Rettiwt`'s error handling is bare-minimum, only able to parse basic error messages. For advanced scenarios, where full error response might be required, in order to diagnose error reason, it's recommended to use a custom error handler, by implementing the `IErrorHandler` interface, as follows:
308
+
309
+ ```ts
310
+ import { Rettiwt, IErrorHandler } from 'rettiwt-api';
311
+
312
+ // Implementing an error handler
313
+ class CustomErrorHandler implements IErrorHandler {
314
+ /**
315
+ * This is where you handle the error yourself.
316
+ */
317
+ public handler(error: unknown): void {
318
+ // The 'error' variable has the full, raw error response returned from Twitter.
319
+ /**
320
+ * You custom error handling logic goes here
321
+ */
322
+
323
+ console.log(`Raw Twitter Error: ${JSON.stringify(error)}`);
324
+ }
325
+ }
326
+
327
+ // Now we'll use the implemented error handler while initializing Rettiwt
328
+ const rettiwt = new Rettiwt({ apiKey: '<API_KEY>', errorHandler: CustomErrorHandler });
329
+ ```
330
+
331
+ You can then use the created `rettiwt` instance and your custom error handler will handler all the error responses, bypassing `Rettiwt`'s error handling logic.
332
+
475
333
  ## Using a proxy
476
334
 
477
335
  For masking of IP address using a proxy server, use the following code snippet for instantiation of Rettiwt:
@@ -496,6 +354,199 @@ Sometimes, when the library shows unexpected behaviour, for troubleshooting purp
496
354
  const rettiwt = new Rettiwt({ apiKey: API_KEY, logging: true });
497
355
  ```
498
356
 
357
+ ## Accessing raw response
358
+
359
+ For getting the raw data instead of the parsed results, all data models provide a getter `raw` which returns the raw data entity as returned by Twitter, instead of parsing them to Rettiwt's own data entity formats. The following example demonstrates the use of the `raw` getter:
360
+
361
+ ```ts
362
+ import { Rettiwt } from 'rettiwt-api';
363
+
364
+ // Creating a new Rettiwt instance
365
+ // Note that for accessing user details, 'guest' authentication can be used
366
+ const rettiwt = new Rettiwt();
367
+
368
+ // Fetching the details of the user whose username is <username>
369
+ rettiwt.user.details('<username>')
370
+ .then(details => {
371
+ console.log(details);
372
+ // {
373
+ // "createdAt": "2021-07-24T14:25:32.000Z",
374
+ // "description": "Coder, Gamer and Tech Enthusiast",
375
+ // "followersCount": 3,
376
+ // "followingsCount": 44,
377
+ // "fullName": "Rishikant Sahu",
378
+ // "id": "1418940387037782018",
379
+ // "isVerified": false,
380
+ // "likeCount": 762,
381
+ // "profileImage": "https://abs.twimg.com/sticky/default_profile_images/default_profile_normal.png",
382
+ // "statusesCount": 5,
383
+ // "userName": "negmatico"
384
+ // }
385
+
386
+ console.log(details.raw);
387
+ // {
388
+ // "__typename": "User",
389
+ // "id": "VXNlcjoxNDE4OTQwMzg3MDM3NzgyMDE4",
390
+ // "rest_id": "1418940387037782018",
391
+ // "affiliates_highlighted_label": {},
392
+ // "has_graduated_access": true,
393
+ // "is_blue_verified": false,
394
+ // "legacy": {
395
+ // "following": false,
396
+ // "can_dm": true,
397
+ // "can_media_tag": true,
398
+ // "created_at": "Sat Jul 24 14:25:32 +0000 2021",
399
+ // "default_profile": true,
400
+ // "default_profile_image": true,
401
+ // "description": "Coder, Gamer and Tech Enthusiast",
402
+ // "entities": { "description": { "urls": [] } },
403
+ // "fast_followers_count": 0,
404
+ // "favourites_count": 762,
405
+ // "followers_count": 3,
406
+ // "friends_count": 44,
407
+ // "has_custom_timelines": false,
408
+ // "is_translator": false,
409
+ // "listed_count": 0,
410
+ // "location": "",
411
+ // "media_count": 0,
412
+ // "name": "Rishikant Sahu",
413
+ // "needs_phone_verification": false,
414
+ // "normal_followers_count": 3,
415
+ // "pinned_tweet_ids_str": [],
416
+ // "possibly_sensitive": false,
417
+ // "profile_image_url_https": "https://abs.twimg.com/sticky/default_profile_images/default_profile_normal.png",
418
+ // "profile_interstitial_type": "",
419
+ // "screen_name": "negmatico",
420
+ // "statuses_count": 5,
421
+ // "translator_type": "none",
422
+ // "verified": false,
423
+ // "want_retweets": false,
424
+ // "withheld_in_countries": []
425
+ // },
426
+ // "parody_commentary_fan_label": "None",
427
+ // "profile_image_shape": "Circle",
428
+ // "tipjar_settings": {},
429
+ // "verified_phone_status": false,
430
+ // "legacy_extended_profile": {
431
+ // "birthdate": { "day": 18, "month": 1, "year": 2001, "visibility": "Self", "year_visibility": "Self" }
432
+ // },
433
+ // "is_profile_translatable": false,
434
+ // "has_hidden_subscriptions_on_profile": false,
435
+ // "verification_info": { "is_identity_verified": false },
436
+ // "highlights_info": { "can_highlight_tweets": false, "highlighted_tweets": "0" },
437
+ // "user_seed_tweet_count": 0,
438
+ // "premium_gifting_eligible": true,
439
+ // "business_account": {},
440
+ // "creator_subscriptions_count": 0
441
+ // }
442
+
443
+ })
444
+ .catch(error => {
445
+ ...
446
+ });
447
+ ```
448
+
449
+ However, if further control over the raw response is required, Rettiwt-API provides the [`FetcherService`](https://rishikant181.github.io/Rettiwt-API/classes/FetcherService.html) class which provides direct access to the raw response, but keep in mind, this delegates the task of parsing and filtering the results to the consumer of the library. The following example demonstrates using the `FetcherService` class:
450
+
451
+ ```ts
452
+ import { RettiwtConfig, FetcherService, ResourceType, IUserDetailsResponse } from 'rettiwt-api';
453
+
454
+ // Creating the configuration for Rettiwt
455
+ const config = new RettiwtConfig({ apiKey: '<API_KEY>' });
456
+
457
+ // Creating a new FetcherService instance using the config
458
+ const fetcher = new FetcherService(config);
459
+
460
+ // Fetching the details of the given user
461
+ fetcher
462
+ .request<IUserDetailsResponse>(ResourceType.USER_DETAILS_BY_USERNAME, { id: 'user1' })
463
+ .then((res) => {
464
+ console.log(res);
465
+ })
466
+ .catch((err) => {
467
+ console.log(err);
468
+ });
469
+ ```
470
+
471
+ As demonstrated by the example, the raw data can be accessed by using the `request` method of the `FetcherService` class, which takes two parameters. The first parameter is the name of the requested resource, while the second is an object specifying the associated arguments required for the given resource. The complete list of resource type can be checked [here](https://rishikant181.github.io/Rettiwt-API/enums/AuthService.html#ResourceType). As for the resource specific argurments, they are the same as that of the methods of `Rettiwt` class' methods for the respective resources, but structured as an object. Notice how the `FetcherService` class takes the same arguments as the `Rettiwt` class, and the arguments have the same effects as they have in case of `Rettiwt` class.
472
+
473
+ #### Notes:
474
+
475
+ - For for hot-swapping in case of using `FetcherService`, the setters are accessed from the `config` object as `config.apiKey = ...`, `config.proxyUrl = ...`, etc.
476
+
477
+ ## Data serialization
478
+
479
+ The data returned by all functions of `Rettiwt` are complex objects, containing non-serialized fields like `raw`. In order to get JSON-serializable data, all data objects returned by `Rettiwt` provide a function `toJSON()` which converts the data into a serializable JSON, whose type is described by their respective interfaces i.e, `ITweet` for `Tweet`, `IUser` for `User` and so on.
480
+
481
+ For handling and processing of data returned by the functions, it's always advisable to serialize them using the `toJSON()` function.
482
+
483
+ ## Features
484
+
485
+ So far, the following operations are supported:
486
+
487
+ ### Direct Messages
488
+
489
+ - [Getting the DM inbox](https://rishikant181.github.io/Rettiwt-API/classes/DirectMessageService.html#inbox)
490
+ - [Getting a specific conversation with full message history](https://rishikant181.github.io/Rettiwt-API/classes/DirectMessageService.html#conversation)
491
+ - [Deleting a conversation](https://rishikant181.github.io/Rettiwt-API/classes/DirectMessageService.html#deleteConversation)
492
+
493
+ ### List
494
+
495
+ - [Adding a member to a given Twitter list](https://rishikant181.github.io/Rettiwt-API/classes/ListService.html#addMember)
496
+ - [Getting the details of a given Twitter list](https://rishikant181.github.io/Rettiwt-API/classes/ListService.html#details)
497
+ - [Getting the members of a given Twitter list](https://rishikant181.github.io/Rettiwt-API/classes/ListService.html#members)
498
+ - [Removing a member from a given Twitter list](https://rishikant181.github.io/Rettiwt-API/classes/ListService.html#removeMember)
499
+ - [Getting the list of tweets from a given Twitter list](https://rishikant181.github.io/Rettiwt-API/classes/ListService.html#tweets)
500
+
501
+ ### Tweets
502
+
503
+ - [Bookmarking a tweet](https://rishikant181.github.io/Rettiwt-API/classes/TweetService.html#bookmark)
504
+ - [Getting the details of a tweet/multiple tweets](https://rishikant181.github.io/Rettiwt-API/classes/TweetService.html#details)
505
+ - [Liking a tweet](https://rishikant181.github.io/Rettiwt-API/classes/TweetService.html#like)
506
+ - [Getting the list of users who liked your tweet](https://rishikant181.github.io/Rettiwt-API/classes/TweetService.html#likers)
507
+ - [Posting a new tweet](https://rishikant181.github.io/Rettiwt-API/classes/TweetService.html#post)
508
+ - [Getting the list of replies to a tweet](https://rishikant181.github.io/Rettiwt-API/classes/TweetService.html#replies)
509
+ - [Retweeting a tweet](https://rishikant181.github.io/Rettiwt-API/classes/TweetService.html#retweet)
510
+ - [Getting the list of users who retweeted a given tweet by the logged-in user](https://rishikant181.github.io/Rettiwt-API/classes/TweetService.html#retweeters)
511
+ - [Scheduling a new tweet](https://rishikant181.github.io/Rettiwt-API/classes/TweetService.html#schedule)
512
+ - [Searching for the list of tweets that match a given filter](https://rishikant181.github.io/Rettiwt-API/classes/TweetService.html#search)
513
+ - [Streaming filtered tweets in pseudo-realtime](https://rishikant181.github.io/Rettiwt-API/classes/TweetService.html#stream)
514
+ - [Unbookmarking a tweet](https://rishikant181.github.io/Rettiwt-API/classes/TweetService.html#unbookmark)
515
+ - [Unliking a tweet](https://rishikant181.github.io/Rettiwt-API/classes/TweetService.html#unlike)
516
+ - [Unposting a tweet](https://rishikant181.github.io/Rettiwt-API/classes/TweetService.html#unpost)
517
+ - [Unretweeting a tweet](https://rishikant181.github.io/Rettiwt-API/classes/TweetService.html#unretweet)
518
+ - [Unscheduling a tweet](https://rishikant181.github.io/Rettiwt-API/classes/TweetService.html#unschedule)
519
+ - [Uploading a media file for a tweet](https://rishikant181.github.io/Rettiwt-API/classes/TweetService.html#upload)
520
+
521
+ ### Users
522
+
523
+ - [Getting the list of users affiliated with the given user](https://rishikant181.github.io/Rettiwt-API/classes/UserService.html#affiliates)
524
+ - [Getting the analytics of the logged-in user (premium accounts only)](https://rishikant181.github.io/Rettiwt-API/classes/UserService.html#analytics)
525
+ - [Getting the about profile of a user](https://rishikant181.github.io/Rettiwt-API/classes/UserService.html#about)
526
+ - [Getting the list of tweets bookmarked by the logged-in user](https://rishikant181.github.io/Rettiwt-API/classes/UserService.html#bookmarks)
527
+ - [Getting the list of bookmark folders of the logged-in user](https://rishikant181.github.io/Rettiwt-API/classes/UserService.html#bookmarkFolders)
528
+ - [Getting the list of tweets in a specific bookmark folder](https://rishikant181.github.io/Rettiwt-API/classes/UserService.html#bookmarkFolderTweets)
529
+ - [Getting the details of a user/multiple users](https://rishikant181.github.io/Rettiwt-API/classes/UserService.html#details)
530
+ - [Following a given user](https://rishikant181.github.io/Rettiwt-API/classes/UserService.html#follow)
531
+ - [Getting the followed feed of the logged-in user](https://rishikant181.github.io/Rettiwt-API/classes/UserService.html#followed)
532
+ - [Getting the list of users who follow the given user](https://rishikant181.github.io/Rettiwt-API/classes/UserService.html#followers)
533
+ - [Getting the list of users who are followed by the given user](https://rishikant181.github.io/Rettiwt-API/classes/UserService.html#following)
534
+ - [Getting the list of highlighted tweets of the given user](https://rishikant181.github.io/Rettiwt-API/classes/UserService.html#highlights)
535
+ - [Getting the list of tweets liked by the logged-in user](https://rishikant181.github.io/Rettiwt-API/classes/UserService.html#likes)
536
+ - [Getting the lists of the logged-in user](https://rishikant181.github.io/Rettiwt-API/classes/UserService.html#lists)
537
+ - [Getting the media timeline of the given user](https://rishikant181.github.io/Rettiwt-API/classes/UserService.html#media)
538
+ - [Streaming notifications of the logged-in user in pseudo-realtime](https://rishikant181.github.io/Rettiwt-API/classes/UserService.html#notifications)
539
+ - [Getting the recommended feed of the logged-in user](https://rishikant181.github.io/Rettiwt-API/classes/UserService.html#recommended)
540
+ - [Getting the replies timeline of the given user](https://rishikant181.github.io/Rettiwt-API/classes/UserService.html#replies)
541
+ - [Searching for a username](https://rishikant181.github.io/Rettiwt-API/classes/UserService.html#search)
542
+ - [Getting the tweet timeline of the given user](https://rishikant181.github.io/Rettiwt-API/classes/UserService.html#timeline)
543
+ - [Unfollowing a given user](https://rishikant181.github.io/Rettiwt-API/classes/UserService.html#unfollow)
544
+ - [Updating the profile of the logged-in user](https://rishikant181.github.io/Rettiwt-API/classes/UserService.html#updateProfile)
545
+ - [Updating the profile image of the logged-in user](https://rishikant181.github.io/Rettiwt-API/classes/UserService.html#updateProfileImage)
546
+ - [Updating the profile banner of the logged-in user](https://rishikant181.github.io/Rettiwt-API/classes/UserService.html#updateProfileBanner)
547
+ - [Changing the username of the logged-in user](https://rishikant181.github.io/Rettiwt-API/classes/UserService.html#changeUsername)
548
+ - [Changing the password of the logged-in user](https://rishikant181.github.io/Rettiwt-API/classes/UserService.html#changePassword)
549
+
499
550
  ## CLI Usage
500
551
 
501
552
  Rettiwt-API provides an easy to use command-line interface which does not require any programming knowledge.
@@ -514,15 +565,34 @@ Help for the CLI can be obtained from the CLI itself:
514
565
  - For help regarding the available commands, use the command `rettiwt help`
515
566
  - For help regarding a specific command, use the command `rettiwt help <command_name>`
516
567
 
568
+ ### Common user account commands
569
+
570
+ ```bash
571
+ # Update profile fields
572
+ rettiwt user update-profile --name "Jane Doe" --location "Berlin"
573
+
574
+ # Update profile image and banner from file paths
575
+ rettiwt user update-profile-image ./profile.jpg
576
+ rettiwt user update-profile-banner ./banner.jpg
577
+
578
+ # Change username
579
+ rettiwt user change-username new_username
580
+
581
+ # Change password (interactive prompt)
582
+ rettiwt user change-password
583
+ ```
584
+
585
+ Use `rettiwt user change-password --show-new-key` to print the rotated `API_KEY` after a successful password update.
586
+ If you store your `API_KEY` outside the current process, update that stored value after changing the password.
587
+
517
588
  ## API Reference
518
589
 
519
590
  The complete API reference can be found at [this](https://rishikant181.github.io/Rettiwt-API/modules) page.
520
591
 
521
- ## License
592
+ ## Additional information
522
593
 
523
- ISC
594
+ - This API uses the cookies of a Twitter account to fetch data from Twitter and as such, there is always a chance (although a measly one) of getting the account banned by Twitter algorithm.
524
595
 
525
- ## Credits
596
+ ## Donation
526
597
 
527
- - Original [Rettiwt-API](https://github.com/Rishikant181/Rettiwt-API) by [Rishikant Sahu](https://github.com/Rishikant181)
528
- - Browser extension support by [YouMind Open Lab](https://github.com/youmind-openlab)
598
+ Support this project by donating at my [PayPal](https://paypal.me/Rishikant181?country.x=IN&locale.x=en_GB).