scrapely-client-python 3.1.3__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of scrapely-client-python might be problematic. Click here for more details.
- scrapely_client_python-3.1.3/CHANGELOG.md +9 -0
- scrapely_client_python-3.1.3/CONTRIBUTING.md +189 -0
- scrapely_client_python-3.1.3/LICENSE +201 -0
- scrapely_client_python-3.1.3/PKG-INFO +269 -0
- scrapely_client_python-3.1.3/README.md +237 -0
- scrapely_client_python-3.1.3/pyproject.toml +334 -0
- scrapely_client_python-3.1.3/pyproject.toml.orig +339 -0
- scrapely_client_python-3.1.3/src/scrapely_client/__init__.py +30 -0
- scrapely_client_python-3.1.3/src/scrapely_client/_charging.py +186 -0
- scrapely_client_python-3.1.3/src/scrapely_client/_client_registry.py +136 -0
- scrapely_client_python-3.1.3/src/scrapely_client/_consts.py +96 -0
- scrapely_client_python-3.1.3/src/scrapely_client/_docs.py +37 -0
- scrapely_client_python-3.1.3/src/scrapely_client/_literals.py +539 -0
- scrapely_client_python-3.1.3/src/scrapely_client/_logging.py +180 -0
- scrapely_client_python-3.1.3/src/scrapely_client/_models.py +4172 -0
- scrapely_client_python-3.1.3/src/scrapely_client/_pagination.py +220 -0
- scrapely_client_python-3.1.3/src/scrapely_client/_resource_clients/__init__.py +84 -0
- scrapely_client_python-3.1.3/src/scrapely_client/_resource_clients/_resource_client.py +567 -0
- scrapely_client_python-3.1.3/src/scrapely_client/_resource_clients/actor.py +1042 -0
- scrapely_client_python-3.1.3/src/scrapely_client/_resource_clients/actor_collection.py +377 -0
- scrapely_client_python-3.1.3/src/scrapely_client/_resource_clients/actor_env_var.py +154 -0
- scrapely_client_python-3.1.3/src/scrapely_client/_resource_clients/actor_env_var_collection.py +165 -0
- scrapely_client_python-3.1.3/src/scrapely_client/_resource_clients/actor_version.py +254 -0
- scrapely_client_python-3.1.3/src/scrapely_client/_resource_clients/actor_version_collection.py +232 -0
- scrapely_client_python-3.1.3/src/scrapely_client/_resource_clients/build.py +244 -0
- scrapely_client_python-3.1.3/src/scrapely_client/_resource_clients/build_collection.py +164 -0
- scrapely_client_python-3.1.3/src/scrapely_client/_resource_clients/dataset.py +1151 -0
- scrapely_client_python-3.1.3/src/scrapely_client/_resource_clients/dataset_collection.py +244 -0
- scrapely_client_python-3.1.3/src/scrapely_client/_resource_clients/key_value_store.py +906 -0
- scrapely_client_python-3.1.3/src/scrapely_client/_resource_clients/key_value_store_collection.py +243 -0
- scrapely_client_python-3.1.3/src/scrapely_client/_resource_clients/log.py +225 -0
- scrapely_client_python-3.1.3/src/scrapely_client/_resource_clients/request_queue.py +1167 -0
- scrapely_client_python-3.1.3/src/scrapely_client/_resource_clients/request_queue_collection.py +240 -0
- scrapely_client_python-3.1.3/src/scrapely_client/_resource_clients/run.py +875 -0
- scrapely_client_python-3.1.3/src/scrapely_client/_resource_clients/run_collection.py +226 -0
- scrapely_client_python-3.1.3/src/scrapely_client/_resource_clients/schedule.py +243 -0
- scrapely_client_python-3.1.3/src/scrapely_client/_resource_clients/schedule_collection.py +260 -0
- scrapely_client_python-3.1.3/src/scrapely_client/_resource_clients/store_collection.py +242 -0
- scrapely_client_python-3.1.3/src/scrapely_client/_resource_clients/task.py +793 -0
- scrapely_client_python-3.1.3/src/scrapely_client/_resource_clients/task_collection.py +322 -0
- scrapely_client_python-3.1.3/src/scrapely_client/_resource_clients/user.py +262 -0
- scrapely_client_python-3.1.3/src/scrapely_client/_resource_clients/webhook.py +292 -0
- scrapely_client_python-3.1.3/src/scrapely_client/_resource_clients/webhook_collection.py +281 -0
- scrapely_client_python-3.1.3/src/scrapely_client/_resource_clients/webhook_dispatch.py +84 -0
- scrapely_client_python-3.1.3/src/scrapely_client/_resource_clients/webhook_dispatch_collection.py +158 -0
- scrapely_client_python-3.1.3/src/scrapely_client/_scrapely_client.py +837 -0
- scrapely_client_python-3.1.3/src/scrapely_client/_statistics.py +29 -0
- scrapely_client_python-3.1.3/src/scrapely_client/_status_message_watcher.py +197 -0
- scrapely_client_python-3.1.3/src/scrapely_client/_streamed_log.py +250 -0
- scrapely_client_python-3.1.3/src/scrapely_client/_typeddicts.py +408 -0
- scrapely_client_python-3.1.3/src/scrapely_client/_utils/__init__.py +0 -0
- scrapely_client_python-3.1.3/src/scrapely_client/_utils/crypto.py +87 -0
- scrapely_client_python-3.1.3/src/scrapely_client/_utils/encoding.py +133 -0
- scrapely_client_python-3.1.3/src/scrapely_client/_utils/errors.py +33 -0
- scrapely_client_python-3.1.3/src/scrapely_client/_utils/http.py +137 -0
- scrapely_client_python-3.1.3/src/scrapely_client/_utils/time.py +32 -0
- scrapely_client_python-3.1.3/src/scrapely_client/_utils/try_import.py +61 -0
- scrapely_client_python-3.1.3/src/scrapely_client/errors.py +190 -0
- scrapely_client_python-3.1.3/src/scrapely_client/http_clients/__init__.py +10 -0
- scrapely_client_python-3.1.3/src/scrapely_client/http_clients/_base.py +430 -0
- scrapely_client_python-3.1.3/src/scrapely_client/http_clients/_impit.py +598 -0
- scrapely_client_python-3.1.3/src/scrapely_client/http_compressors/__init__.py +18 -0
- scrapely_client_python-3.1.3/src/scrapely_client/http_compressors/_base.py +25 -0
- scrapely_client_python-3.1.3/src/scrapely_client/http_compressors/_brotli.py +38 -0
- scrapely_client_python-3.1.3/src/scrapely_client/http_compressors/_gzip.py +38 -0
- scrapely_client_python-3.1.3/src/scrapely_client/http_compressors/_resolve.py +38 -0
- scrapely_client_python-3.1.3/src/scrapely_client/py.typed +0 -0
- scrapely_client_python-3.1.3/src/scrapely_client/types.py +52 -0
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
# Development
|
|
2
|
+
|
|
3
|
+
Here you'll find a contributing guide to get started with development.
|
|
4
|
+
|
|
5
|
+
## Environment
|
|
6
|
+
|
|
7
|
+
For local development, it is required to have Python 3.11 (or a later version) installed.
|
|
8
|
+
|
|
9
|
+
We use [uv](https://docs.astral.sh/uv/) for project management. Install it and set up your IDE accordingly.
|
|
10
|
+
|
|
11
|
+
We use [Poe the Poet](https://poethepoet.natn.io/) as a task runner, similar to npm scripts in `package.json`.
|
|
12
|
+
All tasks are defined in `pyproject.toml` under `[tool.poe.tasks]` and can be run with `uv run poe <task>`.
|
|
13
|
+
|
|
14
|
+
### Available tasks
|
|
15
|
+
|
|
16
|
+
| Task | Description |
|
|
17
|
+
| ---- | ----------- |
|
|
18
|
+
| `install-dev` | Install development dependencies |
|
|
19
|
+
| `check-code` | Run lint, type-check, unit-tests, and docstring check |
|
|
20
|
+
| `lint` | Run linter |
|
|
21
|
+
| `format` | Fix lint issues and format code |
|
|
22
|
+
| `type-check` | Run type checker |
|
|
23
|
+
| `unit-tests` | Run unit tests |
|
|
24
|
+
| `unit-tests-cov` | Run unit tests with coverage |
|
|
25
|
+
| `integration-tests` | Run integration tests |
|
|
26
|
+
| `integration-tests-cov` | Run integration tests with coverage |
|
|
27
|
+
| `check-docstrings` | Check async client docstrings |
|
|
28
|
+
| `fix-docstrings` | Fix async client docstrings |
|
|
29
|
+
| `build-docs` | Build documentation website |
|
|
30
|
+
| `run-docs` | Run documentation website locally |
|
|
31
|
+
| `build` | Build package |
|
|
32
|
+
| `clean` | Remove build artifacts and clean caches |
|
|
33
|
+
|
|
34
|
+
## Dependencies
|
|
35
|
+
|
|
36
|
+
To install this package and its development dependencies, run:
|
|
37
|
+
|
|
38
|
+
```sh
|
|
39
|
+
uv run poe install-dev
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
## Code checking
|
|
43
|
+
|
|
44
|
+
To execute all code checking tools together, run:
|
|
45
|
+
|
|
46
|
+
```sh
|
|
47
|
+
uv run poe check-code
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
### Linting
|
|
51
|
+
|
|
52
|
+
We utilize [ruff](https://docs.astral.sh/ruff/) for linting, which analyzes code for potential issues and enforces consistent style. Refer to `pyproject.toml` for configuration details.
|
|
53
|
+
|
|
54
|
+
To run linting:
|
|
55
|
+
|
|
56
|
+
```sh
|
|
57
|
+
uv run poe lint
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
### Formatting
|
|
61
|
+
|
|
62
|
+
Our automated code formatting also leverages [ruff](https://docs.astral.sh/ruff/), ensuring uniform style and addressing fixable linting issues. Configuration specifics are outlined in `pyproject.toml`.
|
|
63
|
+
|
|
64
|
+
To run formatting:
|
|
65
|
+
|
|
66
|
+
```sh
|
|
67
|
+
uv run poe format
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
### Type checking
|
|
71
|
+
|
|
72
|
+
Type checking is handled by [ty](https://docs.astral.sh/ty/), verifying code against type annotations. Configuration settings can be found in `pyproject.toml`.
|
|
73
|
+
|
|
74
|
+
To run type checking:
|
|
75
|
+
|
|
76
|
+
```sh
|
|
77
|
+
uv run poe type-check
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
### Unit tests
|
|
81
|
+
|
|
82
|
+
We use [pytest](https://docs.pytest.org/) as a testing framework with many plugins. Check `pyproject.toml` for configuration details and installed plugins.
|
|
83
|
+
|
|
84
|
+
To run unit tests:
|
|
85
|
+
|
|
86
|
+
```sh
|
|
87
|
+
uv run poe unit-tests
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
To run unit tests with XML coverage report:
|
|
91
|
+
|
|
92
|
+
```sh
|
|
93
|
+
uv run poe unit-tests-cov
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
## Integration tests
|
|
97
|
+
|
|
98
|
+
We have integration tests which interact with the Apify platform.
|
|
99
|
+
|
|
100
|
+
Prerequisites:
|
|
101
|
+
|
|
102
|
+
- Set `APIFY_TEST_USER_API_TOKEN` to your Apify API token
|
|
103
|
+
- Set `APIFY_TEST_USER_2_API_TOKEN` for storage access tests (requires two accounts)
|
|
104
|
+
- Optionally set `APIFY_INTEGRATION_TESTS_API_URL` to use a different Apify API environment
|
|
105
|
+
|
|
106
|
+
To run integration tests:
|
|
107
|
+
|
|
108
|
+
```sh
|
|
109
|
+
uv run poe integration-tests
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
## Documentation
|
|
113
|
+
|
|
114
|
+
We adhere to the [Google docstring format](https://sphinxcontrib-napoleon.readthedocs.io/en/latest/example_google.html) for documenting our codebase. Every user-facing class or method is documented. Documentation standards are enforced using [Ruff](https://docs.astral.sh/ruff/).
|
|
115
|
+
|
|
116
|
+
Our API documentation is generated from these docstrings using [pydoc-markdown](https://pypi.org/project/pydoc-markdown/) with additional post-processing. Markdown files in the `docs/` folder complement the autogenerated content. Final documentation is rendered using [Docusaurus](https://docusaurus.io/) and published to GitHub Pages.
|
|
117
|
+
|
|
118
|
+
To run the documentation locally (requires Node.js):
|
|
119
|
+
|
|
120
|
+
```sh
|
|
121
|
+
uv run poe run-docs
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
### Linting the docs and website
|
|
125
|
+
|
|
126
|
+
Markdown content (this guide, `README.md`, and the `docs/` folder) is checked with
|
|
127
|
+
[markdownlint](https://github.com/DavidAnson/markdownlint). The Docusaurus website code is linted
|
|
128
|
+
with [oxlint](https://oxc.rs/) and formatted with [oxfmt](https://oxc.rs/). All of them run in CI.
|
|
129
|
+
To run them locally (requires Node.js 22.12 or newer and pnpm), from the `website/` directory:
|
|
130
|
+
|
|
131
|
+
```sh
|
|
132
|
+
pnpm lint # lint Markdown and website code
|
|
133
|
+
pnpm lint:fix # auto-fix both
|
|
134
|
+
pnpm format # format the website code
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
Doc images are committed as optimized `.webp`. To convert a new image, run
|
|
138
|
+
`pnpm opt:images <path-to-image>` from the `website/` directory.
|
|
139
|
+
|
|
140
|
+
## Commits
|
|
141
|
+
|
|
142
|
+
We use [Conventional Commits](https://www.conventionalcommits.org/) format for commit messages. This convention is used to automatically determine version bumps during the release process.
|
|
143
|
+
|
|
144
|
+
### Available commit types
|
|
145
|
+
|
|
146
|
+
| Type | Description |
|
|
147
|
+
| ---- | ----------- |
|
|
148
|
+
| `feat` | A new feature |
|
|
149
|
+
| `fix` | A bug fix |
|
|
150
|
+
| `docs` | Documentation only changes |
|
|
151
|
+
| `style` | Changes that do not affect the meaning of the code (white-space, formatting, missing semi-colons, etc) |
|
|
152
|
+
| `refactor` | A code change that neither fixes a bug nor adds a feature |
|
|
153
|
+
| `perf` | A code change that improves performance |
|
|
154
|
+
| `test` | Adding missing tests or correcting existing tests |
|
|
155
|
+
| `build` | Changes that affect the build system or external dependencies (example scopes: gulp, broccoli, npm) |
|
|
156
|
+
| `ci` | Changes to our CI configuration files and scripts (example scopes: Travis, Circle, BrowserStack, SauceLabs) |
|
|
157
|
+
| `chore` | Other changes that don't modify src or test files |
|
|
158
|
+
| `revert` | Reverts a previous commit |
|
|
159
|
+
|
|
160
|
+
## Release process
|
|
161
|
+
|
|
162
|
+
Publishing new versions to [PyPI](https://pypi.org/project/apify_client) is automated through GitHub Actions.
|
|
163
|
+
|
|
164
|
+
- **Beta releases**: On each commit to the master branch, a new beta release is automatically published. The version number is determined based on the latest release and conventional commits. The beta version suffix is incremented by 1 from the last beta release on PyPI.
|
|
165
|
+
- **Stable releases**: A stable version release may be created by triggering the `release` GitHub Actions workflow. The version number is determined based on the latest release and conventional commits (`auto` release type), or it may be overridden using the `custom` release type.
|
|
166
|
+
|
|
167
|
+
### Publishing to PyPI manually
|
|
168
|
+
|
|
169
|
+
1. **Do not do this unless absolutely necessary.** In all conceivable scenarios, you should use the `release` workflow instead.
|
|
170
|
+
2. **Make sure you know what you're doing.**
|
|
171
|
+
3. Update the version number by modifying the `version` field under `project` in `pyproject.toml`:
|
|
172
|
+
|
|
173
|
+
```toml
|
|
174
|
+
[project]
|
|
175
|
+
name = "apify_client"
|
|
176
|
+
version = "x.z.y"
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
4. Build the package:
|
|
180
|
+
|
|
181
|
+
```sh
|
|
182
|
+
uv run poe build
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
5. Upload to PyPI:
|
|
186
|
+
|
|
187
|
+
```sh
|
|
188
|
+
uv publish --token YOUR_API_TOKEN
|
|
189
|
+
```
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "{}"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright 2023 Apify Technologies s.r.o.
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
|
@@ -0,0 +1,269 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: scrapely-client-python
|
|
3
|
+
Version: 3.1.3
|
|
4
|
+
Summary: Scrapely API client for Python - a drop-in replacement for apify-client
|
|
5
|
+
Keywords: scrapely,apify,api,client,automation,crawling,scraping
|
|
6
|
+
Author: Scrapely
|
|
7
|
+
License-Expression: Apache-2.0
|
|
8
|
+
License-File: LICENSE
|
|
9
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
10
|
+
Classifier: Environment :: Console
|
|
11
|
+
Classifier: Intended Audience :: Developers
|
|
12
|
+
Classifier: Operating System :: OS Independent
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
17
|
+
Classifier: Topic :: Software Development :: Libraries
|
|
18
|
+
Requires-Dist: colorama>=0.4.0
|
|
19
|
+
Requires-Dist: impit~=0.13.0
|
|
20
|
+
Requires-Dist: more-itertools>=10.0.0
|
|
21
|
+
Requires-Dist: pydantic[email]>=2.11.0
|
|
22
|
+
Requires-Dist: typing-extensions>=4.6.0
|
|
23
|
+
Requires-Dist: brotli>=1.0.9 ; extra == 'brotli'
|
|
24
|
+
Requires-Python: >=3.11
|
|
25
|
+
Project-URL: Homepage, https://api.scrape.ly
|
|
26
|
+
Project-URL: Changelog, https://github.com/SandeepDev1/scrapely/blob/main/scrapely-client-python/CHANGELOG.md
|
|
27
|
+
Project-URL: Documentation, https://api.scrape.ly
|
|
28
|
+
Project-URL: Issue Tracker, https://github.com/SandeepDev1/scrapely/issues
|
|
29
|
+
Project-URL: Source Code, https://github.com/SandeepDev1/scrapely
|
|
30
|
+
Provides-Extra: brotli
|
|
31
|
+
Description-Content-Type: text/markdown
|
|
32
|
+
|
|
33
|
+
<h1 align="center">Scrapely API client for Python</h1>
|
|
34
|
+
|
|
35
|
+
<p align="center">
|
|
36
|
+
<strong>The official Python client for the <a href="https://api.scrape.ly">Scrapely REST API</a>, and a drop-in replacement for <code>apify-client</code>.</strong>
|
|
37
|
+
</p>
|
|
38
|
+
|
|
39
|
+
<p align="center">
|
|
40
|
+
<a href="https://pypi.org/project/scrapely-client-python/"><img src="https://badge.fury.io/py/scrapely-client-python.svg" alt="PyPI version"></a>
|
|
41
|
+
<a href="https://pypi.org/project/scrapely-client-python/"><img src="https://img.shields.io/pypi/dm/scrapely-client-python" alt="PyPI downloads"></a>
|
|
42
|
+
<a href="https://pypi.org/project/scrapely-client-python/"><img src="https://img.shields.io/badge/python-3.11%2B-blue" alt="Python versions"></a>
|
|
43
|
+
<a href="./LICENSE"><img src="https://img.shields.io/pypi/l/scrapely-client-python" alt="License"></a>
|
|
44
|
+
</p>
|
|
45
|
+
|
|
46
|
+
`scrapely-client-python` lets you talk to the [Scrapely platform](https://api.scrape.ly) 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.
|
|
47
|
+
|
|
48
|
+
> **Migrating from `apify-client`?** Just swap the import — the class names (`ApifyClient`, `ApifyClientAsync`), constructor arguments, methods and return types are identical. See [Migrating from apify-client](#migrating-from-apify-client) below.
|
|
49
|
+
>
|
|
50
|
+
> If you want to **build** Actors in Python rather than consume the API, use the Scrapely SDK for Python instead — it bundles this client and adds Actor-side primitives.
|
|
51
|
+
|
|
52
|
+
## Table of contents
|
|
53
|
+
|
|
54
|
+
- [Installation](#installation)
|
|
55
|
+
- [Quick start](#quick-start)
|
|
56
|
+
- [Migrating from apify-client](#migrating-from-apify-client)
|
|
57
|
+
- [Features](#features)
|
|
58
|
+
- [Usage examples](#usage-examples)
|
|
59
|
+
- [Documentation](#documentation)
|
|
60
|
+
- [Related projects](#related-projects)
|
|
61
|
+
- [Support and community](#support-and-community)
|
|
62
|
+
- [Contributing](#contributing)
|
|
63
|
+
- [License](#license)
|
|
64
|
+
|
|
65
|
+
## Installation
|
|
66
|
+
|
|
67
|
+
`scrapely-client-python` requires **Python 3.11 or higher** and is published on [PyPI](https://pypi.org/project/scrapely-client-python/).
|
|
68
|
+
|
|
69
|
+
- From [PyPI](https://pypi.org/project/scrapely-client-python/), it can be installed for example with [pip](https://pip.pypa.io/):
|
|
70
|
+
|
|
71
|
+
```bash
|
|
72
|
+
pip install scrapely-client-python
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
or with [uv](https://docs.astral.sh/uv/):
|
|
76
|
+
|
|
77
|
+
```bash
|
|
78
|
+
uv add scrapely-client-python
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
or any other Python package manager that consumes PyPI.
|
|
82
|
+
|
|
83
|
+
The client compresses request bodies with `gzip` by default (no extra dependencies required). To opt in to
|
|
84
|
+
`brotli` (better compression ratio), install the optional extra and pass `compression='brotli'`:
|
|
85
|
+
|
|
86
|
+
```bash
|
|
87
|
+
pip install "scrapely-client-python[brotli]"
|
|
88
|
+
# or
|
|
89
|
+
uv add "scrapely-client-python[brotli]"
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
## Quick start
|
|
94
|
+
|
|
95
|
+
You'll need a Scrapely API token — find yours in the integrations section of the Scrapely Console. Pass it to the client and you're ready to go.
|
|
96
|
+
|
|
97
|
+
### Synchronous client
|
|
98
|
+
|
|
99
|
+
```python
|
|
100
|
+
from scrapely_client import ApifyClient
|
|
101
|
+
|
|
102
|
+
client = ApifyClient('MY-SCRAPELY-TOKEN')
|
|
103
|
+
|
|
104
|
+
# Start an Actor and wait for it to finish.
|
|
105
|
+
run = client.actor('apify/hello-world').call(
|
|
106
|
+
run_input={'message': 'Hello, Scrapely!'},
|
|
107
|
+
)
|
|
108
|
+
if run is None:
|
|
109
|
+
raise RuntimeError('Actor run was not found.')
|
|
110
|
+
|
|
111
|
+
# Iterate items from the run's default dataset.
|
|
112
|
+
for item in client.dataset(run.default_dataset_id).iterate_items():
|
|
113
|
+
print(item)
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
### Asynchronous client
|
|
117
|
+
|
|
118
|
+
```python
|
|
119
|
+
import asyncio
|
|
120
|
+
|
|
121
|
+
from scrapely_client import ApifyClientAsync
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
async def main() -> None:
|
|
125
|
+
client = ApifyClientAsync('MY-SCRAPELY-TOKEN')
|
|
126
|
+
|
|
127
|
+
run = await client.actor('apify/hello-world').call(
|
|
128
|
+
run_input={'message': 'Hello, Scrapely!'},
|
|
129
|
+
)
|
|
130
|
+
if run is None:
|
|
131
|
+
raise RuntimeError('Actor run was not found.')
|
|
132
|
+
|
|
133
|
+
# Iterate items from the run's default dataset.
|
|
134
|
+
async for item in client.dataset(run.default_dataset_id).iterate_items():
|
|
135
|
+
print(item)
|
|
136
|
+
|
|
137
|
+
|
|
138
|
+
asyncio.run(main())
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
> **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.
|
|
142
|
+
|
|
143
|
+
## Migrating from apify-client
|
|
144
|
+
|
|
145
|
+
`scrapely-client-python` is a drop-in replacement for `apify-client` — swap the import and nothing else in
|
|
146
|
+
your code needs to change:
|
|
147
|
+
|
|
148
|
+
```diff
|
|
149
|
+
- from apify_client import ApifyClient, ApifyClientAsync
|
|
150
|
+
+ from scrapely_client import ApifyClient, ApifyClientAsync
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
- The class names (`ApifyClient`, `ApifyClientAsync` and all resource clients), constructor
|
|
154
|
+
arguments, methods and return types are identical to `apify-client` (aliases `ScrapelyClient` /
|
|
155
|
+
`ScrapelyClientAsync` are also exported).
|
|
156
|
+
- The client talks to `https://api.scrape.ly` by default; override with the `api_url` /
|
|
157
|
+
`api_public_url` arguments if you need a different endpoint.
|
|
158
|
+
- Scrapely-specific extensions (e.g. pay-per-event `charging_hooks`, `task().publish()` /
|
|
159
|
+
`task().unpublish()`, `run().charge()`) are strictly additive — code written for `apify-client`
|
|
160
|
+
runs unchanged.
|
|
161
|
+
|
|
162
|
+
For a guided walkthrough — authenticating, running an Actor, and reading its results — see the Quick start guide.
|
|
163
|
+
|
|
164
|
+
## Features
|
|
165
|
+
|
|
166
|
+
- **Synchronous and asynchronous clients** — pick `ApifyClient` or `ApifyClientAsync` to match your codebase; both expose the same API (Asyncio support).
|
|
167
|
+
- **Fully typed responses** — every method returns a [Pydantic](https://docs.pydantic.dev/) model generated from the Apify OpenAPI spec, with IDE autocomplete and runtime validation (Typed models).
|
|
168
|
+
- **Automatic retries** — exponential backoff for network errors, HTTP 429, and 5xx responses, configurable per client (Retries).
|
|
169
|
+
- **Tiered timeouts** — short / medium / long tiers picked per endpoint, overridable per call (Timeouts).
|
|
170
|
+
- **Pagination and streaming** — iterate datasets, key-value store keys, or live logs without manual paging or buffering (Pagination, Streaming).
|
|
171
|
+
- **Convenience methods** — `call()`, `wait_for_finish()`, nested resource access, and other shortcuts that hide platform quirks (Convenience methods).
|
|
172
|
+
- **Pluggable HTTP layer** — swap the default Impit-based HTTP client for `httpx`, `requests`, `aiohttp`, or any custom implementation (Custom HTTP clients).
|
|
173
|
+
- **Structured errors** — every API error surfaces as an `ApifyApiError` with HTTP-specific subclasses for precise handling (Error handling).
|
|
174
|
+
- **Debug logging** — opt-in structured logging on the `apify_client` logger captures request URLs, status codes, retry attempts, and more (Logging).
|
|
175
|
+
|
|
176
|
+
## Usage examples
|
|
177
|
+
|
|
178
|
+
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).
|
|
179
|
+
|
|
180
|
+
### List Actors and create one
|
|
181
|
+
|
|
182
|
+
```python
|
|
183
|
+
actors = client.actors()
|
|
184
|
+
print(actors.list(limit=10).items)
|
|
185
|
+
|
|
186
|
+
new_actor = actors.create(name='my-actor')
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
### Stream live logs while a run is in progress
|
|
190
|
+
|
|
191
|
+
```python
|
|
192
|
+
run = client.actor('apify/web-scraper').start(run_input={...})
|
|
193
|
+
|
|
194
|
+
with client.run(run.id).log().stream() as log_stream:
|
|
195
|
+
for chunk in log_stream.iter_bytes():
|
|
196
|
+
print(chunk.decode(), end='')
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
### Read and write key-value store records
|
|
200
|
+
|
|
201
|
+
```python
|
|
202
|
+
store = client.key_value_store('STORE-ID')
|
|
203
|
+
store.set_record('greeting', {'message': 'Hello!'})
|
|
204
|
+
record = store.get_record('greeting')
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
### Iterate dataset items with automatic pagination
|
|
208
|
+
|
|
209
|
+
```python
|
|
210
|
+
for item in client.dataset('DATASET-ID').iterate_items(fields=['title', 'url']):
|
|
211
|
+
process(item)
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
### Tune retries and timeouts
|
|
215
|
+
|
|
216
|
+
```python
|
|
217
|
+
from datetime import timedelta
|
|
218
|
+
|
|
219
|
+
from scrapely_client import ApifyClient
|
|
220
|
+
|
|
221
|
+
client = ApifyClient(
|
|
222
|
+
token='MY-SCRAPELY-TOKEN',
|
|
223
|
+
max_retries=8,
|
|
224
|
+
min_delay_between_retries=timedelta(milliseconds=500),
|
|
225
|
+
timeout_long=timedelta(minutes=10),
|
|
226
|
+
)
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
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.
|
|
230
|
+
|
|
231
|
+
## Documentation
|
|
232
|
+
|
|
233
|
+
The full documentation lives at **https://api.scrape.ly**.
|
|
234
|
+
|
|
235
|
+
| Section | What you'll find |
|
|
236
|
+
| --- | --- |
|
|
237
|
+
| Introduction | Overview, prerequisites, and a tour of the client. |
|
|
238
|
+
| Quick start | Authenticate, run an Actor, and fetch its results step by step. |
|
|
239
|
+
| Concepts | Asyncio, single vs. collection clients, nested clients, error handling, retries, logging, convenience methods, pagination, streaming, custom HTTP clients, timeouts. |
|
|
240
|
+
| 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. |
|
|
241
|
+
| Upgrading | Migrating between major versions. |
|
|
242
|
+
| API reference | Generated reference for every class, method, and model. |
|
|
243
|
+
| Changelog | Release history and breaking changes. |
|
|
244
|
+
|
|
245
|
+
## Related projects
|
|
246
|
+
|
|
247
|
+
- **Apify SDK for Python** — toolkit for **building** Apify Actors in Python (this client is bundled with it).
|
|
248
|
+
- **[Crawlee for Python](https://crawlee.dev/python)** — high-level web scraping and browser automation framework that powers many Actors.
|
|
249
|
+
- **Apify API client for JavaScript / TypeScript** — equivalent Apify API client for Node.js.
|
|
250
|
+
- **Apify SDK for JavaScript / TypeScript** — equivalent Apify SDK for Node.js.
|
|
251
|
+
- **[Crawlee for JavaScript / TypeScript](https://crawlee.dev)** — original Node.js implementation of the Crawlee framework.
|
|
252
|
+
- **Apify CLI** — command-line tool for interacting with the Scrapely platform: managing Actors, runs, storages, local development, and deployment.
|
|
253
|
+
|
|
254
|
+
## Support and community
|
|
255
|
+
|
|
256
|
+
- **GitHub issues** — report a bug or request a feature in the repository's [issue tracker](https://github.com/apify/apify-client-python/issues).
|
|
257
|
+
|
|
258
|
+
## Contributing
|
|
259
|
+
|
|
260
|
+
Bug reports, fixes, and improvements are welcome! See [CONTRIBUTING.md](./CONTRIBUTING.md) for the development setup, coding standards, testing, and the release process. The repo uses [uv](https://docs.astral.sh/uv/) for project management and [Poe the Poet](https://poethepoet.natn.io/) as a task runner; the typical loop is:
|
|
261
|
+
|
|
262
|
+
```bash
|
|
263
|
+
uv run poe install-dev # install dev deps and git hooks
|
|
264
|
+
uv run poe check-code # lint, type-check, unit tests, docstring check
|
|
265
|
+
```
|
|
266
|
+
|
|
267
|
+
## License
|
|
268
|
+
|
|
269
|
+
Released under the [Apache License 2.0](./LICENSE).
|