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: docs/04_upgrading/upgrading_to_v4.md
+72-2Lines changed: 72 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,8 +4,78 @@ title: Upgrading to v4
4
4
description: Breaking changes and migration guide from Apify SDK v3.x to v4.0.
5
5
---
6
6
7
-
This guide lists the breaking changes between Apify Python SDK v3.x and v4.0.
7
+
This page summarizes the breaking changes between Apify Python SDK v3.x and v4.0.
8
8
9
9
## Python 3.11+ required
10
10
11
-
Support for Python 3.10 has been dropped. The Apify Python SDK v4.x now requires Python 3.11 or later — make sure your environment is on a compatible version before upgrading.
11
+
Support for Python 3.10 has been dropped. Apify Python SDK v4.x requires Python 3.11 or later.
12
+
13
+
## `apify-client` v3 required
14
+
15
+
The SDK is now built on `apify-client` v3 and no longer depends on `apify-shared`. Three changes are user-visible:
16
+
17
+
-`Actor.start`, `Actor.call`, `Actor.call_task`, and `Actor.metamorph` return `apify_client._models.Run` instead of the SDK-side `ActorRun`. The shape is equivalent — only the import path changes.
18
+
-`apify.WebhookEventType` is now a `Literal[...]` instead of a `StrEnum`. Use plain string values (`'ACTOR.RUN.FAILED'`) instead of enum members.
19
+
-`apify_shared.consts.ActorEventTypes` (a `StrEnum`) is replaced by `apify.ActorEventTypes`, now a `Literal['systemInfo', 'persistState', 'migrating', 'aborting']`. For runtime values, use `apify.Event` (re-exported from Crawlee) instead of enum members.
20
+
21
+
**Before (v3.x):**
22
+
23
+
```python
24
+
from apify import Actor
25
+
from apify_shared.consts import ActorEventTypes
26
+
27
+
Actor.on(ActorEventTypes.SYSTEM_INFO, callback)
28
+
```
29
+
30
+
**Now (v4.0):**
31
+
32
+
```python
33
+
from apify import Actor, Event
34
+
35
+
Actor.on(Event.SYSTEM_INFO, callback)
36
+
```
37
+
38
+
## `Webhook` API simplified
39
+
40
+
The `Webhook` model has been slimmed down to only the fields a user sets when defining a webhook. Server-populated response fields (`id`, `created_at`, `modified_at`, `user_id`, `is_ad_hoc`, `condition`, `last_dispatch`, `stats`) and the unused `WebhookCondition` helper class have been removed. `Webhook` is now a plain `@dataclass` instead of a Pydantic `BaseModel` — construct it with snake_case kwargs; `.model_dump()` / `.model_validate()` are gone.
41
+
42
+
The retry and idempotency kwargs that used to live on `Actor.add_webhook` have moved onto the `Webhook` instance itself.
The `idempotency_key` kwarg form on `Actor.add_webhook` still works for one more release but emits a `DeprecationWarning` and will be removed in v5.0. The `ignore_ssl_errors` and `do_not_retry` kwargs have been removed outright — set them on the `Webhook` instance.
74
+
75
+
`apify.WebhookCondition` is no longer exported; the SDK now binds the webhook to the current Actor run internally.
76
+
77
+
The `webhooks` argument on `Actor.start`, `Actor.call`, and `Actor.call_task` still accepts `list[Webhook]` and the fields used at the call site (`event_types`, `request_url`, `payload_template`, `headers_template`) are unchanged.
78
+
79
+
## `Actor.new_client` — `timeout` scales all tiers
80
+
81
+
`apify-client` v3 split its single timeout into four tiers (short / medium / long / max). `Actor.new_client(timeout=...)` still takes a single `timedelta`; the SDK uses it as the medium-tier baseline and scales the other tiers proportionally (short = `timeout / 6`, long = `timeout * 12`, max = `timeout * 24`). The public signature is unchanged — no migration needed.
0 commit comments