rettiwt-api 2.4.1 → 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.
Files changed (2) hide show
  1. package/README.md +55 -47
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -1,15 +1,23 @@
1
1
  # Rettiwt-API
2
2
 
3
- An API for fetching data from Twitter for free!
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
- ## Types of Authentication
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
- Rettiwt can be used with or without logging in to Twitter. As such, the two authentication strategies are:
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,37 +40,18 @@ 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
 
35
- ## Notes for non-programmers
36
-
37
- - If you have no idea of programming, it's recommended to use the CLI.
38
- - The CLI provides an easy to use interface which does not require any knowledge of JavaScript or programming
39
- - Please skip to 'CLI-Usage' section for details.
40
-
41
- ## Installation
42
-
43
- 1. Initialize a new Node.JS project using the command `npm init`.
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`
47
-
48
- Although the above process initializes a new project, that is, in fact, not necessary and you may add it to an existing Node.JS project and omit the first step altogether.
49
-
50
- ## Getting started
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:
51
44
 
52
- 1. Generate credentials using the command `npx rettiwt auth login <email> <username> <password>` in a terminal in the root of your project.
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.
45
+ 1. Open a terminal.
46
+ 2. Generate an API_KEY using the command `rettiwt auth login <email> <username> <password>`
58
47
 
59
- **Notes:**
48
+ Here,
60
49
 
61
- - The API_KEY that we generated, is a very sensitive information and provides all access to the Twitter account. Therefore, it is generally recommended to store it as an environment variable and use it from there.
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.
62
53
 
63
- - The given example above uses 'user' authentication by using an API_KEY generated from the Twitter account.
64
-
65
- - It's also possible to use this package without using a Twitter account, by omitting the 'apiKey' parameter in the config object. However, in this case, 'guest' authentication is used.
54
+ 3. The string returned after running the command is the API_KEY. Store it in a secure place for later use.
66
55
 
67
56
  ## The API_KEY
68
57
 
@@ -75,9 +64,36 @@ The API_KEY generated by logging in is what allows Rettiwt-API to authenticate a
75
64
  - Therefore, it is recommended to generate the API_KEY only once, then use it every time it is needed.
76
65
  - Do not generate an API_KEY if it has not expired yet!
77
66
 
67
+ ## Notes for non-programmers
68
+
69
+ - If you have no idea of programming, it's recommended to use the CLI.
70
+ - The CLI provides an easy to use interface which does not require any knowledge of JavaScript or programming
71
+ - Please skip to 'CLI-Usage' section for details.
72
+
73
+ ## Usage as a dependency
74
+
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:
76
+
77
+ - `npm install --save rettiwt-api` (using npm)
78
+
79
+ or
80
+
81
+ - `yarn add rettiwt-api` (using yarn)
82
+
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.
84
+
85
+ For example, for generating the API_KEY, the command will be modified as follows:
86
+
87
+ `npx rettiwt auth login <email> <username> <password>`
88
+
78
89
  ## The Rettiwt class
79
90
 
80
- The Rettiwt class is entry point for accessing the Twitter API.
91
+ When used as a dependency, the Rettiwt class is entry point for accessing the Twitter API.
92
+
93
+ A new Rettiwt instance can be initialized using the following code snippets:
94
+
95
+ - `const rettiwt = new Rettiwt()` (for 'guest' authentication)
96
+ - `const rettiwt = new Rettiwt({ apiKey: API_KEY })` (for 'user' authentication)
81
97
 
82
98
  The Rettiwt class has two members:
83
99
 
@@ -95,8 +111,9 @@ The following examples may help you to get started using the library:
95
111
  ```js
96
112
  const { Rettiwt } = require('rettiwt-api');
97
113
 
98
- // Creating a new Rettiwt instance using the API_KEY
99
- const rettiwt = new Rettiwt({ apiKey: API_KEY });
114
+ // Creating a new Rettiwt instance
115
+ // Note that for accessing user details, 'guest' authentication can be used
116
+ const rettiwt = new Rettiwt();
100
117
 
101
118
  // Fetching the details of the user whose username is <username>
102
119
  rettiwt.user.details('<username>')
@@ -214,34 +231,25 @@ So far, the following operations are supported:
214
231
 
215
232
  ## CLI Usage
216
233
 
217
- Rettiwt-API also provides an easy to use command-line interface which does not require any programming knowledge.
218
-
219
- ### Installation
220
-
221
- 1. Install the recommended version of NodeJS specified in the 'Prerequisites' section.
222
- 2. Open a terminal.
223
- 3. Install the package globally using the command `npm install -g rettiwt-api`.
224
- 4. Use the command `rettiwt help` to ensure that the package has been installed correctly.
225
-
226
- ### Authentication
234
+ Rettiwt-API provides an easy to use command-line interface which does not require any programming knowledge.
227
235
 
228
236
  By default, the CLI operates in 'guest' authentication. If you want to use 'user' authentication:
229
237
 
230
- 1. Generate an API_KEY using the command `rettiwt auth login <email> <username> <password>`.
238
+ 1. Generate an API_KEY as described in 'Authentication' section.
231
239
  2. Store the output API_KEY as an environment variable with the name 'API_KEY'.
232
240
  - Additionaly, store the API_KEY in a file for later use.
233
241
  - Make sure to generate an API_KEY only once, and use it every time you need it.
234
242
  3. The CLI automatically reads this environment variable to authenticate against Twitter.
235
243
  - Additionaly, the API_KEY can also be passed in manually using the '-k' option as follows: `rettiwt -k <API_KEY> <command>`
236
244
 
237
- ### Help
245
+ Help for the CLI can be obtained from the CLI itself:
238
246
 
239
247
  - For help regarding the available commands, use the command `rettiwt help`
240
248
  - For help regarding a specific command, use the command `rettiwt help <command_name>`
241
249
 
242
250
  ## API Reference
243
251
 
244
- 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.
245
253
 
246
254
  ## Additional information
247
255
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rettiwt-api",
3
- "version": "2.4.1",
3
+ "version": "2.4.2",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "description": "An API for fetching data from TwitterAPI, without any rate limits!",