scrapely-client-python 1.0.8__tar.gz → 1.0.9__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.
Files changed (71) hide show
  1. {scrapely_client_python-1.0.8 → scrapely_client_python-1.0.9}/CHANGELOG.md +5 -0
  2. {scrapely_client_python-1.0.8 → scrapely_client_python-1.0.9}/PKG-INFO +18 -1
  3. {scrapely_client_python-1.0.8 → scrapely_client_python-1.0.9}/README.md +17 -0
  4. {scrapely_client_python-1.0.8 → scrapely_client_python-1.0.9}/pyproject.toml +1 -1
  5. {scrapely_client_python-1.0.8 → scrapely_client_python-1.0.9}/pyproject.toml.orig +1 -1
  6. {scrapely_client_python-1.0.8 → scrapely_client_python-1.0.9}/src/scrapely_client/_consts.py +3 -0
  7. {scrapely_client_python-1.0.8 → scrapely_client_python-1.0.9}/src/scrapely_client/_scrapely_client.py +25 -14
  8. {scrapely_client_python-1.0.8 → scrapely_client_python-1.0.9}/CONTRIBUTING.md +0 -0
  9. {scrapely_client_python-1.0.8 → scrapely_client_python-1.0.9}/LICENSE +0 -0
  10. {scrapely_client_python-1.0.8 → scrapely_client_python-1.0.9}/NOTICE +0 -0
  11. {scrapely_client_python-1.0.8 → scrapely_client_python-1.0.9}/src/scrapely_client/__init__.py +0 -0
  12. {scrapely_client_python-1.0.8 → scrapely_client_python-1.0.9}/src/scrapely_client/_charging.py +0 -0
  13. {scrapely_client_python-1.0.8 → scrapely_client_python-1.0.9}/src/scrapely_client/_client_registry.py +0 -0
  14. {scrapely_client_python-1.0.8 → scrapely_client_python-1.0.9}/src/scrapely_client/_docs.py +0 -0
  15. {scrapely_client_python-1.0.8 → scrapely_client_python-1.0.9}/src/scrapely_client/_literals.py +0 -0
  16. {scrapely_client_python-1.0.8 → scrapely_client_python-1.0.9}/src/scrapely_client/_logging.py +0 -0
  17. {scrapely_client_python-1.0.8 → scrapely_client_python-1.0.9}/src/scrapely_client/_models.py +0 -0
  18. {scrapely_client_python-1.0.8 → scrapely_client_python-1.0.9}/src/scrapely_client/_pagination.py +0 -0
  19. {scrapely_client_python-1.0.8 → scrapely_client_python-1.0.9}/src/scrapely_client/_resource_clients/__init__.py +0 -0
  20. {scrapely_client_python-1.0.8 → scrapely_client_python-1.0.9}/src/scrapely_client/_resource_clients/_resource_client.py +0 -0
  21. {scrapely_client_python-1.0.8 → scrapely_client_python-1.0.9}/src/scrapely_client/_resource_clients/actor.py +0 -0
  22. {scrapely_client_python-1.0.8 → scrapely_client_python-1.0.9}/src/scrapely_client/_resource_clients/actor_collection.py +0 -0
  23. {scrapely_client_python-1.0.8 → scrapely_client_python-1.0.9}/src/scrapely_client/_resource_clients/actor_env_var.py +0 -0
  24. {scrapely_client_python-1.0.8 → scrapely_client_python-1.0.9}/src/scrapely_client/_resource_clients/actor_env_var_collection.py +0 -0
  25. {scrapely_client_python-1.0.8 → scrapely_client_python-1.0.9}/src/scrapely_client/_resource_clients/actor_version.py +0 -0
  26. {scrapely_client_python-1.0.8 → scrapely_client_python-1.0.9}/src/scrapely_client/_resource_clients/actor_version_collection.py +0 -0
  27. {scrapely_client_python-1.0.8 → scrapely_client_python-1.0.9}/src/scrapely_client/_resource_clients/automation.py +0 -0
  28. {scrapely_client_python-1.0.8 → scrapely_client_python-1.0.9}/src/scrapely_client/_resource_clients/automation_collection.py +0 -0
  29. {scrapely_client_python-1.0.8 → scrapely_client_python-1.0.9}/src/scrapely_client/_resource_clients/build.py +0 -0
  30. {scrapely_client_python-1.0.8 → scrapely_client_python-1.0.9}/src/scrapely_client/_resource_clients/build_collection.py +0 -0
  31. {scrapely_client_python-1.0.8 → scrapely_client_python-1.0.9}/src/scrapely_client/_resource_clients/dataset.py +0 -0
  32. {scrapely_client_python-1.0.8 → scrapely_client_python-1.0.9}/src/scrapely_client/_resource_clients/dataset_collection.py +0 -0
  33. {scrapely_client_python-1.0.8 → scrapely_client_python-1.0.9}/src/scrapely_client/_resource_clients/key_value_store.py +0 -0
  34. {scrapely_client_python-1.0.8 → scrapely_client_python-1.0.9}/src/scrapely_client/_resource_clients/key_value_store_collection.py +0 -0
  35. {scrapely_client_python-1.0.8 → scrapely_client_python-1.0.9}/src/scrapely_client/_resource_clients/log.py +0 -0
  36. {scrapely_client_python-1.0.8 → scrapely_client_python-1.0.9}/src/scrapely_client/_resource_clients/request_queue.py +0 -0
  37. {scrapely_client_python-1.0.8 → scrapely_client_python-1.0.9}/src/scrapely_client/_resource_clients/request_queue_collection.py +0 -0
  38. {scrapely_client_python-1.0.8 → scrapely_client_python-1.0.9}/src/scrapely_client/_resource_clients/run.py +0 -0
  39. {scrapely_client_python-1.0.8 → scrapely_client_python-1.0.9}/src/scrapely_client/_resource_clients/run_collection.py +0 -0
  40. {scrapely_client_python-1.0.8 → scrapely_client_python-1.0.9}/src/scrapely_client/_resource_clients/schedule.py +0 -0
  41. {scrapely_client_python-1.0.8 → scrapely_client_python-1.0.9}/src/scrapely_client/_resource_clients/schedule_collection.py +0 -0
  42. {scrapely_client_python-1.0.8 → scrapely_client_python-1.0.9}/src/scrapely_client/_resource_clients/store_collection.py +0 -0
  43. {scrapely_client_python-1.0.8 → scrapely_client_python-1.0.9}/src/scrapely_client/_resource_clients/task.py +0 -0
  44. {scrapely_client_python-1.0.8 → scrapely_client_python-1.0.9}/src/scrapely_client/_resource_clients/task_collection.py +0 -0
  45. {scrapely_client_python-1.0.8 → scrapely_client_python-1.0.9}/src/scrapely_client/_resource_clients/user.py +0 -0
  46. {scrapely_client_python-1.0.8 → scrapely_client_python-1.0.9}/src/scrapely_client/_resource_clients/webhook.py +0 -0
  47. {scrapely_client_python-1.0.8 → scrapely_client_python-1.0.9}/src/scrapely_client/_resource_clients/webhook_collection.py +0 -0
  48. {scrapely_client_python-1.0.8 → scrapely_client_python-1.0.9}/src/scrapely_client/_resource_clients/webhook_dispatch.py +0 -0
  49. {scrapely_client_python-1.0.8 → scrapely_client_python-1.0.9}/src/scrapely_client/_resource_clients/webhook_dispatch_collection.py +0 -0
  50. {scrapely_client_python-1.0.8 → scrapely_client_python-1.0.9}/src/scrapely_client/_statistics.py +0 -0
  51. {scrapely_client_python-1.0.8 → scrapely_client_python-1.0.9}/src/scrapely_client/_status_message_watcher.py +0 -0
  52. {scrapely_client_python-1.0.8 → scrapely_client_python-1.0.9}/src/scrapely_client/_streamed_log.py +0 -0
  53. {scrapely_client_python-1.0.8 → scrapely_client_python-1.0.9}/src/scrapely_client/_typeddicts.py +0 -0
  54. {scrapely_client_python-1.0.8 → scrapely_client_python-1.0.9}/src/scrapely_client/_utils/__init__.py +0 -0
  55. {scrapely_client_python-1.0.8 → scrapely_client_python-1.0.9}/src/scrapely_client/_utils/crypto.py +0 -0
  56. {scrapely_client_python-1.0.8 → scrapely_client_python-1.0.9}/src/scrapely_client/_utils/encoding.py +0 -0
  57. {scrapely_client_python-1.0.8 → scrapely_client_python-1.0.9}/src/scrapely_client/_utils/errors.py +0 -0
  58. {scrapely_client_python-1.0.8 → scrapely_client_python-1.0.9}/src/scrapely_client/_utils/http.py +0 -0
  59. {scrapely_client_python-1.0.8 → scrapely_client_python-1.0.9}/src/scrapely_client/_utils/time.py +0 -0
  60. {scrapely_client_python-1.0.8 → scrapely_client_python-1.0.9}/src/scrapely_client/_utils/try_import.py +0 -0
  61. {scrapely_client_python-1.0.8 → scrapely_client_python-1.0.9}/src/scrapely_client/errors.py +0 -0
  62. {scrapely_client_python-1.0.8 → scrapely_client_python-1.0.9}/src/scrapely_client/http_clients/__init__.py +0 -0
  63. {scrapely_client_python-1.0.8 → scrapely_client_python-1.0.9}/src/scrapely_client/http_clients/_base.py +0 -0
  64. {scrapely_client_python-1.0.8 → scrapely_client_python-1.0.9}/src/scrapely_client/http_clients/_impit.py +0 -0
  65. {scrapely_client_python-1.0.8 → scrapely_client_python-1.0.9}/src/scrapely_client/http_compressors/__init__.py +0 -0
  66. {scrapely_client_python-1.0.8 → scrapely_client_python-1.0.9}/src/scrapely_client/http_compressors/_base.py +0 -0
  67. {scrapely_client_python-1.0.8 → scrapely_client_python-1.0.9}/src/scrapely_client/http_compressors/_brotli.py +0 -0
  68. {scrapely_client_python-1.0.8 → scrapely_client_python-1.0.9}/src/scrapely_client/http_compressors/_gzip.py +0 -0
  69. {scrapely_client_python-1.0.8 → scrapely_client_python-1.0.9}/src/scrapely_client/http_compressors/_resolve.py +0 -0
  70. {scrapely_client_python-1.0.8 → scrapely_client_python-1.0.9}/src/scrapely_client/py.typed +0 -0
  71. {scrapely_client_python-1.0.8 → scrapely_client_python-1.0.9}/src/scrapely_client/types.py +0 -0
