Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

twitter-openapi-typescript

Package Overview
Dependencies
Maintainers
0
Versions
44
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

twitter-openapi-typescript

Implementation of Twitter internal API in TypeScript

  • 0.0.37
  • Source
  • npm
  • Socket score

Version published
Maintainers
0
Created
Source

twitter-openapi-typescript

Setup

npm i twitter-openapi-typescript

Usage

import { TwitterOpenApi } from 'twitter-openapi-typescript';

const api = new TwitterOpenApi();
const client = await api.getGuestClient();
const response = await client.getUserApi().getUserByScreenName({ screenName: 'elonmusk' });
const userLegacy = response.data?.user?.legacy;
if (userLegacy) {
  console.log(userLegacy.screenName);
  console.log(`followCount: ${userLegacy.friendsCount} followersCount: ${userLegacy.followersCount}`);
} else {
  console.log('User not found');
}

Login

// ct0 and authToken will also work but it is recommended to set all cookies.
const client = await api.getClientFromCookies({
  ct0: '<csrf_token>',
  auth_token: '<auth_token>',
});

Multiple OS

The Token can only be used on the same OS that issued the Token In other words, if the sec-ch-ua-platform does not match, the Token cannot be used. This library uses the Linux Chrome header by default. To use Token issued by Windows, do the following.

TwitterOpenApi.additionalApiHeaders = {
  'sec-ch-ua-platform': '"Windows"',
};
```

### List of APIs

You should read the Test case.

<https://github.com/fa0311/twitter-openapi-typescript/tree/master/twitter-openapi-typescript/test/api>

### Customize in detail

Most values exist as static variables. There is no need to change them.

```typescript
import { TwitterOpenApi } from 'twitter-openapi-typescript';
TwitterOpenApi.additionalBrowserHeaders = {};
TwitterOpenApi.additionalApiHeaders = {};
TwitterOpenApi.fetchApi = fetch.bind(globalThis);

License

This project is dual licensed. You can choose one of the following licenses:

  • Custom License
  • GNU Affero General Public License v3.0

Keywords

FAQs

Package last updated on 30 Sep 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

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