or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

Files

docs

actors.mdbuilds.mdindex.mdlogging.mdrequest-queues.mdruns.mdschedules.mdstorage.mdstore.mdtasks.mdusers.mdwebhooks.md

tasks.mddocs/

0

# Task Management

1

2

Task creation and management for reusable Actor configurations and scheduled executions. Tasks provide a way to save Actor configurations and inputs for repeated use.

3

4

## Capabilities

5

6

### Task Operations

7

8

```python { .api }

9

class TaskClient:

10

def get(self) -> dict | None:

11

"""Get task information."""

12

13

def update(self, **kwargs) -> dict:

14

"""Update task configuration.

15

16

Args:

17

name (str, optional): Task name

18

actor_id (str, optional): Associated Actor ID

19

input (dict, optional): Default task input

20

options (dict, optional): Task execution options

21

**kwargs: Additional task parameters

22

"""

23

24

def delete(self) -> None:

25

"""Delete task."""

26

27

def start(self, **kwargs) -> dict:

28

"""Start task and return run object.

29

30

Args:

31

build (str, optional): Build to use

32

memory (int, optional): Memory allocation

33

timeout (int, optional): Timeout in seconds

34

**kwargs: Additional run parameters

35

"""

36

37

def call(self, **kwargs) -> dict | None:

38

"""Start task and wait for completion.

39

40

Args:

41

wait_secs (int, optional): Maximum wait time

42

**kwargs: Parameters passed to start()

43

"""

44

45

def get_input(self) -> dict | None:

46

"""Get default task input."""

47

48

def update_input(self, *, task_input: dict) -> dict:

49

"""Update default task input.

50

51

Args:

52

task_input: New input configuration

53

"""

54

55

def runs(self) -> RunCollectionClient:

56

"""Get task runs collection."""

57

58

def last_run(self, **kwargs) -> RunClient:

59

"""Get last task run client.

60

61

Args:

62

status (str, optional): Filter by run status

63

origin (str, optional): Filter by run origin

64

"""

65

66

def webhooks(self) -> WebhookCollectionClient:

67

"""Get task webhooks collection."""

68

69

class TaskClientAsync:

70

"""Async version of TaskClient with identical methods."""

71

72

class TaskCollectionClient:

73

def list(

74

self,

75

*,

76

limit: int | None = None,

77

offset: int | None = None,

78

desc: bool | None = None

79

) -> ListPage[dict]:

80

"""List tasks.

81

82

Args:

83

limit: Maximum number of tasks

84

offset: Pagination offset

85

desc: Sort in descending order

86

"""

87

88

def create(self, **kwargs) -> dict:

89

"""Create new task.

90

91

Args:

92

actor_id (str): Actor ID to create task for

93

name (str): Task name

94

input (dict, optional): Default input

95

options (dict, optional): Task options

96

**kwargs: Additional task configuration

97

"""

98

99

class TaskCollectionClientAsync:

100

"""Async version of TaskCollectionClient with identical methods."""

101

```

102

103

## Usage Examples

104

105

```python

106

from apify_client import ApifyClient

107

108

client = ApifyClient('your-api-token')

109

110

# Create reusable task

111

task = client.tasks().create(

112

actor_id='web-scraper-actor-id',

113

name='Daily Website Scraping',

114

input={

115

'startUrls': ['https://example.com/products'],

116

'maxPages': 100,

117

'outputFormat': 'json'

118

},

119

options={

120

'build': 'latest',

121

'memory': 2048,

122

'timeout': 3600

123

}

124

)

125

126

# Execute task

127

task_client = client.task(task['id'])

128

run = task_client.call()

129

130

print(f"Task execution completed: {run['status']}")

131

```