@@ -2,6 +2,11 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file.
4
4
 
5
+ ## [1.0.9] - 2026-10-24
6
+
7
+ - The `SCRAPELY_API_URL` environment variable sets the API URL when `api_url` is not passed to `ScrapelyClient`, `ScrapelyClientAsync` or `with_custom_http_client`; `api_url` still wins, and without either the client uses `https://api.scrape.ly`. An empty value is ignored. `api_public_url` is unchanged.
8
+ - Version 1.0.3 defaulted to `https://api-staging.scrape.ly`; upgrade to 1.0.6 or later.
9
+
5
10
  ## [1.0.8] - 2026-10-20
6
11
 
7
12
  - Request ids are percent-encoded as one URL path segment in `get_request`, `update_request`, `delete_request`, `prolong_request_lock` and `delete_request_lock` (sync and async); `''`, `.` and `..` raise `ValueError`. `update_request` checks the id against the API's grammar (1-128 letters, digits, `-`, `_`, `~`) and refuses a request without an id instead of sending `requests/None`. Resource ids (`client.dataset(id)`, versions, env vars) and automation run ids are encoded the same way. An id such as `..` used to send the call to another resource.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: scrapely-client-python
3
- Version: 1.0.8
3
+ Version: 1.0.9
4
4
  Summary: Scrapely API client for Python
