You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In detail:
- added API calls for adding, deleting and getting filter stream rules
- added stream API call
- added appropriate types
- attempted to stick with current code and exporting structure
- updated README
Copy file name to clipboardExpand all lines: README.md
+67-1Lines changed: 67 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -314,6 +314,70 @@ See the [OAuth example](#oauth-authentication).
314
314
315
315
See the [OAuth example](#oauth-authentication).
316
316
317
+
## Twitter Labs Support
318
+
319
+
[Twitter Labs](https://developer.twitter.com/en/labs) is early access to new endpoints developed by Twitter. Using Twitter Labs requires explicit opt-in, therefore Twitter Labs functionalities are also supported in an opt-in manner.
320
+
321
+
In order to create an instance that comes with Twitter Labs functionalities all you need to do is the following
322
+
323
+
```es6
324
+
constclient=newTwitter({
325
+
consumer_key:"xyz",
326
+
consumer_secret:"xyz"
327
+
});
328
+
329
+
/**
330
+
* will produce object instance with Twitter Labs
331
+
* functionalities in ADDITION to the base Twitter API functionalities
332
+
*/
333
+
constclientWithLabs=client.withLabs()
334
+
```
335
+
336
+
All the options fed to the base `Twitter` instance will be copied over to the instance with Twitter Labs support, and so you don't need to do any more setup.
337
+
338
+
However, not all Twitter Labs APIs are supported currently. If an API is not yet implemented, you can consider making a PR! Please see [contribution guidelines](##contributing).
339
+
340
+
### Supported Twitter Labs APIs
341
+
342
+
#### Filtered streams
343
+
344
+
Support for [Twitter Labs filtered streams](https://developer.twitter.com/en/docs/labs/filtered-stream/api-reference) is provided. The following is an example on how to use it:
process.nextTick(() =>stream.destroy()); // emits "end" and "error" events
369
+
```
370
+
371
+
The streaming functionality uses the same underlying streaming capabilities as shown in the [stream section](##Streams).
372
+
373
+
The methods to interact with the whole filtered stream API suite are:
374
+
-`addRules(rules, dryRun)`
375
+
-`getRules(...ids)`
376
+
-`deleteRules(ids, dryRun)`
377
+
-`filterStream(queryParams)`
378
+
379
+
JSDoc and Typescript documentation are provided for all of them.
380
+
317
381
## Examples
318
382
319
383
You can find many more examples for various resources/endpoints in [the tests](test).
@@ -375,7 +439,9 @@ With the library nearing v1.0, contributions are welcome! Areas especially in ne
375
439
ACCESS_TOKEN=...
376
440
ACCESS_TOKEN_SECRET=...
377
441
```
378
-
5. `yarn/npm test` and make sure all tests pass
442
+
5.
443
+
- `yarn/npm test` and make sure all tests pass
444
+
- `yarn/npm run test-labs` to run Twitter Labs related tests and make sure all tests pass
379
445
6. Add your contribution, along with test case(s). Note: feel free to skip the ["should DM user"](https://github.com/draftbit/twitter-lite/blob/34e8dbb3efb9a45564275f16473af59dbc4409e5/twitter.test.js#L167) test during development by changing that `it()` call to `it.skip()`, but remember to revert that change before committing. This will prevent your account from being flagged as [abusing the API to send too many DMs](https://github.com/draftbit/twitter-lite/commit/5ee2ce4232faa07453ea2f0b4d63ee7a6d119ce7).
380
446
7. Make sure all tests pass. **NOTE: tests will take over 10 minutes to finish.**
381
447
8. Commit using a [descriptive message](https://chris.beams.io/posts/git-commit/) (please squash commits into one per fix/improvement!)
0 commit comments