
Security News
Knip Hits 500 Releases with v5.62.0, Improving TypeScript Config Detection and Plugin Integrations
Knip hits 500 releases with v5.62.0, refining TypeScript config detection and updating plugins as monthly npm downloads approach 12M.
twitter-openapi-typescript
Advanced tools
npm i twitter-openapi-typescript
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');
}
// 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>',
});
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.
const api = new TwitterOpenApi();
api.setAdditionalApiHeaders({
'sec-ch-ua-platform': '"Windows"',
});
You should read the Test case.
https://github.com/fa0311/twitter-openapi-typescript/tree/master/twitter-openapi-typescript/test/api
Most values exist as static variables. There is no need to change them.
Changing them could result in account suspension.
For advanced customization, use the
You can also use the TwitterOpenApiClient
class directly
import { TwitterOpenApi } from 'twitter-openapi-typescript';
TwitterOpenApi.fetchApi = fetch.bind(globalThis);
TwitterOpenApi.twitter = 'https://x.com/home';
TwitterOpenApi.bearer = 'xxxx';
This project is dual licensed. You can choose one of the following licenses:
FAQs
Implementation of Twitter internal API in TypeScript
The npm package twitter-openapi-typescript receives a total of 838 weekly downloads. As such, twitter-openapi-typescript popularity was classified as not popular.
We found that twitter-openapi-typescript demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Security News
Knip hits 500 releases with v5.62.0, refining TypeScript config detection and updating plugins as monthly npm downloads approach 12M.
Security News
The EU Cyber Resilience Act is prompting compliance requests that open source maintainers may not be obligated or equipped to handle.
Security News
Crates.io adds Trusted Publishing support, enabling secure GitHub Actions-based crate releases without long-lived API tokens.