Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
# Change Log

## 27.1.0

* Added: `migrations` service to run Appwrite, Firebase, NHost, Supabase, CSV and JSON migrations, plus retries and listing
* Added: `Migration`, `MigrationList` and `MigrationReport` models and the `AppwriteMigrationResource`, `FirebaseMigrationResource`, `NHostMigrationResource`, `SupabaseMigrationResource` and `OnDuplicate` enums

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove the stale MigrationReport release-note entry

These commits remove the MigrationReport module and its public export, but this bullet still says the model is added in 27.1.0. Users following the release notes will try to import MigrationReport from appwrite.models and fail.

Prompt To Fix With AI
This is a comment left during a code review.
Path: CHANGELOG.md
Line: 6

Comment:
**Remove the stale MigrationReport release-note entry**

These commits remove the `MigrationReport` module and its public export, but this bullet still says the model is added in 27.1.0. Users following the release notes will try to import `MigrationReport` from `appwrite.models` and fail.

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

🟡 Minor · documentation · Reply if this doesn't apply.

* Added: `project.update_deny_realtime_guests_policy`, the `PolicyDenyRealtimeGuests` model and `ProjectPolicyId.DENY_REALTIME_GUESTS`
* Added: `project.delete_sessions` to sign out every user in the project
* Added: `BillingPlan.deploymentretention`, `deploymentretentionmax` and `deploymentsretentioncount`
* Added: `python-3.15`, `deno-2.9`, `go-1.27` and `rust-1.99` to `Runtime` and `BuildRuntime`
* Updated: requests send `X-Appwrite-Response-Format: 2.6.2`; README targets Appwrite 2.6.x
* Updated: redirects are no longer followed; a 3xx raises `AppwriteException` naming the `Location`
* Fixed: path parameters are percent-encoded as one segment; `.` and `..` raise `AppwriteException`
* Fixed: the chunked-upload resume lookup encodes the file ID

## 27.0.0

This release updates the HTTP dependency requirements and raises the minimum supported Python version.
Expand Down
14 changes: 12 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# Appwrite Python SDK

