Releases: d60/twikit
Version 2.3.1
Version 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.)
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.
version 2.3.0
Version 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, AnimatedGif, and Video classes. This makes media downloads easier, and for Video, subtitle downloads 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:
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:
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:
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
Version 2.2.2
- Implemented transaction ID in guest client requests and fixed 404 error
- Removed the dependency on requests (#270)
- Fixed a bug in login with TOTP
- Added Tweet.bookmark_count and Tweet.bookmarked
Version 2.2.0
Version 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
Version 2.1.3
Version 2.1.3
- Fixed
KeyError: 'open_account'"
flow name LoginFlow is currently not accessible
has not yet been fixed.
Version 2.1.0
Version 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 toexamples/guest.py
for usage examples. -
Added
Client.get_user_highlights_tweets
.
Guest client quickstart
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())
Version 2.0.0
Version 2.0.0 has been released
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:
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='[email protected]',
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
andResult.token
. - Changed the return type of
follow_user
,unfollow_user
,mute_user
,block_user
,unblock_user
andunmute_user
fromhttpx.Response
toUser
. - Fixed a bug where the capsolver proxy was not specified.
Version 1.7.6
Tweet.state → Tweet.view_count_state
Version 1.7.3
version1.7.3 fixed async/logout | added _get_user_state
Version 1.7.1
Added totp_secret parameter to the login method for handling two-factor authentication