Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/yarnaimo/twimo-v2
π Twitter API v2 client for TypeScript auto-generated from official OpenAPI specification
https://github.com/yarnaimo/twimo-v2
nodejs twitter twitter-api-v2 typescript
Last synced: 3 months ago
JSON representation
π Twitter API v2 client for TypeScript auto-generated from official OpenAPI specification
- Host: GitHub
- URL: https://github.com/yarnaimo/twimo-v2
- Owner: yarnaimo
- License: mit
- Created: 2020-12-10T12:52:43.000Z (about 4 years ago)
- Default Branch: master
- Last Pushed: 2021-12-04T11:49:40.000Z (about 3 years ago)
- Last Synced: 2023-08-24T07:51:20.183Z (over 1 year ago)
- Topics: nodejs, twitter, twitter-api-v2, typescript
- Language: TypeScript
- Homepage:
- Size: 758 KB
- Stars: 5
- Watchers: 2
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# twimo-v2
Twitter API v2 client for TypeScript auto-generated from official OpenAPI specification
https://api.twitter.com/2/openapi.json
## Install
```sh
yarn add twimo-v2
# or
npm i -S twimo-v2
```## Usage
### Configure (Bearer Token)
```ts
import { configureTwitterApi, TweetsApi, SearchApi, UsersApi } from 'twimo-v2'const bearerToken = 'xxxxxxxx'
const tweetsApi = configureTwitterApi(TweetsApi, bearerToken)
```### Configure (User Context)
```ts
import {
configureUserContextTwitterApi,
TweetsApi,
SearchApi,
UsersApi,
} from 'twimo-v2'const consumer = { key: 'xxxxxxxx', secret: 'xxxxxxxx' }
const token = { key: 'xxxxxxxx', secret: 'xxxxxxxx' }const tweetsApi = configureUserContextTwitterApi(TweetsApi, consumer, token)
```### API
```ts
tweetsApi.findTweetsById({
ids: ['1326191408546414592'],
expansions: ['author_id', 'attachments.media_keys'],
tweetFields: ['created_at', 'referenced_tweets', 'attachments'],
mediaFields: ['url', 'width', 'height'],
})
```**Response Example**
```json
{
"data": [
{
"attachments": {
"media_keys": ["3_1326191367203160064"]
},
"created_at": "2020-11-10T15:54:05.000Z",
"author_id": "1013969666186678272",
"id": "1326191408546414592",
"text": "https://t.co/uMLs9riKeg"
}
],
"includes": {
"media": [
{
"type": "photo",
"media_key": "3_1326191367203160064",
"height": 128,
"width": 477,
"url": "https://pbs.twimg.com/media/EmeUBaJVgAA9mFu.png"
}
],
"users": [
{
"id": "1013969666186678272",
"name": "γγΎγγ",
"username": "yarnaimo"
}
]
}
}
```