Get typed data from the public twitter api. No keys required.
- Search tweets
- Get users by username
- Get users by id
- Get hashflags
- Get tweets from user
- Get replies from tweet
- Get trending topics
npm install --save twitter-api-scraper
First, connect() the client.
import TwitterClient from 'twitter-api-scraper'
const client = new TwitterClient()
await client.connect()
const maxTweets = 3000
const result = await client.search(
{
terms: 'hello world!'
},
maxTweets
)
const { tweets, users, nextToken } = result
import { SearchQuery, ParsedSearchResult } from 'twitter-api-scraper'
const query: SearchQuery = {
terms: '#typescript',
dateFrom: '2021-02-15',
dateTo: '2021-02-15'
}
const result: ParsedSearchResult = await client.search(query)
const query: SearchQuery = {
terms: '#typescript',
dateFrom: '2021-02-15',
dateTo: '2021-02-17',
minReplies: 10,
minRetweets: 10,
minFaves: 10,
lang: 'es'
}
client.search(query)
const result = await client.search(query, 100)
const { nextToken } = result
const secondPageResult = await client.search(query, 100, nextToken)
const originalApiResult = await client.searchRaw(
{
terms: 'hello world!'
}
)
const user: UserInterface = await client.getUser('jack')
const user: UserFromId = await client.getUserById('12')
const hashflags: Hashflag[] = await client.getHashflags('2021-09-23')
MIT © matiasngf