Metadata-Version: 2.4
Name: textql
Version: 2.0.0
Summary: Official Python SDK for the TextQL Platform API
Project-URL: Homepage, https://textql.com
Project-URL: Documentation, https://docs.textql.com
Project-URL: Repository, https://github.com/TextQLLabs/textql-python
Project-URL: Issues, https://github.com/TextQLLabs/textql-python/issues
Project-URL: Changelog, https://github.com/TextQLLabs/textql-python/blob/main/CHANGELOG.md
Author-email: TextQL <support@textql.com>
License: MIT License
        
        Copyright (c) 2026 TextQL
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
License-File: LICENSE
Keywords: ana,analytics,api,sdk,textql
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Python: >=3.9
Requires-Dist: httpx<1,>=0.27
Requires-Dist: typing-extensions>=4.7; python_version < '3.11'
Provides-Extra: dev
Requires-Dist: pyright>=1.1.380; extra == 'dev'
Requires-Dist: pytest-asyncio>=0.23; extra == 'dev'
Requires-Dist: pytest>=8; extra == 'dev'
Requires-Dist: respx>=0.21; extra == 'dev'
Requires-Dist: ruff>=0.6; extra == 'dev'
Description-Content-Type: text/markdown

# TextQL Python SDK

[![PyPI version](https://img.shields.io/pypi/v/textql.svg)](https://pypi.org/project/textql/)
[![Python versions](https://img.shields.io/pypi/pyversions/textql.svg)](https://pypi.org/project/textql/)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE)

Official Python SDK for the [TextQL Platform API](https://docs.textql.com/api-reference/v2/introduction).

## Installation

```bash
pip install textql
```

Requires Python 3.9+.

## Quickstart

```python
from textql import TextQL

client = TextQL(api_key="tql_...")  # or set TEXTQL_API_KEY in the environment

# Ask a question
response = client.chat.create("What was total revenue last quarter?", connector_ids=[1])
print(response["response"])

# Stream a response
for event in client.chat.stream("Summarize sales by region"):
    if event["type"] == "text":
        print(event["text"], end="", flush=True)

# Upload files with a question
response = client.chat.create(
    "Analyze this data",
    files=["./sales.csv"],
)
```

## Resources

### Chat

```python
client.chat.list(limit=10)
client.chat.create("What connectors are available?")
client.chat.get("chat-uuid")
client.chat.stream("Summarize revenue")
client.chat.cancel("chat-uuid")
```

### Connectors

```python
client.connectors.list()
```

### Playbooks

```python
client.playbooks.list(limit=10)
pb = client.playbooks.create()
client.playbooks.update(pb["id"], name="Weekly Revenue", prompt="Summarize revenue by region")
client.playbooks.deploy(pb["id"])
client.playbooks.run(pb["id"])
client.playbooks.get(pb["id"])
client.playbooks.delete(pb["id"])
```

### Sandbox

```python
sb = client.sandbox.start()
sid = sb["sandbox_id"]

client.sandbox.execute(sid, code="import pandas as pd; print(pd.__version__)")
client.sandbox.query(sid, connector_id=1, query="SELECT * FROM sales LIMIT 10", dataframe_name="sales")
client.sandbox.upload_file(sid, "./data.csv")
client.sandbox.status(sid)
client.sandbox.stop(sid)
```

## Configuration

| Option | Env var | Default |
|---|---|---|
| `api_key` | `TEXTQL_API_KEY` | — (required) |
| `base_url` | `TEXTQL_BASE_URL` | `https://app.textql.com` |
| `timeout` | — | `60.0` seconds |

The `base_url` accepts a bare hostname (e.g. `app.textql.com`) or a full URL.

## Links

- [API documentation](https://docs.textql.com/api-reference/v2/introduction)
- [Changelog](CHANGELOG.md)
- [Issues](https://github.com/TextQLLabs/textql-python/issues)

## License

[MIT](LICENSE)
