Skip to content

Commit 432216d

Browse files
author
ThreadSync Engineering
committed
feat: initial SDK scaffold — v0.1.0
0 parents  commit 432216d

6 files changed

Lines changed: 183 additions & 0 deletions

File tree

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
__pycache__
2+
dist
3+
*.egg-info
4+
.env
5+
.venv
6+
venv

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2026 Cichocki
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
# ThreadSync Python SDK
2+
3+
[![PyPI](https://img.shields.io/pypi/v/threadsync)](https://pypi.org/project/threadsync/)
4+
[![license](https://img.shields.io/pypi/l/threadsync)](./LICENSE)
5+
[![python](https://img.shields.io/pypi/pyversions/threadsync)](https://pypi.org/project/threadsync/)
6+
7+
Official Python SDK for the [ThreadSync API](https://www.threadsync.io/api-docs.html).
8+
9+
## Installation
10+
11+
```bash
12+
pip install threadsync
13+
```
14+
15+
## Quick Start
16+
17+
```python
18+
from threadsync import ThreadSync
19+
20+
client = ThreadSync(bearer_token='YOUR_API_KEY')
21+
22+
# Create a connection
23+
connection = client.connections.create(
24+
'salesforce',
25+
credentials={'username': 'user@example.com', 'password': 'secret'}
26+
)
27+
28+
# Set up a sync
29+
sync = client.sync.create(
30+
source={'connection': connection.id, 'object': 'Contact'},
31+
destination={'connection': 'dest-conn-id', 'table': 'contacts'},
32+
schedule='realtime',
33+
)
34+
35+
print(f'Sync started: {sync.id}')
36+
```
37+
38+
## API Reference
39+
40+
### `ThreadSync(bearer_token, base_url=...)`
41+
42+
| Parameter | Type | Required | Description |
43+
|-----------|------|----------|-------------|
44+
| `bearer_token` | `str` | Yes | Your ThreadSync API key |
45+
| `base_url` | `str` | No | Override the API base URL (default: `https://api.threadsync.io/v1`) |
46+
47+
### `client.connections`
48+
49+
| Method | Description |
50+
|--------|-------------|
51+
| `connections.create(provider, **kwargs)` | Create a new connection |
52+
| `connections.get(id)` | Retrieve a connection by ID |
53+
| `connections.list()` | List all connections |
54+
55+
### `client.sync`
56+
57+
| Method | Description |
58+
|--------|-------------|
59+
| `sync.create(source, destination, schedule)` | Create a new sync job |
60+
| `sync.get(id)` | Retrieve a sync by ID |
61+
62+
## Links
63+
64+
- [API Documentation](https://www.threadsync.io/api-docs.html)
65+
- [ThreadSync Website](https://www.threadsync.io)
66+
67+
## License
68+
69+
MIT — see [LICENSE](./LICENSE)

pyproject.toml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
[build-system]
2+
requires = ["setuptools>=68", "wheel"]
3+
build-backend = "setuptools.backends.legacy:build"
4+
5+
[project]
6+
name = "threadsync"
7+
version = "0.1.0"
8+
description = "Official Python SDK for the ThreadSync API"
9+
readme = "README.md"
10+
license = { file = "LICENSE" }
11+
requires-python = ">=3.8"
12+
dependencies = [
13+
"httpx>=0.24",
14+
]
15+
16+
[project.urls]
17+
Homepage = "https://www.threadsync.io"
18+
Documentation = "https://www.threadsync.io/api-docs.html"
19+
Repository = "https://github.com/threadsync-infrastructure/threadsync-python"

threadsync/__init__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
from .client import ThreadSync, Connection, Sync
2+
3+
__version__ = '0.1.0'
4+
__all__ = ['ThreadSync', 'Connection', 'Sync']

threadsync/client.py

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
import httpx
2+
from dataclasses import dataclass
3+
from typing import Optional, Any
4+
5+
@dataclass
6+
class Connection:
7+
id: str
8+
provider: str
9+
name: str
10+
status: str
11+
12+
@dataclass
13+
class Sync:
14+
id: str
15+
status: str
16+
records_synced: Optional[int] = None
17+
18+
class _ConnectionsAPI:
19+
def __init__(self, client: 'ThreadSync'):
20+
self._client = client
21+
22+
def create(self, provider: str, **kwargs) -> Connection:
23+
data = self._client._request('POST', '/connections', json={'provider': provider, **kwargs})
24+
return Connection(**data)
25+
26+
def get(self, id: str) -> Connection:
27+
data = self._client._request('GET', f'/connections/{id}')
28+
return Connection(**data)
29+
30+
def list(self) -> list:
31+
data = self._client._request('GET', '/connections')
32+
return [Connection(**c) for c in data]
33+
34+
class _SyncAPI:
35+
def __init__(self, client: 'ThreadSync'):
36+
self._client = client
37+
38+
def create(self, source: dict, destination: dict, schedule: str = 'realtime') -> Sync:
39+
data = self._client._request('POST', '/syncs', json={
40+
'source': source, 'destination': destination, 'schedule': schedule
41+
})
42+
return Sync(**data)
43+
44+
def get(self, id: str) -> Sync:
45+
data = self._client._request('GET', f'/syncs/{id}')
46+
return Sync(**data)
47+
48+
class ThreadSync:
49+
def __init__(self, bearer_token: str, base_url: str = 'https://api.threadsync.io/v1'):
50+
self._http = httpx.Client(
51+
base_url=base_url,
52+
headers={
53+
'Authorization': f'Bearer {bearer_token}',
54+
'Content-Type': 'application/json',
55+
'User-Agent': 'threadsync-python/0.1.0',
56+
},
57+
)
58+
self.connections = _ConnectionsAPI(self)
59+
self.sync = _SyncAPI(self)
60+
61+
def _request(self, method: str, path: str, **kwargs) -> Any:
62+
response = self._http.request(method, path, **kwargs)
63+
response.raise_for_status()
64+
return response.json()

0 commit comments

Comments
 (0)