You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: CHANGELOG.md
+12Lines changed: 12 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,5 +1,17 @@
1
1
# Change Log
2
2
3
+
## 16.0.0rc1
4
+
5
+
* Breaking change: All service methods now return typed Pydantic models instead of `Dict[str, Any]`
6
+
* Breaking change: Models with dynamic fields (e.g., `Row`, `Document`) now store user-defined data in a typed `.data` property instead of direct attribute access
7
+
* Breaking change: Added `pydantic>=2,<3` as a required dependency
8
+
* Breaking change: Minimum Python version raised from 3.5 to 3.9
9
+
* Added `AppwriteModel` base class (Pydantic `BaseModel`) for all response models with `from_dict()` and `to_dict()` helpers
10
+
* Added 130+ typed model classes under `appwrite/models/` (e.g., `Database`, `Collection`, `Document`, `User`, `Session`, `File`, `Bucket`, etc.)
11
+
* Added Generic[T] support for models with dynamic fields (e.g., `Row`, `Document`) - pass `model_type=YourModel` to methods like `get_row()` or `list_rows()` for type-safe access to user-defined data via `result.data.field_name`
12
+
* Updated README with `uv add appwrite` installation example
13
+
* Updated all doc examples to use typed response models (e.g., `result: TemplateFunctionList = functions.list_templates(...)`)
Copy file name to clipboardExpand all lines: README.md
+69-3Lines changed: 69 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -20,6 +20,12 @@ To install via [PyPI](https://pypi.org/):
20
20
pip install appwrite
21
21
```
22
22
23
+
Or with `uv`:
24
+
25
+
```bash
26
+
uv add appwrite
27
+
```
28
+
23
29
24
30
## Getting Started
25
31
@@ -43,10 +49,16 @@ client = Client()
43
49
### Make Your First Request
44
50
Once your SDK object is set, create any of the Appwrite service objects and choose any request to send. Full documentation for any service method you would like to use can be found in your SDK documentation or in the [API References](https://appwrite.io/docs) section.
45
51
52
+
All service methods return typed Pydantic models, so you can access response fields as attributes:
53
+
46
54
```python
47
55
users = Users(client)
48
56
49
-
result = users.create(ID.unique(), email="email@example.com", phone="+123456789", password="password", name="Walter O'Brien")
57
+
user = users.create(ID.unique(), email="email@example.com", phone="+123456789", password="password", name="Walter O'Brien")
58
+
59
+
print(user.name) # "Walter O'Brien"
60
+
print(user.email) # "email@example.com"
61
+
print(user.id) # The generated user ID
50
62
```
51
63
52
64
### Full Example
@@ -66,7 +78,60 @@ client = Client()
66
78
67
79
users = Users(client)
68
80
69
-
result = users.create(ID.unique(), email="email@example.com", phone="+123456789", password="password", name="Walter O'Brien")
81
+
user = users.create(ID.unique(), email="email@example.com", phone="+123456789", password="password", name="Walter O'Brien")
82
+
83
+
print(user.name) # Access fields as attributes
84
+
print(user.to_dict()) # Convert to dictionary if needed
85
+
```
86
+
87
+
### Type Safety with Models
88
+
89
+
The Appwrite Python SDK provides type safety when working with database rows through generic methods. Methods like `get_row`, `list_rows`, and others accept a `model_type` parameter that allows you to specify your custom Pydantic model for full type safety.
90
+
91
+
```python
92
+
from pydantic import BaseModel
93
+
from datetime import datetime
94
+
from typing import Optional
95
+
from appwrite.client import Client
96
+
from appwrite.services.tables_db import TablesDB
97
+
98
+
# Define your custom model matching your table schema
99
+
classPost(BaseModel):
100
+
postId: int
101
+
authorId: int
102
+
title: str
103
+
content: str
104
+
createdAt: datetime
105
+
updatedAt: datetime
106
+
isPublished: bool
107
+
excerpt: Optional[str] =None
108
+
109
+
client = Client()
110
+
# ... configure your client ...
111
+
112
+
tables_db = TablesDB(client)
113
+
114
+
# Fetch a single row with type safety
115
+
row = tables_db.get_row(
116
+
database_id="your-database-id",
117
+
table_id="your-table-id",
118
+
row_id="your-row-id",
119
+
model_type=Post # Pass your custom model type
120
+
)
121
+
122
+
print(row.data.title) # Fully typed - IDE autocomplete works
123
+
print(row.data.postId) # int type, not Any
124
+
print(row.data.createdAt) # datetime type
125
+
126
+
# Fetch multiple rows with type safety
127
+
result = tables_db.list_rows(
128
+
database_id="your-database-id",
129
+
table_id="your-table-id",
130
+
model_type=Post
131
+
)
132
+
133
+
for row in result.rows:
134
+
print(f"{row.data.title} by {row.data.authorId}")
70
135
```
71
136
72
137
### Error Handling
@@ -75,7 +140,8 @@ The Appwrite Python SDK raises `AppwriteException` object with `message`, `code`
75
140
```python
76
141
users = Users(client)
77
142
try:
78
-
result = users.create(ID.unique(), email="email@example.com", phone="+123456789", password="password", name="Walter O'Brien")
143
+
user = users.create(ID.unique(), email="email@example.com", phone="+123456789", password="password", name="Walter O'Brien")
0 commit comments