twitter-openapi-typescript is a TypeScript library that provides an implementation of Twitter's (now X's) *internal* API, allowing programmatic interaction with the platform without relying on the official, public API. It is currently in a pre-1.0 development phase, indicated by its `0.0.55` version, suggesting frequent updates and potential breaking changes without prior notice due to the nature of interacting with internal, undocumented endpoints. The library emphasizes ease of use with guest clients for public data access and supports authenticated clients via cookie-based login (`ct0`, `auth_token`). A key differentiator is its focus on the internal API, which offers capabilities beyond the public API, though at a higher risk of instability and account suspension. The project ships with full TypeScript types, enhancing developer experience.
npm install twitter-openapi-typescriptVerified import paths — ran on the pinned version, not inferred.
Demonstrates fetching a user's details (followers, friends count) using a guest client.
Monitor library updates and GitHub issues frequently. Be prepared to adapt your code to API changes or unexpected responses.
Avoid modifying static variables unless absolutely necessary and with a full understanding of the implications. Use official API calls where possible.
Set the `sec-ch-ua-platform` header using `api.setAdditionalApiHeaders({'sec-ch-ua-platform': '"Windows"'})` (or other OS values) to match the token's origin.Pin to exact versions in `package.json` or frequently review release notes and test your integration after updates.
Consult legal counsel to ensure compliance with the chosen license, especially for commercial or proprietary projects. Understand the implications of AGPLv3 for your codebase.
Ensure `ct0` and `auth_token` are current and correctly passed to `getClientFromCookies()`. Check if the token's OS platform matches the client's `sec-ch-ua-platform` header.
Implement exponential backoff or introduce delays between requests. Consider using authenticated clients which might have higher rate limits than guest clients.
Verify the `screenName` is correct. Check GitHub issues or the library's test cases for recent changes to API responses. Add robust error handling and null checks for API data.
No dependency data recorded yet.