XSelfBot
X client for Python. Posts, reads, searches and streams over a cookie session, with no API key.
pip install git+https://github.com/Tky567/xselfbot.git@main
pip install xselfbot
Requires Python 3.10+.
Session
The cookie session is the supported path. Export the cookies of a signed-in browser session (any Netscape-format jar works) and hand them to the client:
import asyncio
from xselfbot import Client
client = Client('en-US')
client.load_cookies('cookies.json')
async def main():
print(await client.identity())
# {'user_id': '…', 'screen_name': '…', 'name': '…', 'avatar': '…'}
asyncio.run(main())
login() by password is still in the tree, but it is the path that gets accounts
flagged. See ToProtectYourAccount.md and
ratelimits.md.
Post
media_ids = [await client.upload_media('media1.jpg')]
await client.create_tweet('Example', media_ids=media_ids)
Content disclosure, the way the web composer sends it:
await client.create_tweet('Rendered overnight', made_with_ai=True)
await client.create_tweet('Partner drop', paid_partnership=True)
await client.add_content_disclosure(tweet_id, made_with_ai=True)
await client.delete_content_disclosure(tweet_id)
Read it back — the label is only serialised when the read query asks for it, which the default feature sets do:
from xselfbot import applied_disclosures
tweet = await client.get_tweet_by_id(tweet_id)
applied_disclosures(tweet) # {'paid_partnership': False, 'made_with_ai': True}
Read
tweets = await client.search_tweet('python', 'Latest')
for tweet in tweets:
print(tweet.user.name, tweet.text, tweet.created_at)
tweets = await client.get_user_tweets('123456', 'Tweets')
trends = await client.get_trends('trending')
Message and stream
await client.send_dm('123456789', 'Hello')
from xselfbot.streaming import Topic
Layout
| path | what |
|---|---|
| `xselfbot/client/(client | gql |
xselfbot/tweet.py, user.py, message.py |
entities |
xselfbot/content_disclosure.py |
the Paid partnership / Made with AI labels |
xselfbot/x_client_transaction/ |
X-Client-Transaction-Id builder, with a fallback |
xselfbot/guest/ |
logged-out client |
docs/ |
Sphinx sources |
tests/ |
offline checks, no network |
Tests
python -m pytest tests -q
Credit
This library began as a fork of the Twikit project, and the shape of the client — the entity model, the GraphQL endpoint table, the captcha hook — is that project's work. Credit for the original design belongs to its author; what is here is the same library carried through the 2026 x.com build and renamed so the two can be told apart.
Licence
MIT. See LICENSE.
Metadata
Release files for xselfbot 4.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| xselfbot-4.0.0.tar.gz | 79.1 kB | Without provenance | Details for xselfbot-4.0.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| xselfbot-4.0.0-py3-none-any.whl | Python 3 | none | any | Details for xselfbot-4.0.0-py3-none-any.whl |
Total release size: 167.6 kB
Release files / xselfbot-4.0.0.tar.gz
| Download URL | xselfbot-4.0.0.tar.gz |
|---|---|
| Size | 79.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
9cfb930ded6e092582d79a4247a000cd43ad27e9d3dc972463cb8c8065bb42f0
|
|
BLAKE2b-256 checksum How to use checksums |
38d8408fb1bffe20b17c72a336808d3bb69f88cceba232ca0e335bb3a0cd590c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.10
|
Release files / xselfbot-4.0.0-py3-none-any.whl
| Download URL | xselfbot-4.0.0-py3-none-any.whl |
|---|---|
| Size | 88.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
bba933f2671a13e47484c765e28ae6ec747cb84b0fe5b76aab6016b85b6f512e
|
|
BLAKE2b-256 checksum How to use checksums |
5c03ede538575cab2ece0f92a222380178fdb35e1c9a52d3774acac5f68bbb11
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.10
|
Security for xselfbot 4.0.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.