Skip to content

Latest commit

 

History

History
74 lines (59 loc) · 3.64 KB

File metadata and controls

74 lines (59 loc) · 3.64 KB
id getting-started
title Getting started

import Tabs from '@theme/Tabs'; import TabItem from '@theme/TabItem'; import CodeBlock from '@theme/CodeBlock';

import UsageAsyncExample from '!!raw-loader!./code/01_usage_async.py'; import UsageSyncExample from '!!raw-loader!./code/01_usage_sync.py'; import InputAsyncExample from '!!raw-loader!./code/03_input_async.py'; import InputSyncExample from '!!raw-loader!./code/03_input_sync.py'; import DatasetAsyncExample from '!!raw-loader!./code/03_dataset_async.py'; import DatasetSyncExample from '!!raw-loader!./code/03_dataset_sync.py';

This guide will walk you through how to use the Apify Client for Python to run Actors on the Apify platform, provide input to them, and retrieve results from their datasets. You'll learn the basics of running serverless programs (we're calling them Actors) and managing their output efficiently.

Running your first Actor

To start an Actor, you need its ID (e.g., john-doe/my-cool-actor) and an API token. The Actor's ID is a combination of the username and the Actor owner's username. Use the ActorClient to run the Actor and wait for it to complete. You can run both your own Actors and Actors from Apify store.

{UsageAsyncExample} {UsageSyncExample}

Providing input to Actor

Actors often require input, such as URLs to scrape, search terms, or other configuration data. You can pass input as a JSON object when starting the Actor using the ActorClient.call method. Actors respect the input schema defined in the Actor's input schema.

{InputAsyncExample} {InputSyncExample}

Getting results from the dataset

To get the results from the dataset, you can use the DatasetClient (ApifyClient.dataset ) and DatasetClient.list_items method. You need to pass the dataset ID to define which dataset you want to access. You can get the dataset ID from the Actor's run dictionary (represented by defaultDatasetId).

{InputAsyncExample} {InputSyncExample}

:::note Dataset access

Running an Actor might take time, depending on the Actor's complexity and the amount of data it processes. If you want only to get data and have an immediate response you should access the existing dataset of the finished Actor run.

:::