https://github.com/mkosir/twit-wrapper
Twitter API client for Node.js
https://github.com/mkosir/twit-wrapper
javascript library nodejs twitter
Last synced: 10 months ago
JSON representation
Twitter API client for Node.js
- Host: GitHub
- URL: https://github.com/mkosir/twit-wrapper
- Owner: mkosir
- Created: 2019-03-22T09:38:32.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2020-03-14T07:26:49.000Z (over 6 years ago)
- Last Synced: 2025-08-31T23:26:30.353Z (10 months ago)
- Topics: javascript, library, nodejs, twitter
- Language: JavaScript
- Homepage:
- Size: 81.1 KB
- Stars: 14
- Watchers: 3
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# twit-wrapper
[](https://www.npmjs.com/package/twit-wrapper)
[](https://travis-ci.org/mkosir/twit-wrapper)
## Twitter API client for Node.js
This is a small utility wrapper/facade library which translates [twit](https://github.com/ttezel/twit) existing interface into simplified one.
#### Prerequisite
To interact with Twitter API, head over to [Twitter Developer Platform](https://developer.twitter.com/) and create new application.
Once you are done filling out information, you need to generate four access tokens:
- Consumer API Key
- Consumer API Secret Key
- Access Token
- Access Token Secret
## Install
```shell
npm i twit-wrapper
```
## Usage:
Only most commonly used function for interacting with Twitter API are implemented:
- postTweet(msg)
- getTweets(keyword, fromDate, lang = 'en', maxResults = 100)
```js
const TwitterClient = require('twit-wrapper');
const twitterClient = new TwitterClient(
consumerAPIKey,
consumerAPISecretKey,
accessToken,
accessTokenSecret,
);
// post new tweet
try {
const msgToPost = 'Post a test message';
const postedMsg = await twitterClient.postTweet(msgToPost);
console.log(postedMsg);
} catch (e) {
console.error(e);
}
// search twitter for all tweets containing the word 'javascript' since January 1, 2017
try {
const searchedTweets = await twitterClient.getTweets('javascript', '2017-01-01');
console.log(searchedTweets);
} catch (e) {
console.error(e);
}
```