xclienttransaction


Namexclienttransaction JSON
Version 1.0.1 PyPI version JSON
download
home_pagehttps://github.com/iSarabjitDhiman/XClientTransaction
SummaryTwitter X-Client-Transaction-Id generator written in python.
upload_time2025-10-09 10:38:31
maintainerNone
docs_urlNone
authorSarabjit Dhiman
requires_python>=3
licenseMIT
keywords xclienttransaction twitter transaction id client transaction id twitter tid generator x client transaction id generator xid twitter tweeterpy
VCS
bugtrack_url
requirements beautifulsoup4
Travis-CI No Travis.
coveralls test coverage No coveralls.
            <h1 align="center">X-Client-Transaction-ID</h1>

<p align="center">
Twitter X-Client-Transaction-Id generator written in python.

<p align="center">
<a href="https://choosealicense.com/licenses/mit/"> <img src="https://img.shields.io/badge/License-MIT-green.svg"></a>
<a href="https://www.python.org/"><img src="https://img.shields.io/pypi/pyversions/XClientTransaction"></a>
<a href="https://pypi.org/project/XClientTransaction"> <img src="https://img.shields.io/pypi/v/XClientTransaction"></a>
<a href="https://github.com/iSarabjitDhiman/XClientTransaction/commits"> <img src="https://img.shields.io/github/last-commit/iSarabjitDhiman/XClientTransaction"></a>
<a href="https://pypi.org/project/XClientTransaction/"> <img src="https://img.shields.io/pypi/dd/XClientTransaction"></a>
<a href="https://discord.gg/pHY6CU5Ke4"> <img alt="Discord" src="https://img.shields.io/discord/1149281691479851018?style=flat&logo=discord&logoColor=white"></a>
<a href="https://twitter.com/isarabjitdhiman"> <img src="https://img.shields.io/twitter/follow/iSarabjitDhiman?style=social"></a>

Reference :

- [Twitter Header: Part 1, Deobfuscation](https://antibot.blog/posts/1741552025433)
- [Twitter Header: Part 2, Reverse Engineering](https://antibot.blog/posts/1741552092462)
- [Twitter Header: Part 3, Generating the header](https://antibot.blog/posts/1741552163416)

## Installation

Install XClientTransaction with pip

```python
pip install XClientTransaction -U --no-cache-dir
```

## Usage/Examples

```python
python quickstart.py
```

## Get x.com Home Page and ondemand.s File Response

#### Synchronous Version

```python
import bs4
import requests
from x_client_transaction.utils import generate_headers, handle_x_migration, get_ondemand_file_url

# INITIALIZE SESSION
session = requests.Session()
session.headers = generate_headers()


# GET HOME PAGE RESPONSE
# required only when hitting twitter.com but not x.com
# returns bs4.BeautifulSoup object
home_page_response = handle_x_migration(session=session)

# for x.com no migration is required, just simply do
home_page = session.get(url="https://x.com")
home_page_response = bs4.BeautifulSoup(home_page.content, 'html.parser')


# GET ondemand.s FILE RESPONSE
ondemand_file_url = get_ondemand_file_url(response=home_page_response)
ondemand_file = session.get(url=ondemand_file_url)

ondemand_file_response = bs4.BeautifulSoup(ondemand_file.content, 'html.parser')
# Getting "Couldn't get KEY_BYTE indices" error? Try passing the original response or the response text
# both should work
# ondemand_file_response = ondemand_file
ondemand_file_response = ondemand_file.text
```

#### Async Version

```python
import bs4
import httpx
from x_client_transaction.utils import generate_headers, handle_x_migration_async, get_ondemand_file_url

# INITIALIZE SESSION
session = httpx.AsyncClient(headers=generate_headers())


# GET HOME PAGE RESPONSE
# required only when hitting twitter.com but not x.com
# returns bs4.BeautifulSoup object
home_page_response = await handle_x_migration_async(session=session)

# for x.com no migration is required, just simply do
home_page = await session.get(url="https://x.com")
home_page_response = bs4.BeautifulSoup(home_page.content, 'html.parser')


# GET ondemand.s FILE RESPONSE
ondemand_file_url = get_ondemand_file_url(response=home_page_response)
ondemand_file = await session.get(url=ondemand_file_url)

ondemand_file_response = bs4.BeautifulSoup(ondemand_file.content, 'html.parser')
# Getting "Couldn't get KEY_BYTE indices" error? Try passing the original response or the response text
# both should work
# ondemand_file_response = ondemand_file
ondemand_file_response = ondemand_file.text
```

## Generate X-Client-Transaction-Id (tid):

```python
from urllib.parse import urlparse
from x_client_transaction import ClientTransaction


# Example 1
# replace the url and http method as per your use case
url = "https://x.com/i/api/1.1/jot/client_event.json"
method = "POST"
path = urlparse(url=url).path
# path will be /i/api/1.1/jot/client_event.json in this case

# Example 2
user_by_screen_name_url = "https://x.com/i/api/graphql/1VOOyvKkiI3FMmkeDNxM9A/UserByScreenName"
user_by_screen_name_http_method = "GET"
user_by_screen_name_path = urlparse(url=url).path
# path will be /i/api/graphql/1VOOyvKkiI3FMmkeDNxM9A/UserByScreenName in this case


ct = ClientTransaction(home_page_response=home_page_response, ondemand_file_response=ondemand_file_response)
transaction_id = ct.generate_transaction_id(method=method, path=path)
transaction_id_for_user_by_screen_name_endpoint = ct.generate_transaction_id(
    method=user_by_screen_name_http_method, path=user_by_screen_name_path)

print(transaction_id)
print(transaction_id_for_user_by_screen_name_endpoint)

```

## Authors

- [@iSarabjitDhiman](https://www.github.com/iSarabjitDhiman)

## Feedback

If you have any feedback, please reach out to us at hello@sarabjitdhiman.com or contact me on Social Media @iSarabjitDhiman

## Support

For support, email hello@sarabjitdhiman.com

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/iSarabjitDhiman/XClientTransaction",
    "name": "xclienttransaction",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3",
    "maintainer_email": null,
    "keywords": "XClientTransaction, twitter transaction id, client transaction id twitter, tid generator, x client transaction id generator, xid twitter, tweeterpy",
    "author": "Sarabjit Dhiman",
    "author_email": "hello@sarabjitdhiman.com",
    "download_url": "https://files.pythonhosted.org/packages/eb/c7/c841afe6759567cf29e36196dff65c935682b69ae38e986bd14e7decf74e/xclienttransaction-1.0.1.tar.gz",
    "platform": null,
    "description": "<h1 align=\"center\">X-Client-Transaction-ID</h1>\r\n\r\n<p align=\"center\">\r\nTwitter X-Client-Transaction-Id generator written in python.\r\n\r\n<p align=\"center\">\r\n<a href=\"https://choosealicense.com/licenses/mit/\"> <img src=\"https://img.shields.io/badge/License-MIT-green.svg\"></a>\r\n<a href=\"https://www.python.org/\"><img src=\"https://img.shields.io/pypi/pyversions/XClientTransaction\"></a>\r\n<a href=\"https://pypi.org/project/XClientTransaction\"> <img src=\"https://img.shields.io/pypi/v/XClientTransaction\"></a>\r\n<a href=\"https://github.com/iSarabjitDhiman/XClientTransaction/commits\"> <img src=\"https://img.shields.io/github/last-commit/iSarabjitDhiman/XClientTransaction\"></a>\r\n<a href=\"https://pypi.org/project/XClientTransaction/\"> <img src=\"https://img.shields.io/pypi/dd/XClientTransaction\"></a>\r\n<a href=\"https://discord.gg/pHY6CU5Ke4\"> <img alt=\"Discord\" src=\"https://img.shields.io/discord/1149281691479851018?style=flat&logo=discord&logoColor=white\"></a>\r\n<a href=\"https://twitter.com/isarabjitdhiman\"> <img src=\"https://img.shields.io/twitter/follow/iSarabjitDhiman?style=social\"></a>\r\n\r\nReference :\r\n\r\n- [Twitter Header: Part 1, Deobfuscation](https://antibot.blog/posts/1741552025433)\r\n- [Twitter Header: Part 2, Reverse Engineering](https://antibot.blog/posts/1741552092462)\r\n- [Twitter Header: Part 3, Generating the header](https://antibot.blog/posts/1741552163416)\r\n\r\n## Installation\r\n\r\nInstall XClientTransaction with pip\r\n\r\n```python\r\npip install XClientTransaction -U --no-cache-dir\r\n```\r\n\r\n## Usage/Examples\r\n\r\n```python\r\npython quickstart.py\r\n```\r\n\r\n## Get x.com Home Page and ondemand.s File Response\r\n\r\n#### Synchronous Version\r\n\r\n```python\r\nimport bs4\r\nimport requests\r\nfrom x_client_transaction.utils import generate_headers, handle_x_migration, get_ondemand_file_url\r\n\r\n# INITIALIZE SESSION\r\nsession = requests.Session()\r\nsession.headers = generate_headers()\r\n\r\n\r\n# GET HOME PAGE RESPONSE\r\n# required only when hitting twitter.com but not x.com\r\n# returns bs4.BeautifulSoup object\r\nhome_page_response = handle_x_migration(session=session)\r\n\r\n# for x.com no migration is required, just simply do\r\nhome_page = session.get(url=\"https://x.com\")\r\nhome_page_response = bs4.BeautifulSoup(home_page.content, 'html.parser')\r\n\r\n\r\n# GET ondemand.s FILE RESPONSE\r\nondemand_file_url = get_ondemand_file_url(response=home_page_response)\r\nondemand_file = session.get(url=ondemand_file_url)\r\n\r\nondemand_file_response = bs4.BeautifulSoup(ondemand_file.content, 'html.parser')\r\n# Getting \"Couldn't get KEY_BYTE indices\" error? Try passing the original response or the response text\r\n# both should work\r\n# ondemand_file_response = ondemand_file\r\nondemand_file_response = ondemand_file.text\r\n```\r\n\r\n#### Async Version\r\n\r\n```python\r\nimport bs4\r\nimport httpx\r\nfrom x_client_transaction.utils import generate_headers, handle_x_migration_async, get_ondemand_file_url\r\n\r\n# INITIALIZE SESSION\r\nsession = httpx.AsyncClient(headers=generate_headers())\r\n\r\n\r\n# GET HOME PAGE RESPONSE\r\n# required only when hitting twitter.com but not x.com\r\n# returns bs4.BeautifulSoup object\r\nhome_page_response = await handle_x_migration_async(session=session)\r\n\r\n# for x.com no migration is required, just simply do\r\nhome_page = await session.get(url=\"https://x.com\")\r\nhome_page_response = bs4.BeautifulSoup(home_page.content, 'html.parser')\r\n\r\n\r\n# GET ondemand.s FILE RESPONSE\r\nondemand_file_url = get_ondemand_file_url(response=home_page_response)\r\nondemand_file = await session.get(url=ondemand_file_url)\r\n\r\nondemand_file_response = bs4.BeautifulSoup(ondemand_file.content, 'html.parser')\r\n# Getting \"Couldn't get KEY_BYTE indices\" error? Try passing the original response or the response text\r\n# both should work\r\n# ondemand_file_response = ondemand_file\r\nondemand_file_response = ondemand_file.text\r\n```\r\n\r\n## Generate X-Client-Transaction-Id (tid):\r\n\r\n```python\r\nfrom urllib.parse import urlparse\r\nfrom x_client_transaction import ClientTransaction\r\n\r\n\r\n# Example 1\r\n# replace the url and http method as per your use case\r\nurl = \"https://x.com/i/api/1.1/jot/client_event.json\"\r\nmethod = \"POST\"\r\npath = urlparse(url=url).path\r\n# path will be /i/api/1.1/jot/client_event.json in this case\r\n\r\n# Example 2\r\nuser_by_screen_name_url = \"https://x.com/i/api/graphql/1VOOyvKkiI3FMmkeDNxM9A/UserByScreenName\"\r\nuser_by_screen_name_http_method = \"GET\"\r\nuser_by_screen_name_path = urlparse(url=url).path\r\n# path will be /i/api/graphql/1VOOyvKkiI3FMmkeDNxM9A/UserByScreenName in this case\r\n\r\n\r\nct = ClientTransaction(home_page_response=home_page_response, ondemand_file_response=ondemand_file_response)\r\ntransaction_id = ct.generate_transaction_id(method=method, path=path)\r\ntransaction_id_for_user_by_screen_name_endpoint = ct.generate_transaction_id(\r\n    method=user_by_screen_name_http_method, path=user_by_screen_name_path)\r\n\r\nprint(transaction_id)\r\nprint(transaction_id_for_user_by_screen_name_endpoint)\r\n\r\n```\r\n\r\n## Authors\r\n\r\n- [@iSarabjitDhiman](https://www.github.com/iSarabjitDhiman)\r\n\r\n## Feedback\r\n\r\nIf you have any feedback, please reach out to us at hello@sarabjitdhiman.com or contact me on Social Media @iSarabjitDhiman\r\n\r\n## Support\r\n\r\nFor support, email hello@sarabjitdhiman.com\r\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Twitter X-Client-Transaction-Id generator written in python.",
    "version": "1.0.1",
    "project_urls": {
        "Homepage": "https://github.com/iSarabjitDhiman/XClientTransaction"
    },
    "split_keywords": [
        "xclienttransaction",
        " twitter transaction id",
        " client transaction id twitter",
        " tid generator",
        " x client transaction id generator",
        " xid twitter",
        " tweeterpy"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "feb8b953828e2f0f658f7f2d6354525728c9569c83937ebe4903f2391f02a702",
                "md5": "5381388d685b73b8f2a63e6206017a9f",
                "sha256": "0280e021129a38f8ee2ebede6406d4c065a599430bd4c8aa0c122f2e42f9f0f0"
            },
            "downloads": -1,
            "filename": "xclienttransaction-1.0.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "5381388d685b73b8f2a63e6206017a9f",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3",
            "size": 10724,
            "upload_time": "2025-10-09T10:38:30",
            "upload_time_iso_8601": "2025-10-09T10:38:30.098040Z",
            "url": "https://files.pythonhosted.org/packages/fe/b8/b953828e2f0f658f7f2d6354525728c9569c83937ebe4903f2391f02a702/xclienttransaction-1.0.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "ebc7c841afe6759567cf29e36196dff65c935682b69ae38e986bd14e7decf74e",
                "md5": "62ed1b77a6ca03dede4bdc7a20d0117a",
                "sha256": "e4e032ff27e76ab927c0a7f57ad3630e06b7100c113bdf22b03cdde9584756f3"
            },
            "downloads": -1,
            "filename": "xclienttransaction-1.0.1.tar.gz",
            "has_sig": false,
            "md5_digest": "62ed1b77a6ca03dede4bdc7a20d0117a",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3",
            "size": 9062,
            "upload_time": "2025-10-09T10:38:31",
            "upload_time_iso_8601": "2025-10-09T10:38:31.485695Z",
            "url": "https://files.pythonhosted.org/packages/eb/c7/c841afe6759567cf29e36196dff65c935682b69ae38e986bd14e7decf74e/xclienttransaction-1.0.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-10-09 10:38:31",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "iSarabjitDhiman",
    "github_project": "XClientTransaction",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "requirements": [
        {
            "name": "beautifulsoup4",
            "specs": []
        }
    ],
    "lcname": "xclienttransaction"
}
        
Elapsed time: 2.05521s