LinkGrid X-Transaction-ID
🔗 A Python package for generating X-Client-Transaction-Id headers used in API requests
✨ Overview
deepsaha-x-transaction-id is a powerful Python package that simplifies the generation of X-Client-Transaction-Id headers required for making authenticated requests to X's (formerly Twitter) API endpoints. It handles all the complexity of generating valid transaction IDs so you can focus on building your application.
🚀 Features
- 🔥 Easy to Use: Simple and intuitive API for generating transaction IDs
- ⚡ High Performance: Optimized for speed and efficiency
- 🔄 Async Support: Built-in support for both synchronous and asynchronous operations
- 📦 Lightweight: Minimal dependencies, maximum functionality
- 🛡 Reliable: Battle-tested and production-ready
📦 Installation
Install the package using pip:
pip install linkgrid-x-transaction-id
🚀 Quick Start
from linkgrid_x_transaction_id import ClientTransaction
# Create a client instance
client = ClientTransaction()
# Get a transaction ID
transaction_id = client.get_transaction_id()
print(f"Generated Transaction ID: {transaction_id}")
import aiohttp import asyncio from deepsaha_x_transaction_id import ClientTransaction from deepsaha_x_transaction_id.utils import generate_headers, handle_x_migration, get_ondemand_file_url
async def main(): async with aiohttp.ClientSession(headers=generate_headers()) as session: # Get home page response home_page_response = await handle_x_migration(session, is_async=True)
# Get ondemand file URL and response
ondemand_file_url = get_ondemand_file_url(home_page_response)
async with session.get(ondemand_file_url) as response:
ondemand_file_response = await response.text()
# Initialize client and generate transaction ID
ct = ClientTransaction(home_page_response, ondemand_file_response)
transaction_id = ct.generate_transaction_id(
method="POST",
path="/i/api/1.1/jot/client_event.json"
)
print(f"Generated Transaction ID: {transaction_id}")
Run the async function
if name == "main": asyncio.run(main())
## 📚 API Reference
### `ClientTransaction` Class
The main class for generating X-Client-Transaction-Id headers.
```python
ClientTransaction(
home_page_response: bs4.BeautifulSoup,
ondemand_file_response: bs4.BeautifulSoup,
random_keyword: str = "qbg",
random_number: int = 1
)
Parameters
home_page_response(bs4.BeautifulSoup): Parsed HTML response from X/Twitter home pageondemand_file_response(bs4.BeautifulSoup): Parsed HTML response from the ondemand scriptrandom_keyword(str, optional): Custom keyword for transaction ID generation. Defaults to "qbg"random_number(int, optional): Custom number for transaction ID generation. Defaults to 1
Methods
generate_transaction_id(method: str, path: str) -> str
Generate a transaction ID for the given HTTP method and path.
Parameters:
method(str): HTTP method (e.g., "GET", "POST")path(str): API endpoint path (e.g., "/i/api/1.1/jot/client_event.json")
Returns:
str: Generated transaction ID string
Utility Functions
generate_headers() -> Dict[str, str]
Generate default headers for X/Twitter API requests.
handle_x_migration(session: requests.Session, is_async: bool = False) -> Union[bs4.BeautifulSoup, Coroutine]
Handle the X/Twitter migration and return the parsed home page response.
get_ondemand_file_url(response: bs4.BeautifulSoup) -> str
Extract the ondemand script URL from the home page response.
🤝 Contributing
Contributions are welcome! Feel free to submit issues and pull requests.
📄 License
This project is licensed under the MIT License - see the LICENSE file for details.
👤 Author
Deep Saha
- Website: deepsaha.com
- Twitter: @DeepSahaDev
- GitHub: @OfficialDeepSaha
Feedback
If you have any feedback, please reach out to us at hiremeasadeveloper@gmail.com or contact me on Social Media @LegendDeep2003
Support
For support, email hiremeasadeveloper@gmail.com
Metadata
Release files for linkgrid-x-transaction-id 1.0.1
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 | |
|---|---|---|---|---|
| linkgrid_x_transaction_id-1.0.1.tar.gz | 12.0 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| linkgrid_x_transaction_id-1.0.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 23.4 kB
Release files / linkgrid_x_transaction_id-1.0.1.tar.gz
| Download URL | linkgrid_x_transaction_id-1.0.1.tar.gz |
|---|---|
| Size | 12.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
702ca6eb67f430097ad038f9e6819a0283cc92509a2d8c185f6a9aa924096b2a
|
|
BLAKE2b-256 checksum How to use checksums |
93aac7f67ccd02a3b655755713a03b1a128b1c111ad1cb4deb94b51e12b1aa3f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.1
|
Release files / linkgrid_x_transaction_id-1.0.1-py3-none-any.whl
| Download URL | linkgrid_x_transaction_id-1.0.1-py3-none-any.whl |
|---|---|
| Size | 11.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
174fdb55d2c1896ca84f4ebb40fe99476ec3979279d83821862bf1bb80e94904
|
|
BLAKE2b-256 checksum How to use checksums |
658c4cfeafe0813ff890278055635cbd481bc60226e7cadba1de8af52550d5a8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.1
|
Security for linkgrid-x-transaction-id 1.0.1
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.