New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@the-convocation/twitter-scraper

Package Overview
Dependencies
Maintainers
4
Versions
38
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@the-convocation/twitter-scraper - npm Package Compare versions

Comparing version 0.3.1 to 0.3.2

typedoc.json

8

dist/api.d.ts

@@ -14,2 +14,10 @@ import { TwitterAuth } from './auth';

};
/**
* Used internally to send HTTP requests to the Twitter API.
* @internal
*
* @param url - The URL to send the request to.
* @param auth - The instance of {@link TwitterAuth} that will be used to authorize this request.
* @param method - The HTTP method used when sending this request.
*/
export declare function requestApi<T>(url: string, auth: TwitterAuth, method?: 'GET' | 'POST'): Promise<RequestApiResult<T>>;

@@ -16,0 +24,0 @@ export declare function addApiFeatures(o: object): {

12

dist/api.js

@@ -13,5 +13,14 @@ "use strict";

exports.bearerToken2 = 'AAAAAAAAAAAAAAAAAAAAANRILgAAAAAAnNwIzUejRCOuH5E6I8xnZz4puTs%3D1Zv7ttfk8LF81IUq16cHjhLTvJu4FA33AGWWjCpTnA';
/**
* Used internally to send HTTP requests to the Twitter API.
* @internal
*
* @param url - The URL to send the request to.
* @param auth - The instance of {@link TwitterAuth} that will be used to authorize this request.
* @param method - The HTTP method used when sending this request.
*/
async function requestApi(url, auth, method = 'GET') {
const headers = new headers_polyfill_1.Headers();
await auth.installTo(headers, url);
let delay = 100;
let res;

@@ -36,3 +45,4 @@ do {

if (res.status === 429) {
await new Promise((resolve) => setTimeout(resolve, 100));
await new Promise((resolve) => setTimeout(resolve, delay));
delay *= 2;
}

@@ -39,0 +49,0 @@ } while (res.status === 429);

31

dist/scraper.d.ts

@@ -8,3 +8,3 @@ import { Cookie } from 'tough-cookie';

* An interface to Twitter's undocumented API.
* Reusing Scraper objects is recommended to minimize the time spent authenticating unnecessarily.
* - Reusing Scraper objects is recommended to minimize the time spent authenticating unnecessarily.
*/

@@ -15,4 +15,5 @@ export declare class Scraper {

/**
* Creates a new Scraper object. Scrapers maintain their own guest tokens for Twitter's internal API.
* Reusing Scraper objects is recommended to minimize the time spent authenticating unnecessarily.
* Creates a new Scraper object.
* - Scrapers maintain their own guest tokens for Twitter's internal API.
* - Reusing Scraper objects is recommended to minimize the time spent authenticating unnecessarily.
*/

@@ -23,3 +24,3 @@ constructor();

* @param username The Twitter username of the profile to fetch, without an `@` at the beginning.
* @returns The requested profile.
* @returns The requested {@link Profile}.
*/

@@ -39,3 +40,3 @@ getProfile(username: string): Promise<Profile>;

* @param searchMode The category filter to apply to the search. Defaults to `Top`.
* @returns An async generator of tweets matching the provided filters.
* @returns An {@link AsyncGenerator} of tweets matching the provided filters.
*/

@@ -47,3 +48,3 @@ searchTweets(query: string, maxTweets: number, searchMode?: SearchMode): AsyncGenerator<Tweet, void>;

* @param maxProfiles The maximum number of profiles to return.
* @returns An async generator of tweets matching the provided filters.
* @returns An {@link AsyncGenerator} of tweets matching the provided filter(s).
*/

@@ -77,24 +78,24 @@ searchProfiles(query: string, maxProfiles: number): AsyncGenerator<Profile, void>;

* @param user The user whose tweets should be returned.
* @param maxTweets The maximum number of tweets to return.
* @returns An async generator of tweets from the provided user.
* @param maxTweets The maximum number of tweets to return. Defaults to `200`.
* @returns An {@link AsyncGenerator} of tweets from the provided user.
*/
getTweets(user: string, maxTweets: number): AsyncGenerator<Tweet, void>;
getTweets(user: string, maxTweets?: number): AsyncGenerator<Tweet>;
/**
* Fetches tweets from a Twitter user using their ID.
* @param userId The user whose tweets should be returned.
* @param maxTweets The maximum number of tweets to return.
* @returns An async generator of tweets from the provided user.
* @param maxTweets The maximum number of tweets to return. Defaults to `200`.
* @returns An {@link AsyncGenerator} of tweets from the provided user.
*/
getTweetsByUserId(userId: string, maxTweets: number): AsyncGenerator<Tweet, void>;
getTweetsByUserId(userId: string, maxTweets?: number): AsyncGenerator<Tweet, void>;
/**
* Fetches the most recent tweet from a Twitter user.
* @param user The user whose latest tweet should be returned.
* @param includeRetweets Whether or not to include retweets.
* @param includeRetweets Whether or not to include retweets. Defaults to `false`.
* @returns The {@link Tweet} object or `null`/`undefined` if it couldn't be fetched.
*/
getLatestTweet(user: string, includeRetweets: boolean): Promise<Tweet | null | void>;
getLatestTweet(user: string, includeRetweets?: boolean): Promise<Tweet | null | void>;
/**
* Fetches a single tweet.
* @param id The ID of the tweet to fetch.
* @returns The request tweet, or `null` if it couldn't be fetched.
* @returns The {@link Tweet} object, or `null` if it couldn't be fetched.
*/

@@ -101,0 +102,0 @@ getTweet(id: string): Promise<Tweet | null>;

@@ -14,8 +14,9 @@ "use strict";

* An interface to Twitter's undocumented API.
* Reusing Scraper objects is recommended to minimize the time spent authenticating unnecessarily.
* - Reusing Scraper objects is recommended to minimize the time spent authenticating unnecessarily.
*/
class Scraper {
/**
* Creates a new Scraper object. Scrapers maintain their own guest tokens for Twitter's internal API.
* Reusing Scraper objects is recommended to minimize the time spent authenticating unnecessarily.
* Creates a new Scraper object.
* - Scrapers maintain their own guest tokens for Twitter's internal API.
* - Reusing Scraper objects is recommended to minimize the time spent authenticating unnecessarily.
*/

@@ -29,3 +30,3 @@ constructor() {

* @param username The Twitter username of the profile to fetch, without an `@` at the beginning.
* @returns The requested profile.
* @returns The requested {@link Profile}.
*/

@@ -51,3 +52,3 @@ async getProfile(username) {

* @param searchMode The category filter to apply to the search. Defaults to `Top`.
* @returns An async generator of tweets matching the provided filters.
* @returns An {@link AsyncGenerator} of tweets matching the provided filters.
*/

@@ -61,3 +62,3 @@ searchTweets(query, maxTweets, searchMode = search_1.SearchMode.Top) {

* @param maxProfiles The maximum number of profiles to return.
* @returns An async generator of tweets matching the provided filters.
* @returns An {@link AsyncGenerator} of tweets matching the provided filter(s).
*/

@@ -99,6 +100,6 @@ searchProfiles(query, maxProfiles) {

* @param user The user whose tweets should be returned.
* @param maxTweets The maximum number of tweets to return.
* @returns An async generator of tweets from the provided user.
* @param maxTweets The maximum number of tweets to return. Defaults to `200`.
* @returns An {@link AsyncGenerator} of tweets from the provided user.
*/
getTweets(user, maxTweets) {
getTweets(user, maxTweets = 200) {
return (0, tweets_1.getTweets)(user, maxTweets, this.auth);

@@ -109,6 +110,6 @@ }

* @param userId The user whose tweets should be returned.
* @param maxTweets The maximum number of tweets to return.
* @returns An async generator of tweets from the provided user.
* @param maxTweets The maximum number of tweets to return. Defaults to `200`.
* @returns An {@link AsyncGenerator} of tweets from the provided user.
*/
getTweetsByUserId(userId, maxTweets) {
getTweetsByUserId(userId, maxTweets = 200) {
return (0, tweets_1.getTweetsByUserId)(userId, maxTweets, this.auth);

@@ -119,6 +120,6 @@ }

* @param user The user whose latest tweet should be returned.
* @param includeRetweets Whether or not to include retweets.
* @param includeRetweets Whether or not to include retweets. Defaults to `false`.
* @returns The {@link Tweet} object or `null`/`undefined` if it couldn't be fetched.
*/
getLatestTweet(user, includeRetweets) {
getLatestTweet(user, includeRetweets = false) {
return (0, tweets_1.getLatestTweet)(user, includeRetweets, this.auth);

@@ -129,3 +130,3 @@ }

* @param id The ID of the tweet to fetch.
* @returns The request tweet, or `null` if it couldn't be fetched.
* @returns The {@link Tweet} object, or `null` if it couldn't be fetched.
*/

@@ -132,0 +133,0 @@ getTweet(id) {

{
"name": "@the-convocation/twitter-scraper",
"version": "0.3.1",
"version": "0.3.2",
"main": "dist/_module.js",

@@ -14,3 +14,3 @@ "repository": "https://github.com/the-convocation/twitter-scraper.git",

"commit": "cz",
"docs:generate": "typedoc --entryPoints src --entryPointStrategy expand --exclude **/*.test.ts",
"docs:generate": "typedoc --options typedoc.json",
"docs:deploy": "yarn docs:generate && gh-pages -d docs",

@@ -17,0 +17,0 @@ "format": "prettier --write \\\"src/**/*.ts\\\" \\\"test/**/*.ts\\\"",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc