rettiwt-api 2.4.0 → 2.4.2
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/README.md +58 -39
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,15 +1,23 @@
|
|
|
1
1
|
# Rettiwt-API
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
A CLI tool and an API for fetching data from Twitter for free!
|
|
4
4
|
|
|
5
5
|
## Prerequisites
|
|
6
6
|
|
|
7
7
|
- NodeJS 20.10.0
|
|
8
|
-
- A working Twitter account
|
|
8
|
+
- A working Twitter account (optional)
|
|
9
9
|
|
|
10
|
-
##
|
|
10
|
+
## Installation
|
|
11
|
+
|
|
12
|
+
It is recommended to install the package globally. Use the following steps to install the package and ensure it's installed correctly:
|
|
13
|
+
|
|
14
|
+
1. Open a terminal.
|
|
15
|
+
2. Install the package using the command `npm install -g rettiwt-api`.
|
|
16
|
+
3. Check if the package is installed correctly using the command `rettiwt help`.
|
|
11
17
|
|
|
12
|
-
|
|
18
|
+
## Authentication
|
|
19
|
+
|
|
20
|
+
Rettiwt-API can be used with or without logging in to Twitter. As such, the two authentication strategies are:
|
|
13
21
|
|
|
14
22
|
- 'guest' authentication (without logging in) grants access to the following resources:
|
|
15
23
|
|
|
@@ -32,43 +40,62 @@ Rettiwt can be used with or without logging in to Twitter. As such, the two auth
|
|
|
32
40
|
- User Timeline (tweets timeline)
|
|
33
41
|
- User Replies (replies timeline)
|
|
34
42
|
|
|
43
|
+
By default, Rettiwt-API uses 'guest' authentication. If however, access to the full set of resources is required, 'user' authentication can be used, which requires the following additional steps post-installtion:
|
|
44
|
+
|
|
45
|
+
1. Open a terminal.
|
|
46
|
+
2. Generate an API_KEY using the command `rettiwt auth login <email> <username> <password>`
|
|
47
|
+
|
|
48
|
+
Here,
|
|
49
|
+
|
|
50
|
+
- \<email\> is the email of the Twitter account to be used for authentication.
|
|
51
|
+
- \<username\> is the username associtated with the Twitter account.
|
|
52
|
+
- \<password\> is the password to the Twitter account.
|
|
53
|
+
|
|
54
|
+
3. The string returned after running the command is the API_KEY. Store it in a secure place for later use.
|
|
55
|
+
|
|
56
|
+
## The API_KEY
|
|
57
|
+
|
|
58
|
+
The API_KEY generated by logging in is what allows Rettiwt-API to authenticate as a logged in user while interacting with the Twitter API ('user' authentication). As such it is a very sensitive information and therefore, must be stored securely. The following points must be kept in mind while using the API_KEY for 'user' authentication:
|
|
59
|
+
|
|
60
|
+
- The API_KEY is generated by logging into Twitter using the email, username and password and encoding the returned cookies as a base64 string. This encoded string is the API_KEY.
|
|
61
|
+
- The API_KEY provides the same level of authorization as any standard Twitter account, nothing more, nothing less.
|
|
62
|
+
- Since generation of API_KEY is equivalent to logging in to Twitter, repeated generation attempts might trigger Twitter's anti-bot measures, the same way repeated login attempts do.
|
|
63
|
+
- The API_KEY expires after one year from the day it was generated.
|
|
64
|
+
- Therefore, it is recommended to generate the API_KEY only once, then use it every time it is needed.
|
|
65
|
+
- Do not generate an API_KEY if it has not expired yet!
|
|
66
|
+
|
|
35
67
|
## Notes for non-programmers
|
|
36
68
|
|
|
37
69
|
- If you have no idea of programming, it's recommended to use the CLI.
|
|
38
70
|
- The CLI provides an easy to use interface which does not require any knowledge of JavaScript or programming
|
|
39
71
|
- Please skip to 'CLI-Usage' section for details.
|
|
40
72
|
|
|
41
|
-
##
|
|
73
|
+
## Usage as a dependency
|
|
42
74
|
|
|
43
|
-
|
|
44
|
-
2. Install the package either via npm or yarn:
|
|
45
|
-
- For npm, use the command `npm install --save rettiwt-api`
|
|
46
|
-
- For yarn, use the command `yarn add rettiwt-api`
|
|
75
|
+
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:
|
|
47
76
|
|
|
48
|
-
|
|
77
|
+
- `npm install --save rettiwt-api` (using npm)
|
|
49
78
|
|
|
50
|
-
|
|
79
|
+
or
|
|
51
80
|
|
|
52
|
-
|
|
53
|
-
2. The generated string is the API_KEY.
|
|
54
|
-
3. Create a new instance of Rettiwt, passing in the API key as a config object:
|
|
55
|
-
`const rettiwt = Rettiwt({ apiKey: API_KEY });`
|
|
56
|
-
The available options in the config object can be found [here](https://rishikant181.github.io/Rettiwt-API/classes/RettiwtConfig.html).
|
|
57
|
-
4. Use the created [Rettiwt](https://rishikant181.github.io/Rettiwt-API/classes/Rettiwt.html) instance to fetch data from Twitter.
|
|
81
|
+
- `yarn add rettiwt-api` (using yarn)
|
|
58
82
|
|
|
59
|
-
|
|
83
|
+
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.
|
|
60
84
|
|
|
61
|
-
|
|
85
|
+
For example, for generating the API_KEY, the command will be modified as follows:
|
|
62
86
|
|
|
63
|
-
|
|
87
|
+
`npx rettiwt auth login <email> <username> <password>`
|
|
64
88
|
|
|
65
|
-
|
|
89
|
+
## The Rettiwt class
|
|
66
90
|
|
|
67
|
-
|
|
91
|
+
When used as a dependency, the Rettiwt class is entry point for accessing the Twitter API.
|
|
68
92
|
|
|
69
|
-
|
|
93
|
+
A new Rettiwt instance can be initialized using the following code snippets:
|
|
70
94
|
|
|
71
|
-
|
|
95
|
+
- `const rettiwt = new Rettiwt()` (for 'guest' authentication)
|
|
96
|
+
- `const rettiwt = new Rettiwt({ apiKey: API_KEY })` (for 'user' authentication)
|
|
97
|
+
|
|
98
|
+
The Rettiwt class has two members:
|
|
72
99
|
|
|
73
100
|
- 'tweet' member, for accessing resources related to tweets
|
|
74
101
|
- 'user' member, for accessing resources related to users
|
|
@@ -84,8 +111,9 @@ The following examples may help you to get started using the library:
|
|
|
84
111
|
```js
|
|
85
112
|
const { Rettiwt } = require('rettiwt-api');
|
|
86
113
|
|
|
87
|
-
// Creating a new Rettiwt instance
|
|
88
|
-
|
|
114
|
+
// Creating a new Rettiwt instance
|
|
115
|
+
// Note that for accessing user details, 'guest' authentication can be used
|
|
116
|
+
const rettiwt = new Rettiwt();
|
|
89
117
|
|
|
90
118
|
// Fetching the details of the user whose username is <username>
|
|
91
119
|
rettiwt.user.details('<username>')
|
|
@@ -203,34 +231,25 @@ So far, the following operations are supported:
|
|
|
203
231
|
|
|
204
232
|
## CLI Usage
|
|
205
233
|
|
|
206
|
-
Rettiwt-API
|
|
207
|
-
|
|
208
|
-
### Installation
|
|
209
|
-
|
|
210
|
-
1. Install the recommended version of NodeJS specified in the 'Prerequisites' section.
|
|
211
|
-
2. Open a terminal.
|
|
212
|
-
3. Install the package globally using the command `npm install -g rettiwt-api`.
|
|
213
|
-
4. Use the command `rettiwt help` to ensure that the package has been installed correctly.
|
|
214
|
-
|
|
215
|
-
### Authentication
|
|
234
|
+
Rettiwt-API provides an easy to use command-line interface which does not require any programming knowledge.
|
|
216
235
|
|
|
217
236
|
By default, the CLI operates in 'guest' authentication. If you want to use 'user' authentication:
|
|
218
237
|
|
|
219
|
-
1. Generate an API_KEY
|
|
238
|
+
1. Generate an API_KEY as described in 'Authentication' section.
|
|
220
239
|
2. Store the output API_KEY as an environment variable with the name 'API_KEY'.
|
|
221
240
|
- Additionaly, store the API_KEY in a file for later use.
|
|
222
241
|
- Make sure to generate an API_KEY only once, and use it every time you need it.
|
|
223
242
|
3. The CLI automatically reads this environment variable to authenticate against Twitter.
|
|
224
243
|
- Additionaly, the API_KEY can also be passed in manually using the '-k' option as follows: `rettiwt -k <API_KEY> <command>`
|
|
225
244
|
|
|
226
|
-
|
|
245
|
+
Help for the CLI can be obtained from the CLI itself:
|
|
227
246
|
|
|
228
247
|
- For help regarding the available commands, use the command `rettiwt help`
|
|
229
248
|
- For help regarding a specific command, use the command `rettiwt help <command_name>`
|
|
230
249
|
|
|
231
250
|
## API Reference
|
|
232
251
|
|
|
233
|
-
The complete API reference can be found at [this](https://rishikant181.github.io/Rettiwt-API/) page.
|
|
252
|
+
The complete API reference can be found at [this](https://rishikant181.github.io/Rettiwt-API/modules) page.
|
|
234
253
|
|
|
235
254
|
## Additional information
|
|
236
255
|
|