# TA-X-AGENT: X (Twitter) Agent Package
A Python package for interacting with X (Twitter) platform using AI agents. This package provides a simple and intuitive interface to perform various Twitter operations like posting, liking, retweeting, and retrieving data.
## Features
- 🤖 AI-powered X (Twitter) interactions
- 📝 Create and post content
- ❤️ Like and unlike posts
- 🔄 Retweet posts
- 📊 Get trending topics
- 👤 Get user details and tweet information
- 🔧 Easy configuration and setup
- 🚀 Ready for PyPI distribution
## Quick Start
### Installation
```bash
pip install ta-x-agent
```
### Basic Usage
```python
import asyncio
from ta_x import setup, XAgent
async def main():
# Setup authentication
setup(
x_auth_token="your_x_auth_token_here",
x_ct0="your_x_ct0_token_here",
openai_api_key="your_openai_api_key_here",
rapid_api_key="your_rapid_api_key_here"
)
# Create agent instance
agent = XAgent()
# Use the agent
result = await agent.run("Post this: Hello X world!")
print(result)
asyncio.run(main())
```
## Import Syntax
The package supports the exact import syntax you wanted:
```python
from ta_x import XAgent
agent = XAgent()
agent.run(user_prompt=" ")
```
## Available Operations
### 1. Create Posts
```python
await agent.run("Post this: Hello X world!")
await agent.run("Create a post about AI and social media")
```
### 2. Like Posts
```python
await agent.run("Like the latest post")
await agent.run("Like the latest post of elonmusk")
await agent.run("Like the second latest post of elonmusk")
```
### 3. Unlike Posts
```python
await agent.run("Unlike the latest post")
await agent.run("Unlike the latest post of elonmusk")
```
### 4. Retweet Posts
```python
await agent.run("Retweet the latest post")
await agent.run("Retweet the latest post of elonmusk")
```
### 5. Get Trends
```python
await agent.run("What's trending on X?")
await agent.run("Show trends")
```
### 6. Get User Details
```python
await agent.run("Get user details for elonmusk")
await agent.run("Show user info for elonmusk")
```
### 7. Get Tweet Details
```python
await agent.run("Get tweet details for 123456789")
```
## Authentication Setup
### Method 1: Using setup() function
```python
from ta_x import setup
setup(
x_auth_token="your_x_auth_token",
x_ct0="your_x_ct0_token",
openai_api_key="your_openai_api_key",
rapid_api_key="your_rapid_api_key"
)
```
### Method 2: Environment Variables
```bash
export X_AUTH_TOKEN="your_x_auth_token"
export X_CT0="your_x_ct0_token"
export OPENAI_API_KEY="your_openai_api_key"
export RAPID_API_KEY="your_rapid_api_key"
```
### Method 3: .env file
Create a `.env` file in your project root:
```
X_AUTH_TOKEN=your_x_auth_token
X_CT0=your_x_ct0_token
OPENAI_API_KEY=your_openai_api_key
RAPID_API_KEY=your_rapid_api_key
```
## CLI Usage
The package also provides a command-line interface:
```bash
# Setup authentication
ta-x-agent setup --x-auth-token "your_token" --x-ct0 "your_ct0" --openai-key "your_key" --rapid-api-key "your_rapid_key"
# Create a post
ta-x-agent post "Hello X world!"
# Like the latest post
ta-x-agent like
# Get trending topics
ta-x-agent trends
# Get user details
ta-x-agent user-details elonmusk
```
## Advanced Usage
### Using XAgent Class Directly
```python
from ta_x import XAgent
custom_agent = XAgent(
auth_token="your_x_auth_token",
ct0="your_x_ct0_token"
)
result = await custom_agent.run("Post this: Hello world!")
```
### Using execute_x_task Function
```python
from ta_x import execute_x_task
result = await execute_x_task("Post this: Hello world!")
```
## Error Handling
```python
try:
result = await agent.run("Post this: Test post")
print(f"Success: {result}")
except Exception as e:
print(f"Error: {e}")
print("Make sure authentication tokens are set correctly!")
```
## Configuration Management
### Get Current Configuration
```python
from ta_x import get_config
config = get_config()
print(f"X Auth Token: {config.x_auth_token}")
print(f"X CT0: {config.x_ct0}")
print(f"OpenAI API Key: {config.openai_api_key}")
print(f"RapidAPI Key: {config.rapid_api_key}")
```
### Reset Configuration
```python
from ta_x import reset_config
# Reset to default values
reset_config()
```
## Available Operations
The agent supports the following operations:
1. **Create Posts**: `"Post this: [content]"` or `"Create a post with [content]"`
2. **Like Posts**: `"Like the latest post"` or `"Like the post of [username]"`
3. **Unlike Posts**: `"Unlike the post"` or `"Dislike the post of [username]"`
4. **Retweet Posts**: `"Retweet the post"` or `"Retweet the post of [username]"`
5. **Get Trends**: `"What's trending?"` or `"Show trends"`
6. **Get Tweet Details**: `"Get tweet details for [tweet_id]"`
7. **Get User Details**: `"Get user details for [username]"`
## Error Handling
The package includes comprehensive error handling:
- **Missing Configuration**: Clear error messages when required tokens are not set
- **Invalid Credentials**: Proper handling of authentication failures
- **Network Errors**: Graceful handling of connection issues
- **Rate Limiting**: Built-in support for X API rate limits
## Development
### Installing Development Dependencies
```bash
pip install -e ".[dev]"
```
### Running Tests
```bash
pytest
```
### Code Formatting
```bash
black ta_x/
```
### Type Checking
```bash
mypy ta_x/
```
## Contributing
1. Fork the repository
2. Create a feature branch
3. Make your changes
4. Add tests for new functionality
5. Run the test suite
6. Submit a pull request
## License
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
## Support
- 📧 Email: your.email@example.com
- 🐛 Issues: [GitHub Issues](https://github.com/Soumyajit22theagentic/ta-x/issues)
- 📖 Documentation: [GitHub README](https://github.com/Soumyajit22theagentic/ta-x#readme)
## Disclaimer
This package is for educational and development purposes. Please ensure you comply with X (Twitter)'s Terms of Service and API usage guidelines when using this package.
Raw data
{
"_id": null,
"home_page": "https://github.com/Soumyajit22theagentic/ta_x",
"name": "ta-x-agent",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.8",
"maintainer_email": "Soumyajit <soumyajit@theagentic.ai>",
"keywords": "twitter, x, social media, ai, agent, automation",
"author": "Soumyajit",
"author_email": "Soumyajit <soumyajit@theagentic.ai>",
"download_url": "https://files.pythonhosted.org/packages/1e/92/2148a79e063eda485dde12f70780902cdf4bdbc04ceaf0326e6dd8685d25/ta_x_agent-0.1.2.tar.gz",
"platform": null,
"description": "# TA-X-AGENT: X (Twitter) Agent Package\n\nA Python package for interacting with X (Twitter) platform using AI agents. This package provides a simple and intuitive interface to perform various Twitter operations like posting, liking, retweeting, and retrieving data.\n\n## Features\n\n- \ud83e\udd16 AI-powered X (Twitter) interactions\n- \ud83d\udcdd Create and post content\n- \u2764\ufe0f Like and unlike posts\n- \ud83d\udd04 Retweet posts\n- \ud83d\udcca Get trending topics\n- \ud83d\udc64 Get user details and tweet information\n- \ud83d\udd27 Easy configuration and setup\n- \ud83d\ude80 Ready for PyPI distribution\n\n## Quick Start\n\n### Installation\n\n```bash\npip install ta-x-agent\n```\n\n### Basic Usage\n\n```python\nimport asyncio\nfrom ta_x import setup, XAgent\n\nasync def main():\n # Setup authentication\n setup(\n x_auth_token=\"your_x_auth_token_here\",\n x_ct0=\"your_x_ct0_token_here\", \n openai_api_key=\"your_openai_api_key_here\",\n rapid_api_key=\"your_rapid_api_key_here\"\n )\n \n # Create agent instance\n agent = XAgent()\n \n # Use the agent\n result = await agent.run(\"Post this: Hello X world!\")\n print(result)\n\nasyncio.run(main())\n```\n\n## Import Syntax\n\nThe package supports the exact import syntax you wanted:\n\n```python\nfrom ta_x import XAgent\nagent = XAgent()\nagent.run(user_prompt=\" \")\n```\n\n## Available Operations\n\n### 1. Create Posts\n```python\nawait agent.run(\"Post this: Hello X world!\")\nawait agent.run(\"Create a post about AI and social media\")\n```\n\n### 2. Like Posts\n```python\nawait agent.run(\"Like the latest post\")\nawait agent.run(\"Like the latest post of elonmusk\")\nawait agent.run(\"Like the second latest post of elonmusk\")\n```\n\n### 3. Unlike Posts\n```python\nawait agent.run(\"Unlike the latest post\")\nawait agent.run(\"Unlike the latest post of elonmusk\")\n```\n\n### 4. Retweet Posts\n```python\nawait agent.run(\"Retweet the latest post\")\nawait agent.run(\"Retweet the latest post of elonmusk\")\n```\n\n### 5. Get Trends\n```python\nawait agent.run(\"What's trending on X?\")\nawait agent.run(\"Show trends\")\n```\n\n### 6. Get User Details\n```python\nawait agent.run(\"Get user details for elonmusk\")\nawait agent.run(\"Show user info for elonmusk\")\n```\n\n### 7. Get Tweet Details\n```python\nawait agent.run(\"Get tweet details for 123456789\")\n```\n\n## Authentication Setup\n\n### Method 1: Using setup() function\n```python\nfrom ta_x import setup\n\nsetup(\n x_auth_token=\"your_x_auth_token\",\n x_ct0=\"your_x_ct0_token\",\n openai_api_key=\"your_openai_api_key\",\n rapid_api_key=\"your_rapid_api_key\"\n)\n```\n\n### Method 2: Environment Variables\n```bash\nexport X_AUTH_TOKEN=\"your_x_auth_token\"\nexport X_CT0=\"your_x_ct0_token\"\nexport OPENAI_API_KEY=\"your_openai_api_key\"\nexport RAPID_API_KEY=\"your_rapid_api_key\"\n```\n\n### Method 3: .env file\nCreate a `.env` file in your project root:\n```\nX_AUTH_TOKEN=your_x_auth_token\nX_CT0=your_x_ct0_token\nOPENAI_API_KEY=your_openai_api_key\nRAPID_API_KEY=your_rapid_api_key\n```\n\n## CLI Usage\n\nThe package also provides a command-line interface:\n\n```bash\n# Setup authentication\nta-x-agent setup --x-auth-token \"your_token\" --x-ct0 \"your_ct0\" --openai-key \"your_key\" --rapid-api-key \"your_rapid_key\"\n\n# Create a post\nta-x-agent post \"Hello X world!\"\n\n# Like the latest post\nta-x-agent like\n\n# Get trending topics\nta-x-agent trends\n\n# Get user details\nta-x-agent user-details elonmusk\n```\n\n## Advanced Usage\n\n### Using XAgent Class Directly\n```python\nfrom ta_x import XAgent\n\ncustom_agent = XAgent(\n auth_token=\"your_x_auth_token\",\n ct0=\"your_x_ct0_token\"\n)\n\nresult = await custom_agent.run(\"Post this: Hello world!\")\n```\n\n### Using execute_x_task Function\n```python\nfrom ta_x import execute_x_task\n\nresult = await execute_x_task(\"Post this: Hello world!\")\n```\n\n## Error Handling\n\n```python\ntry:\n result = await agent.run(\"Post this: Test post\")\n print(f\"Success: {result}\")\nexcept Exception as e:\n print(f\"Error: {e}\")\n print(\"Make sure authentication tokens are set correctly!\")\n```\n\n\n## Configuration Management\n\n### Get Current Configuration\n\n```python\nfrom ta_x import get_config\n\nconfig = get_config()\nprint(f\"X Auth Token: {config.x_auth_token}\")\nprint(f\"X CT0: {config.x_ct0}\")\nprint(f\"OpenAI API Key: {config.openai_api_key}\")\nprint(f\"RapidAPI Key: {config.rapid_api_key}\")\n```\n\n### Reset Configuration\n\n```python\nfrom ta_x import reset_config\n\n# Reset to default values\nreset_config()\n```\n\n## Available Operations\n\nThe agent supports the following operations:\n\n1. **Create Posts**: `\"Post this: [content]\"` or `\"Create a post with [content]\"`\n2. **Like Posts**: `\"Like the latest post\"` or `\"Like the post of [username]\"`\n3. **Unlike Posts**: `\"Unlike the post\"` or `\"Dislike the post of [username]\"`\n4. **Retweet Posts**: `\"Retweet the post\"` or `\"Retweet the post of [username]\"`\n5. **Get Trends**: `\"What's trending?\"` or `\"Show trends\"`\n6. **Get Tweet Details**: `\"Get tweet details for [tweet_id]\"`\n7. **Get User Details**: `\"Get user details for [username]\"`\n\n## Error Handling\n\nThe package includes comprehensive error handling:\n\n- **Missing Configuration**: Clear error messages when required tokens are not set\n- **Invalid Credentials**: Proper handling of authentication failures\n- **Network Errors**: Graceful handling of connection issues\n- **Rate Limiting**: Built-in support for X API rate limits\n\n## Development\n\n### Installing Development Dependencies\n\n```bash\npip install -e \".[dev]\"\n```\n\n### Running Tests\n\n```bash\npytest\n```\n\n### Code Formatting\n\n```bash\nblack ta_x/\n```\n\n### Type Checking\n\n```bash\nmypy ta_x/\n```\n\n## Contributing\n\n1. Fork the repository\n2. Create a feature branch\n3. Make your changes\n4. Add tests for new functionality\n5. Run the test suite\n6. Submit a pull request\n\n## License\n\nThis project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.\n\n## Support\n\n- \ud83d\udce7 Email: your.email@example.com\n- \ud83d\udc1b Issues: [GitHub Issues](https://github.com/Soumyajit22theagentic/ta-x/issues)\n- \ud83d\udcd6 Documentation: [GitHub README](https://github.com/Soumyajit22theagentic/ta-x#readme)\n\n## Disclaimer\n\nThis package is for educational and development purposes. Please ensure you comply with X (Twitter)'s Terms of Service and API usage guidelines when using this package. \n",
"bugtrack_url": null,
"license": "MIT",
"summary": "A Python package for interacting with X (Twitter) platform using AI agents",
"version": "0.1.2",
"project_urls": {
"Bug Tracker": "https://github.com/Soumyajit22theagentic/ta_x/issues",
"Documentation": "https://github.com/Soumyajit22theagentic/ta_x#readme",
"Homepage": "https://github.com/Soumyajit22theagentic/ta_x",
"Repository": "https://github.com/Soumyajit22theagentic/ta_x"
},
"split_keywords": [
"twitter",
" x",
" social media",
" ai",
" agent",
" automation"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "b758458ce26fdf84c2c04c9adfa896a6a554725473904e033d5714e8a4c118f9",
"md5": "ba1c4d11e938b796f5b5d65fb74659e8",
"sha256": "e012b898e028cabe2b506a30498a456cca71a1baf4e49d520e8e258d30a07f17"
},
"downloads": -1,
"filename": "ta_x_agent-0.1.2-py3-none-any.whl",
"has_sig": false,
"md5_digest": "ba1c4d11e938b796f5b5d65fb74659e8",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.8",
"size": 17153,
"upload_time": "2025-07-29T09:49:57",
"upload_time_iso_8601": "2025-07-29T09:49:57.220267Z",
"url": "https://files.pythonhosted.org/packages/b7/58/458ce26fdf84c2c04c9adfa896a6a554725473904e033d5714e8a4c118f9/ta_x_agent-0.1.2-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "1e922148a79e063eda485dde12f70780902cdf4bdbc04ceaf0326e6dd8685d25",
"md5": "518dc6ba0438130a4715b82484fe6493",
"sha256": "6464a44d648bf19267fc7ee0ddd45978ec71c635040708e298f82f2e6623989b"
},
"downloads": -1,
"filename": "ta_x_agent-0.1.2.tar.gz",
"has_sig": false,
"md5_digest": "518dc6ba0438130a4715b82484fe6493",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.8",
"size": 19008,
"upload_time": "2025-07-29T09:49:58",
"upload_time_iso_8601": "2025-07-29T09:49:58.960561Z",
"url": "https://files.pythonhosted.org/packages/1e/92/2148a79e063eda485dde12f70780902cdf4bdbc04ceaf0326e6dd8685d25/ta_x_agent-0.1.2.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-07-29 09:49:58",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "Soumyajit22theagentic",
"github_project": "ta_x",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"requirements": [
{
"name": "pydantic",
"specs": [
[
">=",
"2.0.0"
]
]
},
{
"name": "pydantic-ai",
"specs": [
[
">=",
"0.1.0"
]
]
},
{
"name": "requests",
"specs": [
[
">=",
"2.25.0"
]
]
},
{
"name": "python-dotenv",
"specs": [
[
">=",
"1.0.0"
]
]
},
{
"name": "openai",
"specs": [
[
">=",
"1.0.0"
]
]
},
{
"name": "httpx",
"specs": [
[
">=",
"0.25.0"
]
]
},
{
"name": "setuptools",
"specs": []
},
{
"name": "wheel",
"specs": []
},
{
"name": "twine",
"specs": []
}
],
"lcname": "ta-x-agent"
}