Skip to content

Commit 492e751

Browse files
authored
feat: convert to async using httpx (v3.0.0) (#7)
* feat: convert to async using httpx BREAKING CHANGE: All methods are now async and require await - Replace requests with httpx for async HTTP calls - All API methods now return coroutines - Add httpx as dependency - Bump version to 3.0.0 * docs: add CHANGELOG and release announcement for v3.0.0
1 parent 2f84afe commit 492e751

File tree

5 files changed

+273
-114
lines changed

5 files changed

+273
-114
lines changed

ANNOUNCEMENT.md

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
# shipthisapi-python v3.0.0 Release
2+
3+
We're excited to announce the release of **shipthisapi-python v3.0.0** - now with full async support!
4+
5+
## What's New
6+
7+
### Async-First Design
8+
The library has been completely rewritten to support async/await, making it perfect for modern Python applications like FastAPI, aiohttp, and other async frameworks.
9+
10+
```python
11+
import asyncio
12+
from ShipthisAPI import ShipthisAPI
13+
14+
async def main():
15+
client = ShipthisAPI(
16+
organisation="your_org_id",
17+
x_api_key="your_api_key"
18+
)
19+
20+
await client.connect()
21+
22+
# Fetch shipments
23+
shipments = await client.get_list("sea_shipment")
24+
25+
# Update a document
26+
await client.patch_item(
27+
"fcl_load",
28+
"68a4f906743189ad061429a7",
29+
update_fields={"container_no": "CONT123"}
30+
)
31+
32+
asyncio.run(main())
33+
```
34+
35+
### Custom Headers Support
36+
Server-to-server authentication is now supported via custom headers:
37+
38+
```python
39+
client = ShipthisAPI(
40+
organisation="org_id",
41+
custom_headers={
42+
"authorization": "Bearer your_token",
43+
# ... other custom headers
44+
}
45+
)
46+
```
47+
48+
### Simplified Field Updates
49+
`patch_item` is now the recommended way to update document fields. It provides:
50+
- Full field validation
51+
- Workflow triggers
52+
- Audit logging
53+
- Business logic execution
54+
55+
## Breaking Changes
56+
57+
1. **All methods are now async** - You must use `await` when calling API methods
58+
2. **`requests` replaced with `httpx`** - The library now uses `httpx` for HTTP calls
59+
3. **Removed deprecated methods**:
60+
- `webhook_sync` - Use `patch_item` instead
61+
- `webhook_update` - Use `patch_item` instead
62+
63+
## Installation
64+
65+
```bash
66+
pip install shipthisapi-python==3.0.0
67+
```
68+
69+
Or update your requirements:
70+
```
71+
shipthisapi-python>=3.0.0
72+
```
73+
74+
## Migration Guide
75+
76+
See [CHANGELOG.md](./CHANGELOG.md) for a detailed migration guide from v2.x to v3.x.
77+
78+
## Questions or Issues?
79+
80+
- Open an issue on [GitHub](https://github.com/shipthisco/shipthisapi-python/issues)
81+
- Contact support at support@shipthis.co

CHANGELOG.md

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
# Changelog
2+
3+
All notable changes to this project will be documented in this file.
4+
5+
## [3.0.0] - 2025-02-06
6+
7+
### Breaking Changes
8+
- **Async-first**: All API methods are now async and require `await`
9+
- Replaced `requests` library with `httpx` for async HTTP support
10+
- Removed `webhook_sync` and `webhook_update` methods (use `patch_item` instead)
11+
12+
### Added
13+
- Full async/await support using `httpx`
14+
- `custom_headers` parameter for server-to-server authentication
15+
- `create_reference_linked_field` method
16+
- Per-request header override support
17+
18+
### Changed
19+
- `x_api_key` is now optional (can use `custom_headers` for auth)
20+
- `patch_item` is now the recommended method for updating document fields
21+
- Updated all method signatures to be async
22+
23+
### Migration Guide
24+
25+
**Before (v2.x):**
26+
```python
27+
from ShipthisAPI import ShipthisAPI
28+
29+
client = ShipthisAPI(organisation="org_id", x_api_key="key")
30+
client.connect()
31+
items = client.get_list("shipment")
32+
client.patch_item("fcl_load", doc_id, {"status": "done"})
33+
```
34+
35+
**After (v3.x):**
36+
```python
37+
import asyncio
38+
from ShipthisAPI import ShipthisAPI
39+
40+
async def main():
41+
client = ShipthisAPI(organisation="org_id", x_api_key="key")
42+
await client.connect()
43+
items = await client.get_list("shipment")
44+
await client.patch_item("fcl_load", doc_id, {"status": "done"})
45+
46+
asyncio.run(main())
47+
```
48+
49+
## [2.2.0] - 2025-02-06
50+
51+
### Added
52+
- `custom_headers` parameter for overriding default headers
53+
- `create_reference_linked_field` method
54+
- Per-request header override in `_make_request`
55+
56+
### Changed
57+
- `x_api_key` is now optional
58+
- Enhanced `patch_item` documentation
59+
60+
## [2.1.0] - 2025-01-15
61+
62+
### Added
63+
- `primary_workflow_action` method for workflow transitions
64+
- `secondary_workflow_action` method for sub-status changes
65+
- `bulk_edit` method for batch updates
66+
67+
## [2.0.0] - 2024-12-01
68+
69+
### Added
70+
- Complete rewrite with better error handling
71+
- `ShipthisAPIError`, `ShipthisAuthError`, `ShipthisRequestError` exceptions
72+
- Comprehensive CRUD operations
73+
- Workflow operations
74+
- Report views
75+
- Third-party integrations (currency, places)
76+
- Conversation methods
77+
- File upload support
78+
79+
## [1.0.0] - 2024-06-01
80+
81+
### Added
82+
- Initial release
83+
- Basic API client functionality

ShipthisAPI/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# __variables__ with double-quoted values will be available in setup.py
2-
__version__ = "2.2.0"
2+
__version__ = "3.0.0"
33

44
from .shipthisapi import (
55
ShipthisAPI,

0 commit comments

Comments
 (0)