5
5
  Keywords: scrapely,api,client,automation,crawling,scraping
6
6
  Author: TeraShift GmbH (Scrape.ly)
@@ -94,6 +94,8 @@ Description-Content-Type: text/markdown
94
94
 
95
95
  You'll need a Scrapely API token — find yours in the integrations section of the Scrapely dashboard. Pass it to the client and you're ready to go.
96
96
 
97
+ 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.
98
+
97
99
  ### Synchronous client
98
100
 
99
101
  ```python
@@ -190,6 +192,21 @@ for item in client.dataset('DATASET-ID').iterate_items(fields=['title', 'url']):
190
192
  process(item)
191
193
  ```
192
194
 
195
+ ### Create and run an automation
196
+
197
+ ```python
198
+ automation = client.automations().create({
199
+ 'title': 'Daily dentists',
200
+ 'trigger': {'kind': 'schedule', 'cron': '0 9 * * *', 'timezone': 'Europe/Berlin'},
201
+ 'steps': [{'kind': 'savedInput', 'savedInputId': 'SAVED-INPUT-ID'}],
202
+ 'ai': {'mode': 'summarize', 'prompt': 'List the new practices with their phone numbers.'},
203
+ 'deliveries': [{'channel': 'email'}],
204
+ })
205
+ run = client.automation(automation['id']).run()
206
+ ```
207
+
208
+ Automations take and return the API's camelCase dictionaries (see the automations section of the API reference).
209
+
193
210
  ### Tune retries and timeouts
