Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 0 additions & 26 deletions docs/01_overview/01_introduction.mdx

This file was deleted.

71 changes: 0 additions & 71 deletions docs/01_overview/02_setting_up.mdx

This file was deleted.

74 changes: 0 additions & 74 deletions docs/01_overview/03_getting_started.mdx

This file was deleted.

156 changes: 156 additions & 0 deletions docs/01_overview/index.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,156 @@
---
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same issue. Can the overview page be brought one level up? Overview page under an overview section is kinda weird UX

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

donezo

id: overview
title: Overview
---

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

import AuthAsyncExample from '!!raw-loader!./code/02_auth_async.py';
import AuthSyncExample from '!!raw-loader!./code/02_auth_sync.py';
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';

## Introduction

The [Apify client for Python](https://github.com/apify/apify-client-python) is the official library to access the [Apify REST API](/api/v2) from your Python applications. It provides useful features like automatic retries and convenience functions that improve the experience of using the Apify API.

Key features:

- Synchronous and asynchronous interfaces for flexible integration
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MInor: For integration of what, where? I'd consider specifying.

- Automatic retries for improved reliability
- JSON encoding with UTF-8 for all requests and responses
- Comprehensive API coverage for [Actors](/platform/actors), [datasets](/platform/storage/dataset), [key-value stores](/platform/storage/key-value-store), and more

## Prerequisites

Before installing the Apify client, ensure your system meets the following requirements:

- _An Apify account_
- _Python 3.10 or higher_: You can download Python from the [official website](https://www.python.org/downloads/).
- _Python package manager_: While this guide uses [pip](https://pip.pypa.io/en/stable/), you can also use any package manager you want.

To verify that Python and pip are installed, run the following commands:

```sh
python --version
```

```sh
pip --version
```

If these commands return the respective versions, you're ready to continue.
Comment on lines +44 to +48
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you actually need to check the version of pip, or do you only need to check that it's correctly configured?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think in this case it's just to be more explicit. since you need a package manager we want users to check that they actually have it.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is written one block above; it is for the verification that Python and pip are installed.


## Installation

The Apify client is available as the [`apify-client`](https://pypi.org/project/apify-client/) package on PyPI. To install it, run:

```sh
pip install apify-client
```

After installation, verify that the client is installed correctly by checking its version:

```sh
python -c 'import apify_client; print(apify_client.__version__)'
```

## Authentication and initialization

To use the client, you need an [API token](/platform/integrations/api#api-token). You can find your token under the [Integrations](https://console.apify.com/account/integrations) tab in Apify Console. Copy the token and initialize the client by providing it as a parameter to the `ApifyClient` constructor.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe add "Have an Apify account" to prereqs? It sounds basic, but you actually do need it :D


<Tabs>
<TabItem value="AsyncExample" label="Async client" default>
<CodeBlock className="language-python">
{AuthAsyncExample}
</CodeBlock>
</TabItem>
<TabItem value="SyncExample" label="Sync client">
<CodeBlock className="language-python">
{AuthSyncExample}
</CodeBlock>
</TabItem>
</Tabs>

:::warning Secure access

The API token is used to authorize your requests to the Apify API. You can be charged for the usage of the underlying services, so do not share your API token with untrusted parties or expose it on the client side of your applications.

:::

## Quick start
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just note that we have these quick start sections in overview pages, but ideally over time it would be good to have stand alone quick start pages in all JS, Python Clients/SDKs, and have overview just a really quick overview of the tool

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but that defeats the purpose of what we did, does it not? We had separate quick start (and other pages) and we merge them into one overview, only to later, divide them again into overview and quick start?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But it does not make sense imho, even after the discussion about our KR, where we specifically mentioned that we want to have each page designed for "one purpose".

Maybe we should have some discussion about the general structure of these documentation to prevent these misunderstandings. For example, in the CLI we have Overview, Installation, and Quick Start. I think this work very good as each page has clear purpose.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No no, that makes sense to me in the long run. Do you want us to move quick start to separate page as part of this PR or separate issue and we can move forward how it is now?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nono, let's keep it as it is now. I do not want to block this we want to remove the landing pages. It was more "once we start to work on the redesign", probably in Q2 :D


Now that you have the client set up, let's explore how to run Actors on the Apify platform, provide input to them, and retrieve their results.

### 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 Actor name and the Actor owner's username. Use the [`ActorClient`](/reference/class/ActorClient) to run the Actor and wait for it to complete. You can run both your own Actors and [Actors from Apify Store](https://docs.apify.com/platform/actors/running/actors-in-store).

<Tabs>
<TabItem value="AsyncExample" label="Async client" default>
<CodeBlock className="language-python">
{UsageAsyncExample}
</CodeBlock>
</TabItem>
<TabItem value="SyncExample" label="Sync client">
<CodeBlock className="language-python">
{UsageSyncExample}
</CodeBlock>
</TabItem>
</Tabs>

### 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`](/reference/class/ActorClient#call) method. Actors respect the input schema defined in the Actor's [input schema](https://docs.apify.com/platform/actors/development/actor-definition/input-schema).

<Tabs>
<TabItem value="AsyncExample" label="Async client" default>
<CodeBlock className="language-python">
{InputAsyncExample}
</CodeBlock>
</TabItem>
<TabItem value="SyncExample" label="Sync client">
<CodeBlock className="language-python">
{InputSyncExample}
</CodeBlock>
</TabItem>
</Tabs>

### Getting results from the dataset

To get the results from the dataset, you can use the [`DatasetClient`](/reference/class/DatasetClient) ([`ApifyClient.dataset`](/reference/class/ApifyClient#dataset)) and [`DatasetClient.list_items`](/reference/class/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`).

<Tabs>
<TabItem value="AsyncExample" label="Async client" default>
<CodeBlock className="language-python">
{DatasetAsyncExample}
</CodeBlock>
</TabItem>
<TabItem value="SyncExample" label="Sync client">
<CodeBlock className="language-python">
{DatasetSyncExample}
</CodeBlock>
</TabItem>
</Tabs>

:::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](https://docs.apify.com/platform/actors/running/runs-and-builds#runs).

:::

## Next steps

Now that you're familiar with the basics, explore more advanced features:

- [Asyncio support](/concepts/asyncio-support) - Learn about asynchronous programming with the client
- Common use-case examples like:
- [Passing an input to Actor](/api/client/python/docs/examples/passing-input-to-actor)
- [Retrieve Actor data](/api/client/python/docs/examples/retrieve-actor-data)
- [API Reference](/api/client/python/reference) - Browse the complete API documentation
2 changes: 1 addition & 1 deletion website/docusaurus.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ module.exports = {
title: 'API Client for Python',
items: [
{
to: 'docs/overview/introduction',
to: 'docs/overview',
label: 'Docs',
position: 'left',
activeBaseRegex: '/docs(?!/changelog)',
Expand Down
11 changes: 2 additions & 9 deletions website/sidebars.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,8 @@
module.exports = {
sidebar: [
{
type: 'category',
label: 'Overview',
collapsed: true,
items: [
{
type: 'autogenerated',
dirName: '01_overview',
},
],
type: 'doc',
id: 'overview/overview',
},
{
type: 'category',
Expand Down