Skip to main content
Version: 1.7

Overview

The Apify SDK for Python is the official library for creating Apify Actors in Python.

from apify import Actor
from bs4 import BeautifulSoup
import requests

async def main():
async with Actor:
actor_input = await Actor.get_input()
response = requests.get(actor_input['url'])
soup = BeautifulSoup(response.content, 'html.parser')
await Actor.push_data({ 'url': actor_input['url'], 'title': soup.title.string })

What are Actors?

Actors are serverless cloud programs that can do almost anything a human can do in a web browser. They can do anything from small tasks such as filling in forms or unsubscribing from online services, all the way up to scraping and processing vast numbers of web pages.

Actors can be run either locally, or on the Apify platform, where you can run them at scale, monitor them, schedule them, and even publish and monetize them.

If you're new to Apify, learn what is Apify in the Apify platform documentation.

Quick start

To create and run Actors through Apify Console, see the Console documentation. For creating and running Python Actors locally, refer to the quick start guide.

Explore the Guides section in the sidebar for a deeper understanding of the SDK's features and best practices.

Installation

The Apify SDK for Python requires Python version 3.8 or above. It is typically installed when you create a new Actor project using the Apify CLI. To install it manually in an existing project, use:

pip install apify
API client alternative

If you need to interact with the Apify API programmatically without creating Actors, use the Apify API client for Python instead.