_ActorType
Index
Constructors
Methods
- __call__
- abort
- add_webhook
- apify_client
- call
- call_task
- charge
- config
- configuration
- create_proxy_configuration
- event_manager
- exit
- fail
- get_charging_manager
- get_env
- get_input
- get_value
- init
- is_at_home
- log
- metamorph
- new_client
- off
- on
- open_dataset
- open_key_value_store
- open_request_queue
- push_data
- reboot
- set_status_message
- set_value
- start
Constructors
__init__
{"content": ["Create an Actor instance.\n\nNote that you don't have to do this, all the functionality is accessible using the default instance\n(e.g.
Actor.open_dataset()).\n", {"Parameters
configuration: Configuration | None = None
keyword-onlyconfigure_logging: bool = True
keyword-onlyexit_process: bool | None = None
Returns None
Methods
__call__
{"content": ["Make a new Actor instance with a non-default configuration."]}
Parameters
configuration: Configuration | None = None
keyword-onlyconfigure_logging: bool = True
keyword-onlyexit_process: bool | None = None
Returns Self
abort
{"content": ["Abort given Actor run on the Apify platform using the current user account.\n\nThe user account is determined by the
APIFY_TOKENenvironment variable.\n", {"Parameters
run_id: str
keyword-onlytoken: str | None = None
keyword-onlystatus_message: str | None = None
keyword-onlygracefully: bool | None = None
Returns ActorRun
add_webhook
{"content": ["Create an ad-hoc webhook for the current Actor run.\n\nThis webhook lets you receive a notification when the Actor run finished or failed.\n\nNote that webhooks are only supported for Actors running on the Apify platform. When running the Actor locally,\nthe function will print a warning and have no effect.\n\nFor more information about Apify Actor webhooks, please see the documentation.\n", {"
Parameters
webhook: Webhook
keyword-onlyignore_ssl_errors: bool | None = None
keyword-onlydo_not_retry: bool | None = None
keyword-onlyidempotency_key: str | None = None
Returns None
apify_client
{"content": ["The ApifyClientAsync instance the Actor instance uses."]}
Returns ApifyClientAsync
call
{"content": ["Start an Actor on the Apify Platform and wait for it to finish before returning.\n\nIt waits indefinitely, unless the wait argument is provided.\n", {"
Parameters
actor_id: str
run_input: Any = None
keyword-onlytoken: str | None = None
keyword-onlycontent_type: str | None = None
keyword-onlybuild: str | None = None
keyword-onlymemory_mbytes: int | None = None
keyword-onlytimeout: timedelta | None | Literal['RemainingTime'] = None
keyword-onlywebhooks: list[Webhook] | None = None
keyword-onlywait: timedelta | None = None
keyword-onlylogger: logging.Logger | None | Literal['default'] = 'default'
Returns ActorRun | None
call_task
{"content": ["Start an Actor task on the Apify Platform and wait for it to finish before returning.\n\nIt waits indefinitely, unless the wait argument is provided.\n\nNote that an Actor task is a saved input configuration and options for an Actor. If you want to run an Actor\ndirectly rather than an Actor task, please use the
Actor.call\n", {"Parameters
task_id: str
task_input: dict | None = None
keyword-onlybuild: str | None = None
keyword-onlymemory_mbytes: int | None = None
keyword-onlytimeout: timedelta | None = None
keyword-onlywebhooks: list[Webhook] | None = None
keyword-onlywait: timedelta | None = None
keyword-onlytoken: str | None = None
Returns ActorRun | None
charge
{"content": ["Charge for a specified number of events - sub-operations of the Actor.\n\nThis is relevant only for the pay-per-event pricing model.\n", {"
Parameters
event_name: str
count: int = 1
Returns ChargeResult
config
{"content": ["The Configuration instance the Actor instance uses."]}
Returns Configuration
configuration
{"content": ["The Configuration instance the Actor instance uses."]}
Returns Configuration
create_proxy_configuration
{"content": ["Create a ProxyConfiguration object with the passed proxy configuration.\n\nConfigures connection to a proxy server with the provided options. Proxy servers are used to prevent target\nwebsites from blocking your crawlers based on IP address rate limits or blacklists.\n\nFor more details and code examples, see the
ProxyConfigurationclass.\n", {"Parameters
keyword-onlyactor_proxy_input: dict | None = None
keyword-onlypassword: str | None = None
keyword-onlygroups: list[str] | None = None
keyword-onlycountry_code: str | None = None
keyword-onlyproxy_urls: list[str | None] | None = None
keyword-onlynew_url_function: _NewUrlFunction | None = None
Returns ProxyConfiguration | None
event_manager
{"content": ["The EventManager instance the Actor instance uses."]}
Returns EventManager
exit
{"content": ["Exit the Actor instance.\n\nThis stops the Actor instance. It cancels all the intervals for regularly sending
PERSIST_STATEevents,\nsends a finalPERSIST_STATEevent, waits for all the event listeners to finish, and stops the event manager.\n", {"Parameters
keyword-onlyexit_code: int = 0
keyword-onlyevent_listeners_timeout: timedelta | None = EVENT_LISTENERS_TIMEOUT
keyword-onlystatus_message: str | None = None
keyword-onlycleanup_timeout: timedelta = timedelta(seconds=30)
Returns None
fail
{"content": ["Fail the Actor instance.\n\nThis performs all the same steps as Actor.exit(), but it additionally sets the exit code to
1(by default).\n", {"Parameters
keyword-onlyexit_code: int = 1
keyword-onlyexception: BaseException | None = None
keyword-onlystatus_message: str | None = None
Returns None
get_charging_manager
{"content": ["Retrieve the charging manager to access granular pricing information."]}
Returns ChargingManager
get_env
{"content": ["Return a dictionary with information parsed from all the
APIFY_XXXenvironment variables.\n\nFor a list of all the environment variables, see the\nActor documentation. If some variables\nare not defined or are invalid, the corresponding value in the resulting dictionary will be None."]}Returns dict
get_input
{"content": ["Get the Actor input value from the default key-value store associated with the current Actor run."]}
Returns Any
get_value
{"content": ["Get a value from the default key-value store associated with the current Actor run.\n", {"
Parameters
key: str
default_value: Any = None
Returns Any
init
{"content": ["Initialize the Actor instance.\n\nThis initializes the Actor instance. It configures the right storage client based on whether the Actor is\nrunning locally or on the Apify platform, it initializes the event manager for processing Actor events,\nand starts an interval for regularly sending
PERSIST_STATEevents, so that the Actor can regularly persist\nits state in response to these events.\n\nThis method should be called immediately before performing any additional Actor actions, and it should be\ncalled only once."]}Returns None
is_at_home
{"content": ["Return
Truewhen the Actor is running on the Apify platform, andFalseotherwise (e.g. local run)."]}Returns bool
log
{"content": ["The logging.Logger instance the Actor uses."]}
Returns logging.Logger
metamorph
{"content": ["Transform this Actor run to an Actor run of a different Actor.\n\nThe platform stops the current Actor container and starts a new container with the new Actor instead. All\nthe default storages are preserved, and the new input is stored under the
INPUT-METAMORPH-1key in the same\ndefault key-value store.\n", {"Parameters
target_actor_id: str
run_input: Any = None
keyword-onlytarget_actor_build: str | None = None
keyword-onlycontent_type: str | None = None
keyword-onlycustom_after_sleep: timedelta | None = None
Returns None
new_client
{"content": ["Return a new instance of the Apify API client.\n\nThe
ApifyClientAsyncclass is provided by the apify-client\npackage, and it is automatically configured using theAPIFY_API_BASE_URLandAPIFY_TOKENenvironment\nvariables.\n\nYou can override the token via the available options. That's useful if you want to use the client\nas a different Apify user than the SDK internals are using.\n", {"Parameters
keyword-onlytoken: str | None = None
keyword-onlyapi_url: str | None = None
keyword-onlymax_retries: int | None = None
keyword-onlymin_delay_between_retries: timedelta | None = None
keyword-onlytimeout: timedelta | None = None
Returns ApifyClientAsync
off
{"content": ["Remove a listener, or all listeners, from an Actor event.\n", {"
Parameters
event_name: Event
listener: Callable | None = None
Returns None
on
{"content": ["Add an event listener to the Actor's event manager.\n\nThe following events can be emitted:\n\n-
Event.SYSTEM_INFO: Emitted every minute; the event data contains information about the Actor's resource\nusage.\n\n-Event.MIGRATING: Emitted when the Actor on the Apify platform is about to be migrated to another worker\nserver. Use this event to persist the Actor's state and gracefully stop in-progress tasks, preventing\ndisruption.\n\n-Event.PERSIST_STATE: Emitted regularly (default: 60 seconds) to notify the Actor to persist its state,\npreventing work repetition after a restart. This event is emitted together with theMIGRATINGevent, where\ntheisMigratingflag in the event data isTrue; otherwise, the flag isFalse. This event is for\nconvenience; the same effect can be achieved by setting an interval and listening for theMIGRATINGevent.\n\n-Event.ABORTING: Emitted when a user aborts an Actor run on the Apify platform, allowing the Actor time\nto clean up its state if the abort is graceful.\n", {"Parameters
event_name: Event
listener: EventListener[Any]
Returns EventListener[Any]
open_dataset
{"content": ["Open a dataset.\n\nDatasets are used to store structured data where each object stored has the same attributes, such as online\nstore products or real estate offers. The actual data is stored either on the local filesystem or in\nthe Apify cloud.\n", {"
Parameters
keyword-onlyid: str | None = None
keyword-onlyname: str | None = None
keyword-onlyforce_cloud: bool = False
Returns Dataset
open_key_value_store
{"content": ["Open a key-value store.\n\nKey-value stores are used to store records or files, along with their MIME content type. The records are stored\nand retrieved using a unique key. The actual data is stored either on a local filesystem or in the Apify cloud.\n", {"
Parameters
keyword-onlyid: str | None = None
keyword-onlyname: str | None = None
keyword-onlyforce_cloud: bool = False
Returns KeyValueStore
open_request_queue
{"content": ["Open a request queue.\n\nRequest queue represents a queue of URLs to crawl, which is stored either on local filesystem or in\nthe Apify cloud. The queue is used for deep crawling of websites, where you start with several URLs and then\nrecursively follow links to other pages. The data structure supports both breadth-first and depth-first\ncrawling orders.\n", {"
Parameters
keyword-onlyid: str | None = None
keyword-onlyname: str | None = None
keyword-onlyforce_cloud: bool = False
Returns RequestQueue
push_data
{"content": ["Store an object or a list of objects to the default dataset of the current Actor run.\n", {"
Parameters
data: dict | list[dict]
charged_event_name: str | None = None
Returns ChargeResult | None
reboot
{"content": ["Internally reboot this Actor.\n\nThe system stops the current container and starts a new one, with the same run ID and default storages.\n", {"
Parameters
keyword-onlyevent_listeners_timeout: timedelta | None = EVENT_LISTENERS_TIMEOUT
keyword-onlycustom_after_sleep: timedelta | None = None
Returns None
set_status_message
{"content": ["Set the status message for the current Actor run.\n", {"
Parameters
status_message: str
keyword-onlyis_terminal: bool | None = None
Returns ActorRun | None
set_value
{"content": ["Set or delete a value in the default key-value store associated with the current Actor run.\n", {"
Parameters
key: str
value: Any
keyword-onlycontent_type: str | None = None
Returns None
start
{"content": ["Run an Actor on the Apify platform.\n\nUnlike
Actor.call, this method just starts the run without waiting for finish.\n", {"Parameters
actor_id: str
run_input: Any = None
keyword-onlytoken: str | None = None
keyword-onlycontent_type: str | None = None
keyword-onlybuild: str | None = None
keyword-onlymemory_mbytes: int | None = None
keyword-onlytimeout: timedelta | None | Literal['RemainingTime'] = None
keyword-onlywait_for_finish: int | None = None
keyword-onlywebhooks: list[Webhook] | None = None
Returns ActorRun
{"content": ["The class of
Actor. Only make a new instance if you're absolutely sure you need to."]}