ApifyWrapper#
- class langchain_community.utilities.apify.ApifyWrapper[source]#
Bases:
BaseModel
Wrapper around Apify. To use, you should have the
apify-client
python package installed, and the environment variableAPIFY_API_TOKEN
set with your API key, or pass apify_api_token as a named parameter to the constructor.Create a new model by parsing and validating input data from keyword arguments.
Raises ValidationError if the input data cannot be parsed to form a valid model.
- param apify_api_token: str | None = None#
- param apify_client: Any = None#
- param apify_client_async: Any = None#
- async acall_actor(actor_id: str, run_input: Dict, dataset_mapping_function: Callable[[Dict], Document], *, build: str | None = None, memory_mbytes: int | None = None, timeout_secs: int | None = None) ApifyDatasetLoader [source]#
Run an Actor on the Apify platform and wait for results to be ready. :param actor_id: The ID or name of the Actor on the Apify platform. :type actor_id: str :param run_input: The input object of the Actor that youβre trying to run. :type run_input: Dict :param dataset_mapping_function: A function that takes a single
dictionary (an Apify dataset item) and converts it to an instance of the Document class.
- Parameters:
build (str, optional) β Optionally specifies the actor build to run. It can be either a build tag or build number.
memory_mbytes (int, optional) β Optional memory limit for the run, in megabytes.
timeout_secs (int, optional) β Optional timeout for the run, in seconds.
actor_id (str) β
run_input (Dict) β
dataset_mapping_function (Callable) β
- Returns:
- A loader that will fetch the records from the
Actor runβs default dataset.
- Return type:
- async acall_actor_task(task_id: str, task_input: Dict, dataset_mapping_function: Callable[[Dict], Document], *, build: str | None = None, memory_mbytes: int | None = None, timeout_secs: int | None = None) ApifyDatasetLoader [source]#
Run a saved Actor task on Apify and wait for results to be ready. :param task_id: The ID or name of the task on the Apify platform. :type task_id: str :param task_input: The input object of the task that youβre trying to run.
Overrides the taskβs saved input.
- Parameters:
dataset_mapping_function (Callable) β A function that takes a single dictionary (an Apify dataset item) and converts it to an instance of the Document class.
build (str, optional) β Optionally specifies the actor build to run. It can be either a build tag or build number.
memory_mbytes (int, optional) β Optional memory limit for the run, in megabytes.
timeout_secs (int, optional) β Optional timeout for the run, in seconds.
task_id (str) β
task_input (Dict) β
- Returns:
- A loader that will fetch the records from the
task runβs default dataset.
- Return type:
- call_actor(actor_id: str, run_input: Dict, dataset_mapping_function: Callable[[Dict], Document], *, build: str | None = None, memory_mbytes: int | None = None, timeout_secs: int | None = None) ApifyDatasetLoader [source]#
Run an Actor on the Apify platform and wait for results to be ready. :param actor_id: The ID or name of the Actor on the Apify platform. :type actor_id: str :param run_input: The input object of the Actor that youβre trying to run. :type run_input: Dict :param dataset_mapping_function: A function that takes a single
dictionary (an Apify dataset item) and converts it to an instance of the Document class.
- Parameters:
build (str, optional) β Optionally specifies the actor build to run. It can be either a build tag or build number.
memory_mbytes (int, optional) β Optional memory limit for the run, in megabytes.
timeout_secs (int, optional) β Optional timeout for the run, in seconds.
actor_id (str) β
run_input (Dict) β
dataset_mapping_function (Callable) β
- Returns:
- A loader that will fetch the records from the
Actor runβs default dataset.
- Return type:
- call_actor_task(task_id: str, task_input: Dict, dataset_mapping_function: Callable[[Dict], Document], *, build: str | None = None, memory_mbytes: int | None = None, timeout_secs: int | None = None) ApifyDatasetLoader [source]#
Run a saved Actor task on Apify and wait for results to be ready. :param task_id: The ID or name of the task on the Apify platform. :type task_id: str :param task_input: The input object of the task that youβre trying to run.
Overrides the taskβs saved input.
- Parameters:
dataset_mapping_function (Callable) β A function that takes a single dictionary (an Apify dataset item) and converts it to an instance of the Document class.
build (str, optional) β Optionally specifies the actor build to run. It can be either a build tag or build number.
memory_mbytes (int, optional) β Optional memory limit for the run, in megabytes.
timeout_secs (int, optional) β Optional timeout for the run, in seconds.
task_id (str) β
task_input (Dict) β
- Returns:
- A loader that will fetch the records from the
task runβs default dataset.
- Return type:
Examples using ApifyWrapper