Skip to main content

Introduction

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

Creating Actors

To create and run Actors through Apify Console, see the Console documentation.

To create and run Python Actors locally, check the documentation for how to create and run Python Actors locally.

Guides

To see how you can integrate the Apify SDK with some of the most popular web scraping libraries, see our guides for working with Requests or HTTPX, Beautiful Soup, Playwright, Selenium, or Scrapy.

Usage concepts

To learn more about the features of the Apify SDK and how to use them, check out the Usage Concepts section in the sidebar, especially the guides for the Actor lifecycle, working with storages, handling Actor events, and how to use proxies.

Installing the Apify SDK separately

When you create an Actor using the Apify CLI, the Apify SDK for Python is installed for you automatically. If you want to install it separately, you can install it from its PyPI listing:

pip install apify

If you are not developing Apify Actors and you just need to access the Apify API from Python, consider using the Apify API client for Python directly.