Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/joao208/v2-twitter
Biblioteca Para a versão 2 da api do twitter, para auxiliar no uso dos métodos da api, com typescript, e nodejs
https://github.com/joao208/v2-twitter
api express twitter
Last synced: 14 days ago
JSON representation
Biblioteca Para a versão 2 da api do twitter, para auxiliar no uso dos métodos da api, com typescript, e nodejs
- Host: GitHub
- URL: https://github.com/joao208/v2-twitter
- Owner: Joao208
- Created: 2021-11-19T02:22:27.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2022-03-07T21:37:23.000Z (almost 3 years ago)
- Last Synced: 2024-12-03T12:55:25.138Z (22 days ago)
- Topics: api, express, twitter
- Language: TypeScript
- Homepage: https://www.npmjs.com/package/v2-twitter
- Size: 143 KB
- Stars: 3
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
## Twitter V2
[![v2](https://img.shields.io/endpoint?url=https%3A%2F%2Ftwbadges.glitch.me%2Fbadges%2Fv2)](https://developer.twitter.com/en/docs/twitter-api)
[![codecov](https://codecov.io/gh/Joao208/v2-twitter/branch/main/graph/badge.svg?token=YK3MIN9SMX)](https://codecov.io/gh/Joao208/v2-twitter)
[![Sonarcloud Status](https://sonarcloud.io/api/project_badges/measure?project=Joao208_v2-twitter&metric=alert_status)](https://sonarcloud.io/dashboard?id=Joao208_v2-twitter)Twitter api, using [V2](https://developer.twitter.com/en), for use, create new instance of api, no parameter is necessary, but if you don't pass BearerToken, the others params `ConsumerKey, ConsumerSecret, AccessToken, AccessSecret` are necessary, but you can pass all parameters
```js
import TwitterApi from 'v2-twitter'const twitter = new TwitterApi({
BearerToken: "",
ConsumerKey: "",
ConsumerSecret: "",
AccessToken: "",
AccessSecret: "",
});
```
#### Get An User By UsernameFor get all user information's:, all parameters and fields can be consulted [here](https://developer.twitter.com/en/docs/twitter-api/fields)
```js
.getUserByUsername("TwitterDev", ['profile_image_url'])
.then((data) => console.log(data));// {
// "data": {
// "id": "2244994945",
// "name": "Twitter Dev",
// "username": "TwitterDev"
// }
// }
```#### Get Many Users For Username
For get all user information's for many users:, all parameters and fields can be consulted [here](https://developer.twitter.com/en/docs/twitter-api/fields)
```js
.getUsersByUsername(["TwitterDev"], ['profile_image_url'])
.then((data) => console.log(data));// {
// "data": [
// {
// "id": "2244994945",
// "name": "Twitter Dev",
// "username": "TwitterDev"
// }
// ]
// }
```#### Get User For UserId
For get all user information's by user id:, all parameters and fields can be consulted [here](https://developer.twitter.com/en/docs/twitter-api/fields)
```js
.getUserById('2244994945', ['profile_image_url'])
.then((data) => console.log(data));// {
// "data": {
// "id": "2244994945",
// "name": "Twitter Dev",
// "username": "TwitterDev"
// }
// }
```#### Get Many Users For UserId
For get all user information's by user id for many users:, all parameters and fields can be consulted [here](https://developer.twitter.com/en/docs/twitter-api/fields)
```js
.getUsersById(['2244994945'], ['profile_image_url'])
.then((data) => console.log(data));// {
// "data": [
// {
// "id": "2244994945",
// "name": "Twitter Dev",
// "username": "TwitterDev"
// }
// ]
// }
```#### Get Tweet By Id
For get tweet data for tweet id: all parameters and fields can be consulted [here](https://developer.twitter.com/en/docs/twitter-api/fields)
```js
.getSingleTweet('2244994945', { tweet: ['text', 'id'] })
.then((data) => console.log(data));// {
// "data": {
// "id": "1461381489115947010",
// "text": "There’s so much information in Tweets that @SPDJIndices built a stock index around them.\n\nIntroducing the S&P 500 Twitter Sentiment Index, now measuring conversations & $cashtags on the top positively talked about S&P 500 companies. #YourVoiceYourIndex 👇\n\nhttps://t.co/8aKDXpc94r https://t.co/jiIrBDQb2g"
// }
// }
```#### Get Many Tweets by Id
For get tweet data for many tweets id: all parameters and fields can be consulted [here](https://developer.twitter.com/en/docs/twitter-api/fields)
```js
.getMultipleTweets('2244994945', { tweet: ['text', 'id'] })
.then((data) => console.log(data));// {
// "data": [
// {
// "id": "1461381489115947010",
// "text": "There’s so much information in Tweets that @SPDJIndices built a stock index around them.\n\nIntroducing the S&P 500 Twitter Sentiment Index, now measuring conversations & $cashtags on the top positively talked about S&P 500 companies. #YourVoiceYourIndex 👇\n\nhttps://t.co/8aKDXpc94r https://t.co/jiIrBDQb2g"
// }
// ]
// }
```#### Get User Timeline By UserId
For get timeline of user by user id: all parameters and fields can be consulted [here](https://developer.twitter.com/en/docs/twitter-api/fields)
```js
.getTimelineByUserId('2244994945', { tweet: ['text', 'id'] })
.then((data) => console.log(data));// {
// "data": [
// {
// "id": "1461381489115947010",
// "text": "There’s so much information in Tweets that @SPDJIndices built a stock index around them.\n\nIntroducing the S&P 500 Twitter Sentiment Index, now measuring conversations & $cashtags on the top positively talked about S&P 500 companies. #YourVoiceYourIndex 👇\n\nhttps://t.co/8aKDXpc94r https://t.co/jiIrBDQb2g"
// }
// ],
// "meta": {
// "oldest_id": "1460323748788072449",
// "newest_id": "1461381489115947010",
// "result_count": 10,
// "next_token": "7140dibdnow9c7btw3z3al3eejvt8u5twuupa4vswh54p"
// }
// }
```#### Create new Tweet
🚨 For post/create new Tweet is necessary [oauth](https://developer.twitter.com/en/docs/authentication/overview) login and write access 🚨
For create new tweet: all parameters and fields can be consulted [here](https://developer.twitter.com/en/docs/twitter-api/fields)```js
.createTweet('2244994945', { tweet: ['text', 'id'] })
.then((data) => console.log(data));// {
// "data": {
// "id": "1461897194655600647",
// "text": "Hello!"
// }
// }
```#### Delete Tweet by Id
🚨 For delete Tweet is necessary [oauth](https://developer.twitter.com/en/docs/authentication/overview) login and write access 🚨
For delete tweet:```js
.deleteTweet('2244994945')
.then((data) => console.log(data));// {
// "data": {
// "deleted": true
// }
// }
```#### Get Followers By UserId
For get all followers for user by id: all parameters and fields can be consulted [here](https://developer.twitter.com/en/docs/twitter-api/fields)
```js
.getFollowersById('2244994945', { max:10 })
.then((data) => console.log(data));// {
// "data": [
// {
// "id": "2244994945",
// "name": "Twitter Dev",
// "username": "TwitterDev"
// }
// ],
// "meta": {
// "result_count": 100,
// "next_token": "76NGG1H6J79HEZZZ"
// }
// }
```#### Follow User
🚨 For follow user is necessary [oauth](https://developer.twitter.com/en/docs/authentication/overview) login and write access 🚨
Your id on the left, and id to follow in right
For follow a user:```js
.followUserId('2244994945', '2244994945')
.then((data) => console.log(data));// {
// "data": {
// "following": true,
// "pending_follow": false
// }
// }
```#### Unfollow User
🚨 For unfollow user is necessary [oauth](https://developer.twitter.com/en/docs/authentication/overview) login and write access 🚨
Your id on the left, and id to unfollow in right
For unfollow a user:```js
.unfollowUserId('2244994945', '2244994945')
.then((data) => console.log(data));// {
// "data": {
// "following": false
// }
// }
```#### Follow User By Username
🚨 For this method necessary [oauth](https://developer.twitter.com/en/docs/authentication/overview) login, bearer token and write access 🚨
Your username on the left, and username to follow in right
For unfollow a user by username:```js
.followUsername('TwitterDev', 'TwitterDev')
.then((data) => console.log(data));// {
// "data": {
// "following": true,
// "pending_follow": false
// }
// }
```#### Unfollow User By Username
🚨 For this method necessary [oauth](https://developer.twitter.com/en/docs/authentication/overview) login, bearer token and write access 🚨
Your username on the left, and username to unfollow in right
For unfollow a user by username:```js
.unfollowUsername('TwitterDev', 'TwitterDev')
.then((data) => console.log(data));// {
// "data": {
// "following": false
// }
// }
```#### V1.1 API Support
This module does not support previous versions of the Twitter API, however it
works well with the following V1.1 modules[![NPM](https://nodei.co/npm/twitter.png?compact=true)](https://nodei.co/npm/twitter/)
[![NPM](https://nodei.co/npm/twit.png?compact=true)](https://nodei.co/npm/twit/)
##### More methods will come...