Scrapely API client for Python
The official Python client for the Scrapely REST API.
scrapely-client-python lets you talk to the Scrapely platform from Python — run Actors, manage storages (datasets, key-value stores, request queues), schedule tasks, configure webhooks, and use everything else exposed by the Scrapely API. It ships both synchronous and asynchronous clients, fully typed responses, automatic retries with exponential backoff, tiered timeouts, pagination helpers, streaming, and a pluggable HTTP layer.
If you want to build Actors in Python rather than consume the API, use the Scrapely SDK for Python (
scrapely-python) instead — it bundles this client and adds Actor-side primitives.
Table of contents
- Installation
- Quick start
- Features
- Usage examples
- Documentation
- Related projects
- Support and community
- Contributing
- License
Installation
scrapely-client-python requires Python 3.11 or higher and is published on PyPI.
-
From PyPI, it can be installed for example with pip:
pip install scrapely-client-python
or with uv:
uv add scrapely-client-python
or any other Python package manager that consumes PyPI.
The client compresses request bodies with
gzipby default (no extra dependencies required). To opt in tobrotli(better compression ratio), install the optional extra and passcompression='brotli':pip install "scrapely-client-python[brotli]" # or uv add "scrapely-client-python[brotli]"
Quick start
You'll need a Scrapely API token — create one in the dashboard under Settings → API & Integrations (see API keys). Pass it to the client and you're ready to go.
The client sends requests to https://api.scrape.ly unless you pass another API origin as api_url. When api_url is not given, the SCRAPELY_API_URL environment variable sets it (for example SCRAPELY_API_URL=https://api-staging.scrape.ly). api_public_url, used for public storage links, keeps its own argument and default. The client does not read the token from the environment.
Synchronous client
from scrapely_client import ScrapelyClient
client = ScrapelyClient('MY-SCRAPELY-TOKEN')
# Start an Actor and wait for it to finish.
run = client.actor('my-user/hello-world').call(
run_input={'message': 'Hello, Scrapely!'},
)
if run is None:
raise RuntimeError('Actor run was not found.')
# Iterate items from the run's default dataset.
for item in client.dataset(run.default_dataset_id).iterate_items():
print(item)
Asynchronous client
import asyncio
from scrapely_client import ScrapelyClientAsync
async def main() -> None:
client = ScrapelyClientAsync('MY-SCRAPELY-TOKEN')
run = await client.actor('my-user/hello-world').call(
run_input={'message': 'Hello, Scrapely!'},
)
if run is None:
raise RuntimeError('Actor run was not found.')
# Iterate items from the run's default dataset.
async for item in client.dataset(run.default_dataset_id).iterate_items():
print(item)
asyncio.run(main())
Keep your token secret. It authorizes requests on your behalf and can incur usage costs. Never commit it to source control or expose it to client-side code.
Features
- Synchronous and asynchronous clients — pick
ScrapelyClientorScrapelyClientAsyncto match your codebase; both expose the same API (Asyncio support). - Fully typed responses — every method returns a Pydantic model generated from the platform's OpenAPI spec, with IDE autocomplete and runtime validation (Typed models).
- Automatic retries — exponential backoff for network errors, HTTP 429, and 5xx responses, configurable per client (Retries).
- Tiered timeouts — short / medium / long tiers picked per endpoint, overridable per call (Timeouts).
- Pagination and streaming — iterate datasets, key-value store keys, or live logs without manual paging or buffering (Pagination, Streaming).
- Convenience methods —
call(),wait_for_finish(), nested resource access, and other shortcuts that hide platform quirks (Convenience methods). - Pluggable HTTP layer — swap the default Impit-based HTTP client for
httpx,requests,aiohttp, or any custom implementation (Custom HTTP clients). - Structured errors — every API error surfaces as a
ScrapelyApiErrorwith HTTP-specific subclasses for precise handling (Error handling). - Debug logging — opt-in structured logging on the
scrapely_clientlogger captures request URLs, status codes, retry attempts, and more (Logging).
Usage examples
The client mirrors the platform's resource model. Each entry point returns either a single-resource client for an individual item or a collection client for listing and creating items (Single and collection clients).
List Actors and create one
actors = client.actors()
print(actors.list(limit=10).items)
new_actor = actors.create(name='my-actor')
Stream live logs while a run is in progress
run = client.actor('my-user/web-scraper').start(run_input={...})
with client.run(run.id).log().stream() as log_stream:
for chunk in log_stream.iter_bytes():
print(chunk.decode(), end='')
Read and write key-value store records
store = client.key_value_store('STORE-ID')
store.set_record('greeting', {'message': 'Hello!'})
record = store.get_record('greeting')
Iterate dataset items with automatic pagination
for item in client.dataset('DATASET-ID').iterate_items(fields=['title', 'url']):
process(item)
Create and run an automation
automation = client.automations().create({
'title': 'Daily dentists',
'trigger': {'kind': 'schedule', 'cron': '0 9 * * *', 'timezone': 'Europe/Berlin'},
'steps': [{'kind': 'savedInput', 'savedInputId': 'SAVED-INPUT-ID'}],
'ai': {'mode': 'summarize', 'prompt': 'List the new practices with their phone numbers.'},
'deliveries': [{'channel': 'email'}],
})
run = client.automation(automation['id']).run()
Automations take and return the API's camelCase dictionaries (see the automations section of the API reference).
Tune retries and timeouts
from datetime import timedelta
from scrapely_client import ScrapelyClient
client = ScrapelyClient(
token='MY-SCRAPELY-TOKEN',
max_retries=8,
min_delay_between_retries=timedelta(milliseconds=500),
timeout_long=timedelta(minutes=10),
)
For end-to-end recipes — passing input, managing tasks for reusable input, retrieving and merging Actor data, integrating with Pandas, plugging in a custom HTTP client — see the guides.
Documentation
The client guide lives at https://scrape.ly/docs/client-python, and the REST API it wraps is described in the API reference.
The docs/ folder of the repository has more detail:
| Section | What you'll find |
|---|---|
| Introduction | Overview, installation, and a quick start: authenticate, run an Actor, and fetch its results. |
| Concepts | Asyncio, single vs. collection clients, nested clients, error handling, retries, logging, convenience methods, pagination, streaming, custom HTTP clients, timeouts, typed models, HTTP compression. |
| Guides | Pass input to an Actor, manage tasks for reusable input, retrieve Actor data, integrate with data libraries (e.g. Pandas), use HTTPX as the HTTP client. |
| Changelog | Release history and breaking changes. |
Related projects
- Scrapely SDK for Python (
scrapely-python) — toolkit for building Actors in Python (this client is bundled with it). - Crawlee for Python — high-level web scraping and browser automation framework that powers many Actors.
- Scrapely API client for JavaScript / TypeScript — equivalent Scrapely API client for Node.js.
- Scrapely SDK for JavaScript / TypeScript — equivalent Scrapely SDK for Node.js.
- Crawlee for JavaScript / TypeScript — the Node.js implementation of the Crawlee framework.
- Scrapely CLI — command-line tool for interacting with the Scrapely platform: managing Actors, runs, storages, local development, and deployment.
Support and community
- GitHub issues — report a bug or request a feature in the issue tracker.
Contributing
Bug reports, fixes, and improvements are welcome! See CONTRIBUTING.md for the development setup, coding standards, testing, and the release process. The repo uses uv for project management and Poe the Poet as a task runner; the typical loop is:
uv run poe install-dev # install dev deps and git hooks
uv run poe check-code # lint, type-check, unit tests, docstring check
License
Released under the Apache License 2.0; see NOTICE.
Metadata
Release files for scrapely-client-python 1.0.11
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| scrapely_client_python-1.0.11.tar.gz | 141.2 kB | Without provenance | Details for scrapely_client_python-1.0.11.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| scrapely_client_python-1.0.11-py3-none-any.whl | Python 3 | none | any | Details for scrapely_client_python-1.0.11-py3-none-any.whl |
Total release size: 310.4 kB
Release files / scrapely_client_python-1.0.11.tar.gz
| Download URL | scrapely_client_python-1.0.11.tar.gz |
|---|---|
| Size | 141.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f4844d04851d6cd3d6c4fdc81ee36d2d90d6e022e1292f9528bcc40fe3d5298e
|
|
BLAKE2b-256 checksum How to use checksums |
340a7f1b8868737292a67b36c0609ca74d56a74039d4a77fb1ba6faa8a6b78d0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.13.7 {"installer":{"name":"uv","version":"0.13.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / scrapely_client_python-1.0.11-py3-none-any.whl
| Download URL | scrapely_client_python-1.0.11-py3-none-any.whl |
|---|---|
| Size | 169.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
92386fa3640e8e5e3f9cdc40ffa6b2f33883027b242d18cc23310948c58b5328
|
|
BLAKE2b-256 checksum How to use checksums |
d156ae1522a0eebf586ccd5482908ee6f96583a1f1d120501080479280f12e50
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.13.7 {"installer":{"name":"uv","version":"0.13.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Security for scrapely-client-python 1.0.11
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.