# Apify API client for Python
The Apify API Client for Python is the official library to access the [Apify API](https://docs.apify.com/api/v2) from your Python applications.
It provides useful features like automatic retries and convenience functions to improve your experience with the Apify API.
If you want to develop Apify Actors in Python,
check out the [Apify SDK for Python](https://docs.apify.com/sdk/python) instead.
## Installation
Requires Python 3.8+
You can install the package from its [PyPI listing](https://pypi.org/project/apify-client).
To do that, simply run `pip install apify-client` in your terminal.
## Usage
For usage instructions, check the documentation on [Apify Docs](https://docs.apify.com/api/client/python/).
## Quick Start
```python
from apify_client import ApifyClient
apify_client = ApifyClient('MY-APIFY-TOKEN')
# Start an Actor and wait for it to finish
actor_call = apify_client.actor('john-doe/my-cool-actor').call()
# Fetch results from the Actor's default dataset
dataset_items = apify_client.dataset(actor_call['defaultDatasetId']).list_items().items
```
## Features
Besides greatly simplifying the process of querying the Apify API, the client provides other useful features.
### Automatic parsing and error handling
Based on the endpoint, the client automatically extracts the relevant data and returns it in the
expected format. Date strings are automatically converted to `datetime.datetime` objects. For exceptions,
we throw an `ApifyApiError`, which wraps the plain JSON errors returned by API and enriches
them with other context for easier debugging.
### Retries with exponential backoff
Network communication sometimes fails. The client will automatically retry requests that
failed due to a network error, an internal error of the Apify API (HTTP 500+) or rate limit error (HTTP 429).
By default, it will retry up to 8 times. First retry will be attempted after ~500ms, second after ~1000ms
and so on. You can configure those parameters using the `max_retries` and `min_delay_between_retries_millis`
options of the `ApifyClient` constructor.
### Support for asynchronous usage
Starting with version 1.0.0, the package offers an asynchronous version of the client, [`ApifyClientAsync`](https://docs.apify.com/api/client/python),
which allows you to work with the Apify API in an asynchronous way, using the standard `async`/`await` syntax.
### Convenience functions and options
Some actions can't be performed by the API itself, such as indefinite waiting for an Actor run to finish
(because of network timeouts). The client provides convenient `call()` and `wait_for_finish()` functions that do that.
Key-value store records can be retrieved as objects, buffers or streams via the respective options, dataset items
can be fetched as individual objects or serialized data and we plan to add better stream support and async iterators.
Raw data
{
"_id": null,
"home_page": null,
"name": "apify-client",
"maintainer": null,
"docs_url": null,
"requires_python": "<4.0,>=3.9",
"maintainer_email": null,
"keywords": "apify, api, client, automation, crawling, scraping",
"author": "Apify Technologies s.r.o.",
"author_email": "support@apify.com",
"download_url": "https://files.pythonhosted.org/packages/9c/d7/37d955bff90f6dfc353642e4b4075db3dd9abf8f5111ed35152be3dfc3da/apify_client-1.8.1.tar.gz",
"platform": null,
"description": "# Apify API client for Python\n\nThe Apify API Client for Python is the official library to access the [Apify API](https://docs.apify.com/api/v2) from your Python applications.\nIt provides useful features like automatic retries and convenience functions to improve your experience with the Apify API.\n\nIf you want to develop Apify Actors in Python,\ncheck out the [Apify SDK for Python](https://docs.apify.com/sdk/python) instead.\n\n## Installation\n\nRequires Python 3.8+\n\nYou can install the package from its [PyPI listing](https://pypi.org/project/apify-client).\nTo do that, simply run `pip install apify-client` in your terminal.\n\n## Usage\n\nFor usage instructions, check the documentation on [Apify Docs](https://docs.apify.com/api/client/python/).\n\n## Quick Start\n\n```python\nfrom apify_client import ApifyClient\n\napify_client = ApifyClient('MY-APIFY-TOKEN')\n\n# Start an Actor and wait for it to finish\nactor_call = apify_client.actor('john-doe/my-cool-actor').call()\n\n# Fetch results from the Actor's default dataset\ndataset_items = apify_client.dataset(actor_call['defaultDatasetId']).list_items().items\n```\n\n## Features\n\nBesides greatly simplifying the process of querying the Apify API, the client provides other useful features.\n\n### Automatic parsing and error handling\n\nBased on the endpoint, the client automatically extracts the relevant data and returns it in the\nexpected format. Date strings are automatically converted to `datetime.datetime` objects. For exceptions,\nwe throw an `ApifyApiError`, which wraps the plain JSON errors returned by API and enriches\nthem with other context for easier debugging.\n\n### Retries with exponential backoff\n\nNetwork communication sometimes fails. The client will automatically retry requests that\nfailed due to a network error, an internal error of the Apify API (HTTP 500+) or rate limit error (HTTP 429).\nBy default, it will retry up to 8 times. First retry will be attempted after ~500ms, second after ~1000ms\nand so on. You can configure those parameters using the `max_retries` and `min_delay_between_retries_millis`\noptions of the `ApifyClient` constructor.\n\n### Support for asynchronous usage\n\nStarting with version 1.0.0, the package offers an asynchronous version of the client, [`ApifyClientAsync`](https://docs.apify.com/api/client/python),\nwhich allows you to work with the Apify API in an asynchronous way, using the standard `async`/`await` syntax.\n\n### Convenience functions and options\n\nSome actions can't be performed by the API itself, such as indefinite waiting for an Actor run to finish\n(because of network timeouts). The client provides convenient `call()` and `wait_for_finish()` functions that do that.\nKey-value store records can be retrieved as objects, buffers or streams via the respective options, dataset items\ncan be fetched as individual objects or serialized data and we plan to add better stream support and async iterators.\n\n",
"bugtrack_url": null,
"license": "Apache-2.0",
"summary": "Apify API client for Python",
"version": "1.8.1",
"project_urls": {
"Apify Homepage": "https://apify.com",
"Changelog": "https://github.com/apify/apify-client-python/blob/master/CHANGELOG.md",
"Documentation": "https://docs.apify.com/api/client/python/",
"Homepage": "https://docs.apify.com/api/client/python/",
"Issue Tracker": "https://github.com/apify/apify-client-python/issues",
"Repository": "https://github.com/apify/apify-client-python"
},
"split_keywords": [
"apify",
" api",
" client",
" automation",
" crawling",
" scraping"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "150b42bb740ba9ff4cd540cc3c22687e3c07a823a5bdecb18a714de6df183a3a",
"md5": "d39adb3e85e1efc9113eb71e5e556ed1",
"sha256": "cfa6df3816c436204e37457fba28981a0ef6a7602cde372463f0f078eee64747"
},
"downloads": -1,
"filename": "apify_client-1.8.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "d39adb3e85e1efc9113eb71e5e556ed1",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "<4.0,>=3.9",
"size": 73532,
"upload_time": "2024-09-17T14:56:28",
"upload_time_iso_8601": "2024-09-17T14:56:28.810215Z",
"url": "https://files.pythonhosted.org/packages/15/0b/42bb740ba9ff4cd540cc3c22687e3c07a823a5bdecb18a714de6df183a3a/apify_client-1.8.1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "9cd737d955bff90f6dfc353642e4b4075db3dd9abf8f5111ed35152be3dfc3da",
"md5": "15fad818d43b81216d350bfb003b06fe",
"sha256": "2be1be7879570655bddeebf126833efe94cabb95b3755592845e92c20c70c674"
},
"downloads": -1,
"filename": "apify_client-1.8.1.tar.gz",
"has_sig": false,
"md5_digest": "15fad818d43b81216d350bfb003b06fe",
"packagetype": "sdist",
"python_version": "source",
"requires_python": "<4.0,>=3.9",
"size": 48422,
"upload_time": "2024-09-17T14:56:31",
"upload_time_iso_8601": "2024-09-17T14:56:31.273180Z",
"url": "https://files.pythonhosted.org/packages/9c/d7/37d955bff90f6dfc353642e4b4075db3dd9abf8f5111ed35152be3dfc3da/apify_client-1.8.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-09-17 14:56:31",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "apify",
"github_project": "apify-client-python",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "apify-client"
}