Skip to content

Commit 8a345bd

Browse files
docs: Restructure documentation with separate introduction section (#771)
## Summary Re-applies the documentation restructuring from #740 (which was reverted in #763). - Split the monolithic overview page into three focused pages: Introduction, Installation, and Quick start - Reorganized documentation structure by moving webserver guide from concepts to guides section - Renumbered concept pages to maintain proper ordering after moving webserver content - Updated sidebar configuration to create a dedicated Introduction category - Updated redirect on landing page to point to `/docs/introduction`
1 parent ea1f52b commit 8a345bd

24 files changed

Lines changed: 76 additions & 77 deletions

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ To create and run Actors through Apify Console,
159159
see the [Console documentation](https://docs.apify.com/academy/getting-started/creating-actors#choose-your-template).
160160

161161
To create and run Python Actors locally, check the documentation for
162-
[how to create and run Python Actors locally](https://docs.apify.com/sdk/python/docs/overview/running-locally).
162+
[how to create and run Python Actors locally](https://docs.apify.com/sdk/python/docs/quick-start).
163163

164164
## Guides
165165

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: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
---
2+
id: introduction
3+
title: Overview
4+
sidebar_label: Overview
5+
slug: /overview
6+
description: 'The official library for creating Apify Actors in Python, providing tools for web scraping, automation, and data storage integration.'
7+
---
8+
9+
The Apify SDK for Python is the official library for creating [Apify Actors](https://docs.apify.com/platform/actors) in Python. It provides useful features like Actor lifecycle management, local storage emulation, and Actor event handling.
10+
11+
```python
12+
from apify import Actor
13+
from bs4 import BeautifulSoup
14+
import requests
15+
16+
async def main():
17+
async with Actor:
18+
input = await Actor.get_input()
19+
response = requests.get(input['url'])
20+
soup = BeautifulSoup(response.content, 'html.parser')
21+
await Actor.push_data({ 'url': input['url'], 'title': soup.title.string })
22+
```
23+
24+
## What are Actors
25+
26+
Actors are serverless cloud programs capable of performing tasks in a web browser, similar to what a human can do. These tasks can range from simple operations, such as filling out forms or unsubscribing from services, to complex jobs like scraping and processing large numbers of web pages.
27+
28+
Actors can be executed locally or on the [Apify platform](https://docs.apify.com/platform). The Apify platform lets you run Actors at scale and provides features for monitoring, scheduling, publishing, and monetizing them.
29+
30+
## Quick start
31+
32+
To create and run Actors using Apify Console, check out [Apify Console documentation](https://docs.apify.com/platform/console). For creating and running Python Actors locally, refer to the [quick start guide](./quick-start).
33+
34+
Explore the Guides section in the sidebar for a deeper understanding of the SDK's features and best practices.
35+
36+
## Installation
37+
38+
The Apify SDK for Python requires Python version 3.10 or above. It is typically installed when you create a new Actor project using the [Apify CLI](https://docs.apify.com/cli). To install it manually in an existing project, use:
39+
40+
```bash
41+
pip install apify
42+
```
43+
44+
:::note API client alternative
45+
46+
If you need to interact with the Apify API programmatically without creating Actors, use the [Apify API client for Python](https://docs.apify.com/api/client/python) instead.
47+
48+
:::
Lines changed: 12 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,19 @@
11
---
2-
title: Overview
3-
sidebar_label: Overview
2+
id: quick-start
3+
title: Quick start
4+
sidebar_label: Quick start
5+
description: 'Get started with the Apify SDK for Python by creating your first Actor and learning the basics.'
6+
---
7+
8+
Learn how to create and run Actors using the Apify SDK for Python.
9+
410
---
511

612
import Tabs from '@theme/Tabs';
713
import TabItem from '@theme/TabItem';
814
import CodeBlock from '@theme/CodeBlock';
915

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
16+
## Step 1: Create Actors
4517

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

@@ -55,9 +27,9 @@ apify create my-first-actor --template python-start
5527

5628
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.
5729

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

60-
#### Running the Actor
32+
## Step 2: Run Actors
6133

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

@@ -74,7 +46,7 @@ This command:
7446

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

77-
## Actor structure
49+
## Step 3: Understand Actor structure
7850

7951
All Python Actor templates follow the same structure.
8052

@@ -122,31 +94,6 @@ asyncio.run(main())`
12294
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.
12395
We recommend keeping the entrypoint for the Actor in the `src/__main__.py` file.
12496

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-
15097
## Next steps
15198

15299
### 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)