Skip to content

Commit 6a47fa3

Browse files
author
Ignacio Van Droogenbroeck
committed
docs: Add Python SDK documentation
- Add comprehensive Python SDK docs with dedicated pages: - Installation (pip/uv, extras, configuration) - Data Ingestion (columnar, DataFrame, buffered, line protocol) - Querying (JSON, pandas, polars, PyArrow) - Data Management (retention, CQs, delete, auth) - Add external scheduler examples for Arc OSS (cron, APScheduler, Docker, Kubernetes CronJob, Airflow) - Clarify that retention policies and CQs require manual execution in Arc OSS (automatic scheduling planned for Cloud/Enterprise 2026) - Update API reference to point to official SDK - Update getting-started with SDK link
1 parent 6871ae9 commit 6a47fa3

9 files changed

Lines changed: 2130 additions & 51 deletions

File tree

docs/api-reference/overview.md

Lines changed: 42 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -272,52 +272,46 @@ Arc API uses URL versioning with the `/api/v1/` prefix:
272272

273273
## Client Libraries
274274

275-
### Python
275+
### Python (Official SDK)
276276

277-
```python
278-
import msgpack
279-
import requests
277+
For production use, we recommend the official Python SDK which provides high-level abstractions, DataFrame integration, buffered writes, and comprehensive error handling.
280278

281-
class ArcClient:
282-
def __init__(self, base_url, token):
283-
self.base_url = base_url
284-
self.token = token
285-
self.headers = {"Authorization": f"Bearer {token}"}
286-
287-
def write(self, measurement, fields, tags=None, timestamp=None):
288-
data = {
289-
"batch": [{
290-
"m": measurement,
291-
"t": timestamp or int(time.time() * 1000),
292-
"h": tags.get("host") if tags else None,
293-
"tags": tags,
294-
"fields": fields
295-
}]
296-
}
297-
298-
response = requests.post(
299-
f"{self.base_url}/api/v1/write/msgpack",
300-
headers={**self.headers, "Content-Type": "application/msgpack"},
301-
data=msgpack.packb(data)
302-
)
303-
response.raise_for_status()
304-
305-
def query(self, sql):
306-
response = requests.post(
307-
f"{self.base_url}/api/v1/query",
308-
headers={**self.headers, "Content-Type": "application/json"},
309-
json={"sql": sql, "format": "json"}
310-
)
311-
response.raise_for_status()
312-
return response.json()
313-
314-
# Usage
315-
client = ArcClient("http://localhost:8000", "YOUR_TOKEN")
316-
client.write("cpu", {"usage": 45.2}, tags={"host": "server01"})
317-
data = client.query("SELECT * FROM cpu LIMIT 10")
279+
```bash
280+
pip install arc-tsdb-client[all]
318281
```
319282

320-
### JavaScript
283+
```python
284+
from arc_client import ArcClient
285+
286+
with ArcClient(host="localhost", token="your-token") as client:
287+
# Write data (columnar format - 9M+ records/sec)
288+
client.write.write_columnar(
289+
measurement="cpu",
290+
columns={
291+
"time": [1704067200000000, 1704067260000000],
292+
"host": ["server01", "server01"],
293+
"usage": [45.2, 47.8],
294+
},
295+
)
296+
297+
# Query to pandas DataFrame
298+
df = client.query.query_pandas("SELECT * FROM default.cpu LIMIT 10")
299+
print(df)
300+
```
301+
302+
**Features:**
303+
- High-performance columnar ingestion
304+
- pandas, Polars, and PyArrow integration
305+
- Buffered writes with automatic batching
306+
- Full async support (`AsyncArcClient`)
307+
- Retention policies, continuous queries, delete operations
308+
- Token management
309+
310+
📖 **[Full Python SDK Documentation →](/docs/sdks/python/)**
311+
312+
### JavaScript (Example Implementation)
313+
314+
No official JavaScript SDK is available yet. Here's an example implementation:
321315

322316
```javascript
323317
const msgpack = require('@msgpack/msgpack');
@@ -365,7 +359,9 @@ await client.write('cpu', { usage: 45.2 }, { host: 'server01' });
365359
const data = await client.query('SELECT * FROM cpu LIMIT 10');
366360
```
367361

368-
### Go
362+
### Go (Example Implementation)
363+
364+
No official Go SDK is available yet. Here's an example implementation:
369365

370366
```go
371367
package main
@@ -533,7 +529,8 @@ for chunk in response.iter_content(chunk_size=8192):
533529

534530
## Next Steps
535531

536-
- **[Getting Started →](/arc/getting-started)** - Learn how to use Arc
537-
- **[Data Lifecycle →](/arc/data-lifecycle/retention-policies)** - Manage data retention and deletion
532+
- **[Python SDK →](/docs/sdks/python/)** - Official Python client with DataFrame support
533+
- **[Getting Started →](/docs/getting-started)** - Learn how to use Arc
534+
- **[Data Lifecycle →](/docs/data-lifecycle/retention-policies)** - Manage data retention and deletion
538535
- **[Interactive Docs →](http://localhost:8000/docs)** - Try the API with Swagger UI
539536
- **[OpenAPI Spec →](http://localhost:8000/openapi.json)** - Download OpenAPI specification

docs/getting-started.md

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -339,12 +339,11 @@ curl -X POST http://localhost:8000/api/v1/query \
339339

340340
Now that you have Arc running, you can:
341341

342-
- **[Configure storage backends](/arc/configuration/storage)** - Switch to MinIO, AWS S3, or GCS
343-
- **[Set up authentication](/arc/configuration/authentication)** - Manage API tokens and permissions
344-
- **[Integrate with Telegraf](/arc/integrations/telegraf)** - Collect system metrics automatically
345-
- **[Connect Apache Superset](/arc/integrations/superset)** - Build interactive dashboards
346-
- **[Enable WAL](/arc/advanced/wal)** - Guarantee zero data loss
347-
- **[Optimize compaction](/arc/advanced/compaction)** - Fine-tune query performance
342+
- **[Use the Python SDK](/docs/sdks/python/)** - Official client with DataFrame support and buffered writes
343+
- **[Integrate with Telegraf](/docs/integrations/telegraf)** - Collect system metrics automatically
344+
- **[Connect Apache Superset](/docs/integrations/superset)** - Build interactive dashboards
345+
- **[Enable WAL](/docs/advanced/wal)** - Guarantee zero data loss
346+
- **[Optimize compaction](/docs/advanced/compaction)** - Fine-tune query performance
348347

349348
## Troubleshooting
350349

docs/sdks/_category_.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"label": "SDKs",
3+
"position": 9,
4+
"collapsed": false,
5+
"link": {
6+
"type": "generated-index",
7+
"description": "Official client libraries for Arc time-series database."
8+
}
9+
}

docs/sdks/python/_category_.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"label": "Python",
3+
"position": 1,
4+
"collapsed": false
5+
}

0 commit comments

Comments
 (0)