Twikit

Latest version: v2.3.3

Safety actively analyzes 706267 Python packages for vulnerabilities to keep your Python projects secure.

Scan your dependencies

Page 1 of 2

2.3.1

The method for solving `ui_metrics` has been changed. Previously, it relied on node.js and jsdom, but now it uses Js2Py instead, eliminating the need for node.js.
(For more details about ui_metrics, refer to the [v2.3.0 release page](<https://github.com/d60/twikit/releases/tag/version2.3.0>).)

Additionally, the default of the `enable_ui_metrics` argument in `Client.login` has been changed to `True`.


The new version has been tested and confirmed to work on Python 3.10, 3.11, 3.12, and 3.13, but please let us know if you encounter any errors.

version2.3.0

2.3.0

Major Updates

1. Changes to Tweet.media
Previously, Tweet.media directly stored the response returned by the API. Starting from v2.3.0, it now returns a list containing instances of the newly introduced [Photo](https://twikit.readthedocs.io/en/latest/twikit.html#twikit.media.Photo), [AnimatedGif](https://twikit.readthedocs.io/en/latest/twikit.html#twikit.media.AnimatedGif), and [Video](https://twikit.readthedocs.io/en/latest/twikit.html#twikit.media.Video) classes. This makes media downloads easier, and for Video, [subtitle downloads](https://twikit.readthedocs.io/en/latest/twikit.html#twikit.media.Video.get_subtitles) are also supported.

https://twikit.readthedocs.io/en/latest/twikit.html#twikit.tweet.Tweet.media
https://github.com/d60/twikit/blob/main/examples/download_tweet_media.py


2. Added cookies_file argument to Client.login
This parameter simplifies saving and loading cookies. Previously, you had to write:
python
if os.path.exists('cookies.json'):
client.load_cookies('cookies.json')
else:
await client.login(
auth_info_1=...,
auth_info_2=...,
password=...
)
client.save_cookies('cookies.json')

Now, you can just write:
python
await client.login(
auth_info_1=...,
auth_info_2=...,
password=...,
cookies_file='cookies.json',
)

https://twikit.readthedocs.io/en/latest/twikit.html#twikit.client.client.Client.login


3. Added enable_ui_metrics argument to Client.login

When set to True, the obfuscated `ui_metrics` function is executed using JSDom, and the result is sent to the API. Enabling this **might reduce the risk of account suspension**. To use this feature, Node.js and JSDom must be installed. If Node.js is available in your environment, enabling this option is recommended.

Usage:
python
await client.login(
auth_info_1=a1,
auth_info_2=a2,
password=password,
cookies_file='cookies.json',
enable_ui_metrics=True
)

https://twikit.readthedocs.io/en/latest/twikit.html#twikit.client.client.Client.login

version2.2.2
- Implemented transaction ID in guest client requests and fixed 404 error
- Removed the dependency on requests (https://github.com/d60/twikit/pull/270)
- Fixed a bug in login with TOTP
- Added Tweet.bookmark_count and Tweet.bookmarked

version2.2.0

2.2.0

- Implemented transaction id.
- Fixed error in create_tweet.
- **Fixed login error** (`flow name LoginFlow is currently not accessible`).

`python -m pip install -U twikit -U lxml`

version2.1.3

2.1.3

- Fixed `KeyError: 'open_account'"`
- `flow name LoginFlow is currently not accessible` has not yet been fixed.

version2.1.0

2.1.0

New Features

- Added `twikit.guest` module, which allows operations such as retrieving users, tweets, and user tweets **without logging in**. You can refer to [`examples/guest.py`](<https://github.com/d60/twikit/blob/main/examples/guest.py>) for usage examples.

- Added `Client.get_user_highlights_tweets`.



**Guest client quickstart**
python
import asyncio

from twikit.guest import GuestClient

client = GuestClient()


async def main():
Activate the client by generating a guest token.
await client.activate()

Get user by screen name
user = await client.get_user_by_screen_name('elonmusk')
print(user)
Get user by ID
user = await client.get_user_by_id('44196397')
print(user)


user_tweets = await client.get_user_tweets('44196397')
print(user_tweets)

tweet = await client.get_tweet_by_id('1519480761749016577')
print(tweet)

asyncio.run(main())


version2.0.0

2.0.0

Twikit version 2.0.0 has been released. From this version, **the synchronous version has been discontinued** and **only the asynchronous version is available**. Also, `twikit.twikit_async` module has been renamed to `twikit`.

To update run `pip install -U twikit`.

Example Code for version 2:
python
import asyncio
import os

No need to write "from twikit.twikit_async import Client"
from twikit import Client

client = Client()

async def main():
if not os.path.exists('cookies.json'):
await client.login(
auth_info_1='example',
auth_info_2='emailexample.com',
password='example0000'
)
client.save_cookies('cookies.json')
else:
client.load_cookies('cookies.json')

client.create_tweet('Hello World.')

asyncio.run(main())


More usage examples: <https://github.com/d60/twikit/tree/main/examples>
Documentation: <https://twikit.readthedocs.io/en/latest/twikit.html>

Minor Changes and Bug Fixes:
- Removed `Result.cursor` and `Result.token`.
- Changed the return type of `follow_user`, `unfollow_user`, `mute_user`, `block_user`, `unblock_user` and `unmute_user` from `httpx.Response` to `User`.
- Fixed a bug where the capsolver proxy was not specified.

version1.7.6
Tweet.state → Tweet.view_count_state

version1.7.3


version1.7.1
Added totp_secret parameter to the login method for handling two-factor authentication

version1.7.0

Page 1 of 2

© 2025 Safety CLI Cybersecurity Inc. All Rights Reserved.