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

twitter-api-v2

Package Overview
Dependencies
Maintainers
1
Versions
73
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

twitter-api-v2 - npm Package Compare versions

Comparing version 1.0.0 to 1.1.0

5

changelog.md

@@ -0,1 +1,6 @@

1.1.0
-----
- Add the new v2 likes endpoint
- Fix: add some missing media types
1.0.0

@@ -2,0 +7,0 @@ -----

3

dist/test/utils.d.ts
import { TwitterApi } from '..';
/** User OAuth 1.0a client */
export declare function getUserClient(): TwitterApi;
export declare function getUserClient(this: any): TwitterApi;
export declare function sleepTest(ms: number): Promise<unknown>;
/** User-unlogged OAuth 1.0a client */

@@ -5,0 +6,0 @@ export declare function getRequestClient(): TwitterApi;

@@ -6,3 +6,3 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.getAppClient = exports.getAccessClient = exports.getAuthLink = exports.getRequestClient = exports.getUserClient = void 0;
exports.getAppClient = exports.getAccessClient = exports.getAuthLink = exports.getRequestClient = exports.sleepTest = exports.getUserClient = void 0;
const __1 = require("..");

@@ -13,3 +13,6 @@ const dotenv_1 = __importDefault(require("dotenv"));

function getUserClient() {
return new __1.TwitterApi({
if (this.__client) {
return this.__client;
}
return this.__client = new __1.TwitterApi({
appKey: process.env.CONSUMER_TOKEN,

@@ -22,2 +25,6 @@ appSecret: process.env.CONSUMER_SECRET,

exports.getUserClient = getUserClient;
async function sleepTest(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}
exports.sleepTest = sleepTest;
/** User-unlogged OAuth 1.0a client */

@@ -24,0 +31,0 @@ function getRequestClient() {

@@ -32,2 +32,3 @@ import type { UserV2 } from './user.v2.types';

width?: number;
url?: string;
preview_image_url?: string;

@@ -34,0 +35,0 @@ non_public_metrics?: PlaybackCountV2;

@@ -25,3 +25,3 @@ import type { TweetV2, ApiV2Includes } from './tweet.definition.v2';

export declare type TTweetv2Expansion = 'attachments.poll_ids' | 'attachments.media_keys' | 'author_id' | 'referenced_tweets.id' | 'in_reply_to_user_id' | 'geo.place_id' | 'entities.mentions.username' | 'referenced_tweets.id.author_id';
export declare type TTweetv2MediaField = 'duration_ms' | 'height' | 'media_key' | 'preview_image_url' | 'type' | 'url' | 'width' | 'public_metrics';
export declare type TTweetv2MediaField = 'duration_ms' | 'height' | 'media_key' | 'preview_image_url' | 'type' | 'url' | 'width' | 'public_metrics' | 'non_public_metrics' | 'organic_metrics';
export declare type TTweetv2PlaceField = 'contained_within' | 'country' | 'country_code' | 'full_name' | 'geo' | 'id' | 'name' | 'place_type';

@@ -52,1 +52,4 @@ export declare type TTweetv2PollField = 'duration_minutes' | 'end_datetime' | 'id' | 'options' | 'voting_status';

}>;
export declare type TweetV2LikeResult = DataV2<{
liked: boolean;
}>;
import TwitterApiv2ReadOnly from './client.v2.read';
import type { TweetV2HideReplyResult, UserV2BlockResult, UserV2FollowResult, UserV2UnfollowResult } from '../types';
import type { TweetV2HideReplyResult, TweetV2LikeResult, UserV2BlockResult, UserV2FollowResult, UserV2UnfollowResult } from '../types';
import TwitterApiv2LabsReadWrite from '../v2-labs/client.v2.labs.write';

@@ -24,2 +24,17 @@ /**

/**
* Causes the user ID identified in the path parameter to Like the target Tweet.
* https://developer.twitter.com/en/docs/twitter-api/tweets/likes/api-reference/post-users-user_id-likes
*
* **Note**: You must specify the currently logged user ID ; you can obtain it through v1.1 API.
*/
like(loggedUserId: string, targetTweetId: string): Promise<TweetV2LikeResult>;
/**
* Allows a user or authenticated user ID to unlike a Tweet.
* The request succeeds with no action when the user sends a request to a user they're not liking the Tweet or have already unliked the Tweet.
* https://developer.twitter.com/en/docs/twitter-api/tweets/likes/api-reference/delete-users-user_id-likes
*
* **Note**: You must specify the currently logged user ID ; you can obtain it through v1.1 API.
*/
unlike(loggedUserId: string, targetTweetId: string): Promise<TweetV2LikeResult>;
/**
* Allows a user ID to follow another user.

@@ -26,0 +41,0 @@ * If the target user does not have public Tweets, this endpoint will send a follow request.

@@ -40,2 +40,21 @@ "use strict";

}
/**
* Causes the user ID identified in the path parameter to Like the target Tweet.
* https://developer.twitter.com/en/docs/twitter-api/tweets/likes/api-reference/post-users-user_id-likes
*
* **Note**: You must specify the currently logged user ID ; you can obtain it through v1.1 API.
*/
like(loggedUserId, targetTweetId) {
return this.post(`users/${loggedUserId}/likes`, { tweet_id: targetTweetId });
}
/**
* Allows a user or authenticated user ID to unlike a Tweet.
* The request succeeds with no action when the user sends a request to a user they're not liking the Tweet or have already unliked the Tweet.
* https://developer.twitter.com/en/docs/twitter-api/tweets/likes/api-reference/delete-users-user_id-likes
*
* **Note**: You must specify the currently logged user ID ; you can obtain it through v1.1 API.
*/
unlike(loggedUserId, targetTweetId) {
return this.delete(`users/${loggedUserId}/likes/${targetTweetId}`);
}
/* Users */

@@ -42,0 +61,0 @@ /**

{
"name": "twitter-api-v2",
"version": "1.0.0",
"version": "1.1.0",
"description": "Strongly typed, full-featured, light, versatile yet powerful Twitter API v1.1 and v2 client for Node.js.",

@@ -27,3 +27,3 @@ "main": "dist/index.js",

},
"repository": "github:plhery/node-twitter-api",
"repository": "github:plhery/node-twitter-api-v2",
"author": "Paul-Louis Hery <paullouis.hery+twitterapi@gmail.com> (https://twitter.com/plhery)",

@@ -30,0 +30,0 @@ "license": "Apache-2.0",

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