![License](https://img.shields.io/badge/license-BSD--3--Clause-blue.svg?style=flat-square)
![Version](https://img.shields.io/badge/api%20version-2.5.0-blue.svg?style=flat-square)
![Version](https://img.shields.io/badge/api%20version-2.6.2-blue.svg?style=flat-square)
[![X Account](https://img.shields.io/badge/follow-%40appwrite-000000?logo=x&style=flat-square)](https://x.com/appwrite)
[![Discord](https://img.shields.io/discord/564160730845151244?label=discord&style=flat-square)](https://appwrite.io/discord)

**This SDK targets Appwrite server version 2.5.x as shipped on Appwrite Cloud.** Self-hosted releases can lag behind Cloud — if you run an older self-hosted build, use a matching older SDK from [previous releases](https://github.com/appwrite/sdk-for-python/releases) when APIs differ.
**This SDK targets Appwrite server version 2.6.x as shipped on Appwrite Cloud.** Self-hosted releases can lag behind Cloud — if you run an older self-hosted build, use a matching older SDK from [previous releases](https://github.com/appwrite/sdk-for-python/releases) when APIs differ.

Appwrite is an open-source backend as a service server that abstracts and simplifies complex and repetitive development tasks behind a very simple to use REST API. Appwrite aims to help you develop your apps faster and in a more secure way. Use the Python SDK to integrate your app with the Appwrite server to easily start interacting with all of Appwrite backend APIs and tools. For full API documentation and tutorials go to [https://appwrite.io/docs](https://appwrite.io/docs)

Expand All @@ -27,6 +27,16 @@ uv add appwrite

## Getting started

### Requirements and installation

Use Python 3.10 or later. Create and activate a virtual environment with that interpreter, then install the SDK:

```sh
python -m pip install --upgrade appwrite
```

The SDK requires `requests>=2.34.2,<3` and `urllib3>=2.8.0,<3`. Update application pins or constraints that exclude these versions.

### Initialize the client

Create a client with your Appwrite endpoint, project ID and an [API key](https://appwrite.io/docs/partners/project/api-keys). Find the endpoint and project ID in your project's **Settings** page, and create an API key with only the scopes you need under **API keys** in the project sidebar.
Expand Down
22 changes: 17 additions & 5 deletions appwrite/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import requests
from concurrent.futures import ThreadPoolExecutor, as_completed
from threading import Lock
from urllib.parse import quote
from .input_file import InputFile
from .exception import AppwriteException
from .encoders.value_class_encoder import ValueClassEncoder
Expand All @@ -19,12 +20,12 @@ def __init__(self):
self._endpoint = 'https://cloud.appwrite.io/v1'
self._global_headers = {
'content-type': '',
'user-agent': f'AppwritePythonSDK/27.0.0 ({platform.uname().system}; {platform.uname().version}; {platform.uname().machine})',
'user-agent': f'AppwritePythonSDK/27.1.0 ({platform.uname().system}; {platform.uname().version}; {platform.uname().machine})',
'x-sdk-name': 'Python',
'x-sdk-platform': 'server',
'x-sdk-language': 'python',
'x-sdk-version': '27.0.0',
'X-Appwrite-Response-Format': '2.5.0',
'x-sdk-version': '27.1.0',
'X-Appwrite-Response-Format': '2.6.2',
}
self._config = {}

Expand Down Expand Up @@ -180,11 +181,18 @@ def call(self, method, path='', headers=None, params=None, response_type='json')
files=files,
headers=headers,
verify=(not self._self_signed),
allow_redirects=False if response_type == 'location' else True,
# A redirect would carry the API key to wherever it points, possibly another host.
allow_redirects=False,
Comment thread
ChiragAgg5k marked this conversation as resolved.
)

response.raise_for_status()

if response_type != 'location' and 300 <= response.status_code < 400:
location = response.headers.get('Location', '')
raise AppwriteException(
f'Redirect to {location} not followed', response.status_code, None, response.text
)

warnings = response.headers.get('x-appwrite-warning')
if warnings:
for warning in warnings.split(';'):
Expand All @@ -202,6 +210,8 @@ def call(self, method, path='', headers=None, params=None, response_type='json')
return response.json()

return response._content
except AppwriteException:
raise
except Exception as e:
if response != None:
content_type = response.headers['Content-Type']
Expand Down Expand Up @@ -249,8 +259,10 @@ def chunked_upload(
counter = 0

if upload_id:
if upload_id in ('.', '..'):
raise AppwriteException('Path parameter cannot be "." or ".."')
try:
result = self.call('get', path + '/' + upload_id, headers)
result = self.call('get', path + '/' + quote(upload_id, safe="!*'()"), headers)
counter = result['chunksUploaded']
except:
pass
Expand Down
24 changes: 24 additions & 0 deletions appwrite/encoders/value_class_encoder.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,14 @@
from ..enums.execution_method import ExecutionMethod
from ..enums.message_priority import MessagePriority
from ..enums.smtp_encryption import SmtpEncryption
from ..enums.appwrite_migration_resource import AppwriteMigrationResource
from ..enums.on_duplicate import OnDuplicate
from ..enums.firebase_migration_resource import FirebaseMigrationResource
from ..enums.n_host_migration_resource import NHostMigrationResource
from ..enums.supabase_migration_resource import SupabaseMigrationResource
from ..enums.region import Region
from ..enums.project_auth_method_id import ProjectAuthMethodId
from ..enums.environment_resource import EnvironmentResource
from ..enums.project_o_auth2_auth0_prompt import ProjectOAuth2Auth0Prompt
from ..enums.project_o_auth2_discord_prompt import ProjectOAuth2DiscordPrompt
from ..enums.project_o_auth2_git_hub_prompt import ProjectOAuth2GitHubPrompt
Expand Down Expand Up @@ -173,12 +179,30 @@ def default(self, o):
if isinstance(o, SmtpEncryption):
return o.value

if isinstance(o, AppwriteMigrationResource):
return o.value

if isinstance(o, OnDuplicate):
return o.value

if isinstance(o, FirebaseMigrationResource):
return o.value

if isinstance(o, NHostMigrationResource):
return o.value

if isinstance(o, SupabaseMigrationResource):
return o.value

if isinstance(o, Region):
return o.value

if isinstance(o, ProjectAuthMethodId):
return o.value

if isinstance(o, EnvironmentResource):
return o.value

if isinstance(o, ProjectOAuth2Auth0Prompt):
return o.value

Expand Down
44 changes: 44 additions & 0 deletions appwrite/enums/appwrite_migration_resource.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
from enum import Enum


class AppwriteMigrationResource(Enum):
USER = "user"
TEAM = "team"
MEMBERSHIP = "membership"
AUTH_METHODS = "auth-methods"
POLICIES = "policies"
OAUTH2_PROVIDER = "oauth2-provider"
DATABASE = "database"
TABLE = "table"
COLUMN = "column"
INDEX = "index"
ROW = "row"
DOCUMENT = "document"
ATTRIBUTE = "attribute"
COLLECTION = "collection"
DOCUMENTSDB = "documentsdb"
VECTORSDB = "vectorsdb"
BUCKET = "bucket"
FILE = "file"
FUNCTION = "function"
DEPLOYMENT = "deployment"
ENVIRONMENT_VARIABLE = "environment-variable"
PROVIDER = "provider"
TOPIC = "topic"
SUBSCRIBER = "subscriber"
MESSAGE = "message"
SITE = "site"
SITE_DEPLOYMENT = "site-deployment"
SITE_VARIABLE = "site-variable"
PLATFORM = "platform"
API_KEY = "api-key"
WEBHOOK = "webhook"
SMTP = "smtp"
BACKUP_POLICY = "backup-policy"
PROJECT_VARIABLE = "project-variable"
PROJECT_PROTOCOLS = "project-protocols"
PROJECT_LABELS = "project-labels"
PROJECT_SERVICES = "project-services"
PROJECT_EMAIL_TEMPLATE = "project-email-template"
PROJECT_ENVIRONMENT = "project-environment"
RULE = "rule"
4 changes: 4 additions & 0 deletions appwrite/enums/build_runtime.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ class BuildRuntime(Enum):
PYTHON_3_12 = "python-3.12"
PYTHON_3_13 = "python-3.13"
PYTHON_3_14 = "python-3.14"
PYTHON_3_15 = "python-3.15"
PYTHON_ML_3_11 = "python-ml-3.11"
PYTHON_ML_3_12 = "python-ml-3.12"
PYTHON_ML_3_13 = "python-ml-3.13"
Expand All @@ -39,6 +40,7 @@ class BuildRuntime(Enum):
DENO_2_0 = "deno-2.0"
DENO_2_5 = "deno-2.5"
DENO_2_6 = "deno-2.6"
DENO_2_9 = "deno-2.9"
DART_2_15 = "dart-2.15"
DART_2_16 = "dart-2.16"
DART_2_17 = "dart-2.17"
Expand Down Expand Up @@ -86,7 +88,9 @@ class BuildRuntime(Enum):
GO_1_24 = "go-1.24"
GO_1_25 = "go-1.25"
GO_1_26 = "go-1.26"
GO_1_27 = "go-1.27"
RUST_1_83 = "rust-1.83"
RUST_1_99 = "rust-1.99"
STATIC_1 = "static-1"
FLUTTER_3_24 = "flutter-3.24"
FLUTTER_3_27 = "flutter-3.27"
Expand Down
38 changes: 38 additions & 0 deletions appwrite/enums/environment_resource.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
from enum import Enum


class EnvironmentResource(Enum):
USER = "user"
TEAM = "team"
MEMBERSHIP = "membership"
AUTH_METHODS = "auth-methods"
POLICIES = "policies"
OAUTH2_PROVIDER = "oauth2-provider"
DATABASE = "database"
DOCUMENTSDB = "documentsdb"
VECTORSDB = "vectorsdb"
TABLE = "table"
COLLECTION = "collection"
COLUMN = "column"
ATTRIBUTE = "attribute"
INDEX = "index"
ROW = "row"
DOCUMENT = "document"
BUCKET = "bucket"
FILE = "file"
FUNCTION = "function"
ENVIRONMENT_VARIABLE = "environment-variable"
DEPLOYMENT = "deployment"
SITE = "site"
SITE_VARIABLE = "site-variable"
SITE_DEPLOYMENT = "site-deployment"
PROVIDER = "provider"
TOPIC = "topic"
SUBSCRIBER = "subscriber"
PLATFORM = "platform"
SMTP = "smtp"
PROJECT_VARIABLE = "project-variable"
PROJECT_PROTOCOLS = "project-protocols"
PROJECT_LABELS = "project-labels"
PROJECT_SERVICES = "project-services"
PROJECT_EMAIL_TEMPLATE = "project-email-template"
14 changes: 14 additions & 0 deletions appwrite/enums/firebase_migration_resource.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
from enum import Enum


class FirebaseMigrationResource(Enum):
USER = "user"
DATABASE = "database"
TABLE = "table"
COLUMN = "column"
ROW = "row"
DOCUMENT = "document"
ATTRIBUTE = "attribute"
COLLECTION = "collection"
BUCKET = "bucket"
FILE = "file"
15 changes: 15 additions & 0 deletions appwrite/enums/n_host_migration_resource.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
from enum import Enum


class NHostMigrationResource(Enum):
USER = "user"
DATABASE = "database"
TABLE = "table"
COLUMN = "column"
INDEX = "index"
ROW = "row"
DOCUMENT = "document"
ATTRIBUTE = "attribute"
COLLECTION = "collection"
BUCKET = "bucket"
FILE = "file"
7 changes: 7 additions & 0 deletions appwrite/enums/on_duplicate.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
from enum import Enum


class OnDuplicate(Enum):
FAIL = "fail"
SKIP = "skip"
OVERWRITE = "overwrite"
1 change: 1 addition & 0 deletions appwrite/enums/project_policy_id.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,5 @@ class ProjectPolicyId(Enum):
DENY_DISPOSABLE_EMAIL = "deny-disposable-email"
DENY_FREE_EMAIL = "deny-free-email"
DENY_CORPORATE_EMAIL = "deny-corporate-email"
DENY_REALTIME_GUESTS = "deny-realtime-guests"
PASSKEY = "passkey"
4 changes: 4 additions & 0 deletions appwrite/enums/runtime.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ class Runtime(Enum):
PYTHON_3_12 = "python-3.12"
PYTHON_3_13 = "python-3.13"
PYTHON_3_14 = "python-3.14"
PYTHON_3_15 = "python-3.15"
PYTHON_ML_3_11 = "python-ml-3.11"
PYTHON_ML_3_12 = "python-ml-3.12"
PYTHON_ML_3_13 = "python-ml-3.13"
Expand All @@ -39,6 +40,7 @@ class Runtime(Enum):
DENO_2_0 = "deno-2.0"
DENO_2_5 = "deno-2.5"
DENO_2_6 = "deno-2.6"
DENO_2_9 = "deno-2.9"
DART_2_15 = "dart-2.15"
DART_2_16 = "dart-2.16"
DART_2_17 = "dart-2.17"
Expand Down Expand Up @@ -86,7 +88,9 @@ class Runtime(Enum):
GO_1_24 = "go-1.24"
GO_1_25 = "go-1.25"
GO_1_26 = "go-1.26"
GO_1_27 = "go-1.27"
RUST_1_83 = "rust-1.83"
RUST_1_99 = "rust-1.99"
STATIC_1 = "static-1"
FLUTTER_3_24 = "flutter-3.24"
FLUTTER_3_27 = "flutter-3.27"
Expand Down
15 changes: 15 additions & 0 deletions appwrite/enums/supabase_migration_resource.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
from enum import Enum


class SupabaseMigrationResource(Enum):
USER = "user"
DATABASE = "database"
TABLE = "table"
COLUMN = "column"
INDEX = "index"
ROW = "row"
DOCUMENT = "document"
ATTRIBUTE = "attribute"
COLLECTION = "collection"
BUCKET = "bucket"
FILE = "file"
Loading