Metadata-Version: 2.4
Name: xselfbot
Version: 4.0.0
Summary: X client for python — posting, reading, search and streaming, no API key.
Home-page: https://github.com/Tky567/xselfbot
License: MIT
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: httpx[socks]
Requires-Dist: filetype
Requires-Dist: beautifulsoup4
Requires-Dist: pyotp
Requires-Dist: lxml
Requires-Dist: webvtt-py
Requires-Dist: m3u8
Requires-Dist: Js2Py-3.13
Dynamic: description
Dynamic: description-content-type
Dynamic: home-page
Dynamic: license
Dynamic: license-file
Dynamic: requires-dist
Dynamic: requires-python
Dynamic: summary

# 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:

```python
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](ToProtectYourAccount.md) and
[ratelimits.md](ratelimits.md).

## Post

```python
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:

```python
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:

```python
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

```python
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

```python
await client.send_dm('123456789', 'Hello')

from xselfbot.streaming import Topic
```

## Layout

| path | what |
|---|---|
| `xselfbot/client/(client|gql|v11).py` | session, GraphQL and v1.1 transport |
| `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](https://github.com/d60/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](LICENSE).
