Internal
Optional
config: IRettiwtConfigThe config object for configuring the Rettiwt instance.
Protected
Optional
Readonly
authThe URL to the proxy server to use for authentication.
Get the details of a tweet.
The id of the target tweet.
The details of a single tweet with the given tweet id.
import { Rettiwt } from 'rettiwt-api';
// Creating a new Rettiwt instance using the given 'API_KEY'
const rettiwt = new Rettiwt({ apiKey: API_KEY });
// Fetching the details of the tweet with the id '12345678'
rettiwt.tweet.details('12345678')
.then(res => {
console.log(res);
})
.catch(err => {
console.log(err);
});
Favorite the tweet with the given id.
The id of the tweet to be favorited.
Whether favoriting was successful or not.
import { Rettiwt } from 'rettiwt-api';
// Creating a new Rettiwt instance using the given 'API_KEY'
const rettiwt = new Rettiwt({ apiKey: API_KEY });
// Liking the Tweet with id '12345678'
rettiwt.tweet.favorite('12345678')
.then(res => {
console.log(res);
})
.catch(err => {
console.log(err);
});
Get the list of users who liked a tweet.
The rest id of the target tweet.
Optional
count: numberThe number of favoriters to fetch, must be <= 100.
Optional
cursor: stringThe cursor to the batch of favoriters to fetch.
The list of users who liked the given tweet.
import { Rettiwt } from 'rettiwt-api';
// Creating a new Rettiwt instance using the given 'API_KEY'
const rettiwt = new Rettiwt({ apiKey: API_KEY });
// Fetching the most recent 100 likers of the Tweet with id '12345678'
rettiwt.tweet.favoriters('12345678')
.then(res => {
console.log(res);
})
.catch(err => {
console.log(err);
});
Protected
fetchFetches the requested resource from Twitter and returns it after processing.
The type of resource to fetch.
Resource specific arguments.
The processed data requested from Twitter.
Get the tweets from the tweet list with the given id.
The id of list from where the tweets are to be fetched.
Optional
count: numberThe number of tweets to fetch, must be <= 100.
Optional
cursor: stringThe cursor to the batch of tweets to fetch.
The list tweets present in the given list.
import { Rettiwt } from 'rettiwt-api';
// Creating a new Rettiwt instance using the given 'API_KEY'
const rettiwt = new Rettiwt({ apiKey: API_KEY });
// Fetching the most recent 100 tweets of the Twitter list with id '12345678'
rettiwt.tweet.list('12345678')
.then(res => {
console.log(res);
})
.catch(err => {
console.log(err);
});
Due a bug in Twitter API, the count is ignored when no cursor is provided and defaults to 100.
Protected
postRetweet the tweet with the given id.
The id of the tweet with the given id.
Whether retweeting was successful or not.
import { Rettiwt } from 'rettiwt-api';
// Creating a new Rettiwt instance using the given 'API_KEY'
const rettiwt = new Rettiwt({ apiKey: API_KEY });
// Retweeting the Tweet with id '12345678'
rettiwt.tweet.retweet('12345678')
.then(res => {
console.log(res);
})
.catch(err => {
console.log(err);
});
Get the list of users who retweeted a tweet.
The rest id of the target tweet.
Optional
count: numberThe number of retweeters to fetch, must be <= 100.
Optional
cursor: stringThe cursor to the batch of retweeters to fetch.
The list of users who retweeted the given tweet.
import { Rettiwt } from 'rettiwt-api';
// Creating a new Rettiwt instance using the given 'API_KEY'
const rettiwt = new Rettiwt({ apiKey: API_KEY });
// Fetching the most recent 100 retweeters of the Tweet with id '12345678'
rettiwt.tweet.retweeters('12345678')
.then(res => {
console.log(res);
})
.catch(err => {
console.log(err);
});
Search for tweets using a query.
The query be used for searching the tweets.
Optional
count: numberThe number of tweets to fetch, must be <= 20.
Optional
cursor: stringThe cursor to the batch of tweets to fetch.
The list of tweets that match the given filter.
import { Rettiwt } from 'rettiwt-api';
// Creating a new Rettiwt instance using the given 'API_KEY'
const rettiwt = new Rettiwt({ apiKey: API_KEY });
// Fetching the most recent 5 tweets from user 'user1'
rettiwt.tweet.search({ fromUsers: ['user1'] }, 5)
.then(res => {
console.log(res);
})
.catch(err => {
console.log(err);
});
For details about available filters, refer to TweetFilter
Stream tweets in pseudo real-time using a filter.
The filter to be used for searching the tweets.
The interval in milliseconds to poll for new tweets. Default interval is 60000 ms.
An async generator that yields matching tweets as they are found.
import { Rettiwt } from 'rettiwt-api';
// Creating a new Rettiwt instance using the given 'API_KEY'
const rettiwt = new Rettiwt({ apiKey: API_KEY });
// Streaming all upcoming tweets from user 'user1'
(async () => {
try {
for await (const tweet of rettiwt.tweet.stream({ fromUsers: ['user1'] }, 1000)) {
console.log(tweet.fullText);
}
}
catch (err) {
console.log(err);
}
})();
Post a tweet.
The text to be posted, length must be <= 280 characters.
Optional
media: TweetMediaArgs[]The list of media to post in the tweet, max number of media must be <= 4.
Optional
replyTo: stringThe id of the tweet to which the reply is to be made.
Whether posting was successful or not.
Posting a simple text
import { Rettiwt } from 'rettiwt-api';
// Creating a new Rettiwt instance using the given 'API_KEY'
const rettiwt = new Rettiwt({ apiKey: API_KEY });
// Posting a tweet to twitter
rettiwt.tweet.tweet('Hello World!')
.then(res => {
console.log(res);
})
.catch(err => {
console.log(err);
});
Posting a tweet with an image
import { Rettiwt } from 'rettiwt-api';
// Creating a new Rettiwt instance using the given 'API_KEY'
const rettiwt = new Rettiwt({ apiKey: API_KEY });
// Posting a tweet, containing an image called 'mountains.jpg', to twitter
rettiwt.tweet.tweet('What a nice view!', [{ path: 'mountains.jpg' }])
.then(res => {
console.log(res);
})
.catch(err => {
console.log(err);
});
Posting a reply to a tweet
import { Rettiwt } from 'rettiwt-api';
// Creating a new Rettiwt instance using the given 'API_KEY'
const rettiwt = new Rettiwt({ apiKey: API_KEY });
// Posting a simple text reply, to a tweet with id "1234567890"
rettiwt.tweet.tweet('Hello!', undefined, "1234567890")
.then(res => {
console.log(res);
})
.catch(err => {
console.log(err);
});
Protected
uploadGenerated using TypeDoc
Handles fetching of data related to tweets.