Skip to content

Commit 82c7f74

Browse files
docs: restructure documentation with separate introduction section
Reorganize documentation structure by splitting the overview into three distinct pages: - Introduction: SDK overview and features - Installation: Setup and dependency management - Quick start: Creating and running Actors Also reorganize sections by renaming and moving files: - Move webserver guide from concepts to guides section - Renumber concept pages to maintain proper ordering - Update sidebar configuration to reflect new structure Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
1 parent cad8381 commit 82c7f74

22 files changed

+124
-75
lines changed
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

docs/01_introduction/index.mdx

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
---
2+
id: overview
3+
title: Introduction
4+
sidebar_label: Introduction
5+
description: 'The official library for creating Apify Actors in Python, providing tools for web scraping, automation, and data storage integration.'
6+
---
7+
8+
The Apify SDK for Python is the official library for creating [Apify Actors](https://docs.apify.com/platform/actors) in Python.
9+
10+
It provides tools and classes for web scraping and automation, allowing you to manage Actor lifecycles, handle data storage, work with proxies, and integrate with popular Python libraries.
11+
12+
## Example
13+
14+
Here's a simple example of an Actor that scrapes a web page and stores the result:
15+
16+
```py
17+
from apify import Actor
18+
from bs4 import BeautifulSoup
19+
import requests
20+
21+
async def main():
22+
async with Actor:
23+
input = await Actor.get_input()
24+
response = requests.get(input['url'])
25+
soup = BeautifulSoup(response.content, 'html.parser')
26+
await Actor.push_data({ 'url': input['url'], 'title': soup.title.string })
27+
```
28+
29+
## Features
30+
31+
The Apify SDK for Python provides:
32+
33+
- **Actor lifecycle management** - Handle initialization, teardown, and graceful shutdowns
34+
- **Storage management** - Work with Datasets, Key-Value Stores, and Request Queues
35+
- **Event handling** - Respond to Actor events like migration, abort, and system info
36+
- **Proxy management** - Rotate and manage proxies for web scraping
37+
- **Platform integration** - Interact with other Actors, webhooks, and the Apify API
38+
- **Framework compatibility** - Integrate with BeautifulSoup, Playwright, Selenium, Scrapy, and Crawlee
39+
40+
## Next steps
41+
42+
- **[Installation](./installation)** - Install the SDK and set up your development environment
43+
- **[Quick start](./quick-start)** - Create and run your first Actor
44+
- **[Concepts](../concepts/actor-lifecycle)** - Learn about core SDK concepts
45+
- **[Guides](../guides/beautiful-soup)** - See how to integrate with popular libraries
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
---
2+
title: Installation
3+
sidebar_label: Installation
4+
description: 'Learn how to install the Apify SDK for Python using pip and manage dependencies for your Actor projects.'
5+
---
6+
7+
import Tabs from '@theme/Tabs';
8+
import TabItem from '@theme/TabItem';
9+
import CodeBlock from '@theme/CodeBlock';
10+
11+
## Requirements
12+
13+
The Apify SDK requires Python version 3.10 or above to run Python Actors locally.
14+
15+
## Installation
16+
17+
The Apify Python SDK is available as [`apify`](https://pypi.org/project/apify/) package on PyPi. To install it, run:
18+
19+
```bash
20+
pip install apify
21+
```
22+
23+
When you create an Actor using the Apify CLI, the Apify SDK for Python is installed for you automatically.
24+
25+
If you are not developing Apify Actors and you just need to access the Apify API from Python,
26+
consider using the [Apify API client for Python](/api/client/python) directly.
27+
28+
## Adding dependencies
29+
30+
First, add the dependencies in the [`requirements.txt`](https://pip.pypa.io/en/stable/reference/requirements-file-format/) file in the Actor source folder.
31+
32+
Then activate the virtual environment in `.venv`:
33+
34+
<Tabs groupId="operating-systems">
35+
<TabItem value="unix" label="Linux / macOS" default>
36+
<CodeBlock language="bash">{
37+
`source .venv/bin/activate`
38+
}</CodeBlock>
39+
</TabItem>
40+
<TabItem value="win" label="Windows">
41+
<CodeBlock language="powershell">{
42+
`.venv\\Scripts\\activate`
43+
}</CodeBlock>
44+
</TabItem>
45+
</Tabs>
46+
47+
Finally, install the dependencies:
48+
49+
```bash
50+
python -m pip install -r requirements.txt
51+
```
Lines changed: 11 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,18 @@
11
---
2-
title: Overview
3-
sidebar_label: Overview
2+
title: Quick start
3+
sidebar_label: Quick start
4+
description: 'Get started with the Apify SDK for Python by creating your first Actor and learning the basics.'
5+
---
6+
7+
Learn how to create and run Actors using the Apify SDK for Python.
8+
49
---
510

611
import Tabs from '@theme/Tabs';
712
import TabItem from '@theme/TabItem';
813
import CodeBlock from '@theme/CodeBlock';
914

10-
The Apify SDK for Python is the official library for creating [Apify Actors](https://docs.apify.com/platform/actors) in Python.
11-
12-
```py
13-
from apify import Actor
14-
from bs4 import BeautifulSoup
15-
import requests
16-
17-
async def main():
18-
async with Actor:
19-
input = await Actor.get_input()
20-
response = requests.get(input['url'])
21-
soup = BeautifulSoup(response.content, 'html.parser')
22-
await Actor.push_data({ 'url': input['url'], 'title': soup.title.string })
23-
```
24-
25-
## Requirements
26-
27-
The Apify SDK requires Python version 3.10 or above to run Python Actors locally.
28-
29-
## Installation
30-
31-
The Apify Python SDK is available as [`apify`](https://pypi.org/project/apify/) package on PyPi. To install it, run:
32-
33-
```bash
34-
pip install apify
35-
```
36-
37-
When you create an Actor using the Apify CLI, the Apify SDK for Python is installed for you automatically.
38-
39-
If you are not developing Apify Actors and you just need to access the Apify API from Python,
40-
consider using the [Apify API client for Python](/api/client/python) directly.
41-
42-
## Quick start
43-
44-
### Creating Actors
15+
## Step 1: Creating Actors
4516

4617
To create and run Actors in Apify Console, refer to the [Console documentation](/platform/actors/development/quick-start/web-ide).
4718

@@ -55,9 +26,9 @@ apify create my-first-actor --template python-start
5526

5627
This will create a new folder called `my-first-actor`, download and extract the "Getting started with Python" Actor template there, create a virtual environment in `my-first-actor/.venv`, and install the Actor dependencies in it.
5728

58-
![actor create command run](../01_overview/images/apify-create.gif)
29+
![actor create command run](./images/apify-create.gif)
5930

60-
#### Running the Actor
31+
## Step 2: Running the Actor
6132

6233
To run the Actor, you can use the [`apify run` command](/cli/docs/reference#apify-run):
6334

@@ -74,7 +45,7 @@ This command:
7445

7546
The Actor input, for example, will be in `storage/key_value_stores/default/INPUT.json`.
7647

77-
## Actor structure
48+
## Step 3: Understanding Actor structure
7849

7950
All Python Actor templates follow the same structure.
8051

@@ -122,31 +93,6 @@ asyncio.run(main())`
12293
If you want to modify the Actor structure, you need to make sure that your Actor is executable as a module, via `python -m src`, as that is the command started by `apify run` in the Apify CLI.
12394
We recommend keeping the entrypoint for the Actor in the `src/__main__.py` file.
12495

125-
## Adding dependencies
126-
127-
First, add the dependencies in the [`requirements.txt`](https://pip.pypa.io/en/stable/reference/requirements-file-format/) file in the Actor source folder.
128-
129-
Then activate the virtual environment in `.venv`:
130-
131-
<Tabs groupId="operating-systems">
132-
<TabItem value="unix" label="Linux / macOS" default>
133-
<CodeBlock language="bash">{
134-
`source .venv/bin/activate`
135-
}</CodeBlock>
136-
</TabItem>
137-
<TabItem value="win" label="Windows">
138-
<CodeBlock language="powershell">{
139-
`.venv\\Scripts\\activate`
140-
}</CodeBlock>
141-
</TabItem>
142-
</Tabs>
143-
144-
Finally, install the dependencies:
145-
146-
```bash
147-
python -m pip install -r requirements.txt
148-
```
149-
15096
## Next steps
15197

15298
### Guides
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@ title: Logging
55

66
import RunnableCodeBlock from '@site/src/components/RunnableCodeBlock';
77

8-
import LogConfigExample from '!!raw-loader!roa-loader!./code/10_log_config.py';
9-
import LoggerUsageExample from '!!raw-loader!roa-loader!./code/10_logger_usage.py';
10-
import RedirectLog from '!!raw-loader!roa-loader!./code/10_redirect_log.py';
11-
import RedirectLogExistingRun from '!!raw-loader!roa-loader!./code/10_redirect_log_existing_run.py';
8+
import LogConfigExample from '!!raw-loader!roa-loader!./code/09_log_config.py';
9+
import LoggerUsageExample from '!!raw-loader!roa-loader!./code/09_logger_usage.py';
10+
import RedirectLog from '!!raw-loader!roa-loader!./code/09_redirect_log.py';
11+
import RedirectLogExistingRun from '!!raw-loader!roa-loader!./code/09_redirect_log_existing_run.py';
1212

1313
The Apify SDK is logging useful information through the [`logging`](https://docs.python.org/3/library/logging.html) module from Python's standard library, into the logger with the name `apify`.
1414

0 commit comments

Comments
 (0)