Socket
Socket
Sign inDemoInstall

twitter-api-scraper

Package Overview
Dependencies
2
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    twitter-api-scraper

Scrape the twitter api, no keys required.


Version published
Weekly downloads
1
Maintainers
1
Install size
535 kB
Created
Weekly downloads
 

Readme

Source

twitter-api-scraper

Get typed data from the public twitter api. No keys required.

NPM JavaScript Style Guide License Issues

  • Search tweets
  • Get users by username
  • Get users by id
  • Get hashflags
  • Get tweets from user
  • Get replies from tweet
  • Get trending topics

Install

npm install --save twitter-api-scraper

Usage

Start client

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

Typescript

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)

Search parameters

const query: SearchQuery = {
  terms: '#typescript',
  dateFrom: '2021-02-15',
  dateTo: '2021-02-17',
  minReplies: 10,
  minRetweets: 10,
  minFaves: 10,
  lang: 'es'
}
client.search(query)

Search multiple pages

const result = await client.search(query, 100)
const { nextToken } = result

const secondPageResult = await client.search(query, 100, nextToken)

Original api response

const originalApiResult = await client.searchRaw(
  {
    terms: 'hello world!'
  }
)

Users

Get user

const user: UserInterface = await client.getUser('jack')

Get user by id

const user: UserFromId = await client.getUserById('12')

Hashflags

const hashflags: Hashflag[] = await client.getHashflags('2021-09-23')

License

MIT © matiasngf

FAQs

Last updated on 23 Sep 2021

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc