0.4.0 • Published 2 years ago

twimo-v2 v0.4.0

Weekly downloads
6
License
MIT
Repository
github
Last release
2 years ago

twimo-v2

Twitter API v2 client for TypeScript auto-generated from official OpenAPI specification

https://api.twitter.com/2/openapi.json

Install

yarn add twimo-v2
# or
npm i -S twimo-v2

Usage

Configure (Bearer Token)

import { configureTwitterApi, TweetsApi, SearchApi, UsersApi } from 'twimo-v2'

const bearerToken = 'xxxxxxxx'
const tweetsApi = configureTwitterApi(TweetsApi, bearerToken)

Configure (User Context)

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

tweetsApi.findTweetsById({
  ids: ['1326191408546414592'],
  expansions: ['author_id', 'attachments.media_keys'],
  tweetFields: ['created_at', 'referenced_tweets', 'attachments'],
  mediaFields: ['url', 'width', 'height'],
})

Response Example

{
  "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"
      }
    ]
  }
}
0.4.0

2 years ago

0.3.2

3 years ago

0.3.3

3 years ago

0.3.0

3 years ago

0.3.1

3 years ago

0.2.3

3 years ago

0.2.4

3 years ago

0.2.1

3 years ago

0.2.2

3 years ago

0.2.0

3 years ago

0.1.1

3 years ago

0.1.0

3 years ago

0.0.2

3 years ago

0.0.1

3 years ago