194
211
 
195
212
  ```python
@@ -61,6 +61,8 @@
61
61
 
62
62
  You'll need a Scrapely API token — find yours in the integrations section of the Scrapely dashboard. Pass it to the client and you're ready to go.
63
63
 
64
+ 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.
65
+
64
66
  ### Synchronous client
65
67
 
66
68
  ```python
@@ -157,6 +159,21 @@ for item in client.dataset('DATASET-ID').iterate_items(fields=['title', 'url']):
157
159
  process(item)
158
160
  ```
159
161
 
162
+ ### Create and run an automation
163
+
164
+ ```python
165
+ automation = client.automations().create({
166
+ 'title': 'Daily dentists',
167
+ 'trigger': {'kind': 'schedule', 'cron': '0 9 * * *', 'timezone': 'Europe/Berlin'},
168
+ 'steps': [{'kind': 'savedInput', 'savedInputId': 'SAVED-INPUT-ID'}],
169
+ 'ai': {'mode': 'summarize', 'prompt': 'List the new practices with their phone numbers.'},
170
+ 'deliveries': [{'channel': 'email'}],
171
+ })
172
+ run = client.automation(automation['id']).run()
173
+ ```
174
+
175
+ Automations take and return the API's camelCase dictionaries (see the automations section of the API reference).
176
+
160
177
  ### Tune retries and timeouts
161
178
 
162
179
  ```python
@@ -4,7 +4,7 @@ build-backend = "uv_build"
4
4
 
5
5
  [project]
6
6
  name = "scrapely-client-python"
7
- version = "1.0.8"
7
+ version = "1.0.9"
8
8
  description = "Scrapely API client for Python"
9
9
  license = "Apache-2.0"
