Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mkosir/twit-wrapper
Twitter API client for Node.js
https://github.com/mkosir/twit-wrapper
javascript library nodejs twitter
Last synced: 25 days 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 (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2020-03-14T07:26:49.000Z (almost 5 years ago)
- Last Synced: 2024-12-03T03:46:24.705Z (about 1 month 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
[![npm](https://img.shields.io/npm/v/twit-wrapper.svg)](https://www.npmjs.com/package/twit-wrapper)
[![Travis (.org)](https://img.shields.io/travis/mkosir/twit-wrapper.svg)](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);
}
```