10
10
  license-files = [
@@ -4,7 +4,7 @@ build-backend = "uv_build"
4
4
 
5
5
  [project]
6
6
  name = "scrapely-client-python"
7
- version = "1.0.8"
7
+ version = "1.0.9"
8
8
  description = "Scrapely API client for Python"
9
9
  authors = [{ name = "TeraShift GmbH (Scrape.ly)" }]
10
10
  license = "Apache-2.0"
@@ -7,6 +7,9 @@ from datetime import timedelta
7
7
  DEFAULT_API_URL = 'https://api.scrape.ly'
8
8
  """Default base URL for the Scrapely API."""
9
9
 
10
+ API_URL_ENV_VAR = 'SCRAPELY_API_URL'
11
+ """Environment variable that sets the API URL when `api_url` is not passed to the client."""
12
+
10
13
  API_VERSION = 'v2'
11
14
  """Current Scrapely API version."""
12
15
 
@@ -2,12 +2,14 @@
2
2
  # Modified by TeraShift GmbH. See the LICENSE and NOTICE files.
3
3
  from __future__ import annotations
4
4
 
5
+ import os
5
6
  from functools import cached_property
6
7
  from typing import TYPE_CHECKING
7
8
 
8
9
  from scrapely_client._charging import ChargingHooks, wrap_dataset_client_with_charging
9
10
  from scrapely_client._client_registry import ClientRegistry, ClientRegistryAsync
10
11
  from scrapely_client._consts import (
12
+ API_URL_ENV_VAR,
11
13
  API_VERSION,
12
14
  DEFAULT_API_URL,
13
15
  DEFAULT_MAX_RETRIES,
@@ -90,6 +92,13 @@ if TYPE_CHECKING:
90
92
  from scrapely_client.types import HttpCompressionAlgorithm
91
93
 
92
94
 
95
+ def _resolve_api_url(api_url: str | None) -> str:
96
+ """Return `api_url` if given, else the `SCRAPELY_API_URL` environment variable, else the production API."""
97
+ if api_url is not None:
98
+ return api_url
99
+ return os.environ.get(API_URL_ENV_VAR, '').strip() or DEFAULT_API_URL
100
+
101
+
93
102
  @docs_group('Scrapely API clients')
94
103
  class ApifyClient:
95
104
  """Synchronous client for the Scrapely API.
@@ -124,7 +133,7 @@ class ApifyClient:
124
133
  self,
125
134
  token: str | None = None,
126
135
  *,
127
- api_url: str = DEFAULT_API_URL,
136
+ api_url: str | None = None,
128
137
  api_public_url: str | None = DEFAULT_API_URL,
129
138
  max_retries: int = DEFAULT_MAX_RETRIES,
130
139
  min_delay_between_retries: timedelta = DEFAULT_MIN_DELAY_BETWEEN_RETRIES,
@@ -144,9 +153,9 @@ class ApifyClient:
144
153
  Args:
145
154
  token: The Scrapely API token. You can find your token on the
146
155
  Integrations page in the Scrapely dashboard.
147
- api_url: The URL of the Scrapely API server to connect to. Defaults to https://api.scrape.ly. It can
148
- be an internal URL that is not globally accessible, in which case `api_public_url` should be set
149
- as well.
156
+ api_url: The URL of the Scrapely API server to connect to. When not given, the `SCRAPELY_API_URL`
157
+ environment variable is used, then https://api.scrape.ly. It can be an internal URL that is not
158
+ globally accessible, in which case `api_public_url` should be set as well.
150
159
  api_public_url: The globally accessible URL of the Scrapely API server. Should be set only if `api_url`
151
160
  is an internal URL that is not globally accessible. Defaults to https://api.scrape.ly.
152
161
  max_retries: How many times to retry a failed request at most.
@@ -165,7 +174,7 @@ class ApifyClient:
165
174
  default_dataset_id: ID of the actor run's default dataset, used to gate charging interception.
166
175
  """
167
176
  # We need to do this because of mocking in tests and default mutable arguments.
168
- api_url = DEFAULT_API_URL if api_url is None else api_url
177
+ api_url = _resolve_api_url(api_url)
169
178
  api_public_url = DEFAULT_API_URL if api_public_url is None else api_public_url
170
179
 
171
180
  if headers:
@@ -234,7 +243,7 @@ class ApifyClient:
234
243
  cls,
235
244
  token: str | None = None,
236
245
  *,
237
- api_url: str = DEFAULT_API_URL,
246
+ api_url: str | None = None,
238
247
  api_public_url: str | None = DEFAULT_API_URL,
239
248
  http_client: HttpClient,
240
249
  ) -> ApifyClient:
@@ -263,7 +272,8 @@ class ApifyClient:
263
272
  Args:
264
273
  token: The Scrapely API token. It is set as the `Authorization` header on the custom client,
265
274
  unless the client already has one configured.
266
- api_url: The URL of the Scrapely API server to connect to. Defaults to https://api.scrape.ly.
275
+ api_url: The URL of the Scrapely API server to connect to. When not given, the `SCRAPELY_API_URL`
276
+ environment variable is used, then https://api.scrape.ly.
267
277
  api_public_url: The globally accessible URL of the Scrapely API server. Defaults to https://api.scrape.ly.
268
278
  http_client: A custom HTTP client instance extending `HttpClient`.
269
279
  """
@@ -513,7 +523,7 @@ class ApifyClientAsync:
513
523
  self,
514
524
  token: str | None = None,
515
525
  *,
516
- api_url: str = DEFAULT_API_URL,
526
+ api_url: str | None = None,
517
527
  api_public_url: str | None = DEFAULT_API_URL,
518
528
  max_retries: int = DEFAULT_MAX_RETRIES,
519
529
  min_delay_between_retries: timedelta = DEFAULT_MIN_DELAY_BETWEEN_RETRIES,
@@ -533,9 +543,9 @@ class ApifyClientAsync:
533
543
  Args:
534
544
  token: The Scrapely API token. You can find your token on the
535
545
  Integrations page in the Scrapely dashboard.
536
- api_url: The URL of the Scrapely API server to connect to. Defaults to https://api.scrape.ly. It can
537
- be an internal URL that is not globally accessible, in which case `api_public_url` should be set
538
- as well.
546
+ api_url: The URL of the Scrapely API server to connect to. When not given, the `SCRAPELY_API_URL`
547
+ environment variable is used, then https://api.scrape.ly. It can be an internal URL that is not
548
+ globally accessible, in which case `api_public_url` should be set as well.
539
549
  api_public_url: The globally accessible URL of the Scrapely API server. Should be set only if `api_url`
540
550
  is an internal URL that is not globally accessible. Defaults to https://api.scrape.ly.
541
551
  max_retries: How many times to retry a failed request at most.
@@ -554,7 +564,7 @@ class ApifyClientAsync:
554
564
  default_dataset_id: ID of the actor run's default dataset, used to gate charging interception.
555
565
  """
556
566
  # We need to do this because of mocking in tests and default mutable arguments.
557
- api_url = DEFAULT_API_URL if api_url is None else api_url
567
+ api_url = _resolve_api_url(api_url)
558
568
  api_public_url = DEFAULT_API_URL if api_public_url is None else api_public_url
559
569
 
560
570
  if headers:
@@ -623,7 +633,7 @@ class ApifyClientAsync:
623
633
  cls,
624
634
  token: str | None = None,
625
635
  *,
626
- api_url: str = DEFAULT_API_URL,
636
+ api_url: str | None = None,
627
637
  api_public_url: str | None = DEFAULT_API_URL,
628
638
  http_client: HttpClientAsync,
629
639
  ) -> ApifyClientAsync:
@@ -652,7 +662,8 @@ class ApifyClientAsync:
652
662
  Args:
653
663
  token: The Scrapely API token. It is set as the `Authorization` header on the custom client,
654
664
  unless the client already has one configured.
655
- api_url: The URL of the Scrapely API server to connect to. Defaults to https://api.scrape.ly.
665
+ api_url: The URL of the Scrapely API server to connect to. When not given, the `SCRAPELY_API_URL`
666
+ environment variable is used, then https://api.scrape.ly.
656
667
  api_public_url: The globally accessible URL of the Scrapely API server. Defaults to https://api.scrape.ly.
657
668
  http_client: A custom HTTP client instance extending `HttpClientAsync`.
658
669
  """