tinyfish 0.6.0__tar.gz → 0.8.0__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 (54) hide show
  1. {tinyfish-0.6.0 → tinyfish-0.8.0}/CHANGELOG.md +28 -0
  2. {tinyfish-0.6.0 → tinyfish-0.8.0}/CLAUDE.md +3 -4
  3. {tinyfish-0.6.0 → tinyfish-0.8.0}/PKG-INFO +80 -4
  4. {tinyfish-0.6.0 → tinyfish-0.8.0}/README.md +78 -2
  5. {tinyfish-0.6.0 → tinyfish-0.8.0}/docs/exceptions-and-errors-guide.md +1 -1
  6. {tinyfish-0.6.0 → tinyfish-0.8.0}/docs/internal/exceptions-and-errors-guide.md +1 -1
  7. {tinyfish-0.6.0 → tinyfish-0.8.0}/pyproject.toml +1 -1
  8. {tinyfish-0.6.0 → tinyfish-0.8.0}/src/tinyfish/__init__.py +12 -0
  9. {tinyfish-0.6.0 → tinyfish-0.8.0}/src/tinyfish/_utils/client/_base.py +8 -5
  10. {tinyfish-0.6.0 → tinyfish-0.8.0}/src/tinyfish/_utils/exceptions.py +49 -18
  11. {tinyfish-0.6.0 → tinyfish-0.8.0}/src/tinyfish/agent/__init__.py +65 -0
  12. {tinyfish-0.6.0 → tinyfish-0.8.0}/src/tinyfish/agent/types.py +43 -0
  13. {tinyfish-0.6.0 → tinyfish-0.8.0}/src/tinyfish/fetch/__init__.py +39 -3
  14. {tinyfish-0.6.0 → tinyfish-0.8.0}/src/tinyfish/fetch/types.py +23 -1
  15. {tinyfish-0.6.0 → tinyfish-0.8.0}/src/tinyfish/runs/types.py +2 -0
  16. {tinyfish-0.6.0 → tinyfish-0.8.0}/src/tinyfish/wallet/types.py +6 -8
  17. {tinyfish-0.6.0 → tinyfish-0.8.0}/tests/test_agent.py +47 -4
  18. {tinyfish-0.6.0 → tinyfish-0.8.0}/tests/test_errors.py +20 -0
  19. {tinyfish-0.6.0 → tinyfish-0.8.0}/tests/test_fetch.py +99 -1
  20. {tinyfish-0.6.0 → tinyfish-0.8.0}/tests/test_wallet.py +20 -4
  21. {tinyfish-0.6.0 → tinyfish-0.8.0}/uv.lock +1 -1
  22. {tinyfish-0.6.0 → tinyfish-0.8.0}/.gitignore +0 -0
  23. {tinyfish-0.6.0 → tinyfish-0.8.0}/.pre-commit-config.yaml +0 -0
  24. {tinyfish-0.6.0 → tinyfish-0.8.0}/AGENTS.md +0 -0
  25. {tinyfish-0.6.0 → tinyfish-0.8.0}/RELEASE.md +0 -0
  26. {tinyfish-0.6.0 → tinyfish-0.8.0}/docs/internal/api-integration-header.md +0 -0
  27. {tinyfish-0.6.0 → tinyfish-0.8.0}/docs/internal/publishing-private-guide.md +0 -0
  28. {tinyfish-0.6.0 → tinyfish-0.8.0}/docs/pagination-guide.md +0 -0
  29. {tinyfish-0.6.0 → tinyfish-0.8.0}/docs/proxy-and-browser-profiles.md +0 -0
  30. {tinyfish-0.6.0 → tinyfish-0.8.0}/docs/streaming-guide.md +0 -0
  31. {tinyfish-0.6.0 → tinyfish-0.8.0}/src/tinyfish/_utils/__init__.py +0 -0
  32. {tinyfish-0.6.0 → tinyfish-0.8.0}/src/tinyfish/_utils/client/__init__.py +0 -0
  33. {tinyfish-0.6.0 → tinyfish-0.8.0}/src/tinyfish/_utils/client/async_.py +0 -0
  34. {tinyfish-0.6.0 → tinyfish-0.8.0}/src/tinyfish/_utils/client/sync.py +0 -0
  35. {tinyfish-0.6.0 → tinyfish-0.8.0}/src/tinyfish/_utils/resource.py +0 -0
  36. {tinyfish-0.6.0 → tinyfish-0.8.0}/src/tinyfish/_utils/sse_parser.py +0 -0
  37. {tinyfish-0.6.0 → tinyfish-0.8.0}/src/tinyfish/browser/__init__.py +0 -0
  38. {tinyfish-0.6.0 → tinyfish-0.8.0}/src/tinyfish/browser/types.py +0 -0
  39. {tinyfish-0.6.0 → tinyfish-0.8.0}/src/tinyfish/client.py +0 -0
  40. {tinyfish-0.6.0 → tinyfish-0.8.0}/src/tinyfish/py.typed +0 -0
  41. {tinyfish-0.6.0 → tinyfish-0.8.0}/src/tinyfish/runs/__init__.py +0 -0
  42. {tinyfish-0.6.0 → tinyfish-0.8.0}/src/tinyfish/search/__init__.py +0 -0
  43. {tinyfish-0.6.0 → tinyfish-0.8.0}/src/tinyfish/search/types.py +0 -0
  44. {tinyfish-0.6.0 → tinyfish-0.8.0}/src/tinyfish/vault/__init__.py +0 -0
  45. {tinyfish-0.6.0 → tinyfish-0.8.0}/src/tinyfish/vault/types.py +0 -0
  46. {tinyfish-0.6.0 → tinyfish-0.8.0}/src/tinyfish/wallet/__init__.py +0 -0
  47. {tinyfish-0.6.0 → tinyfish-0.8.0}/tests/__init__.py +0 -0
  48. {tinyfish-0.6.0 → tinyfish-0.8.0}/tests/conftest.py +0 -0
  49. {tinyfish-0.6.0 → tinyfish-0.8.0}/tests/test_browser.py +0 -0
  50. {tinyfish-0.6.0 → tinyfish-0.8.0}/tests/test_client.py +0 -0
  51. {tinyfish-0.6.0 → tinyfish-0.8.0}/tests/test_runs.py +0 -0
  52. {tinyfish-0.6.0 → tinyfish-0.8.0}/tests/test_search.py +0 -0
  53. {tinyfish-0.6.0 → tinyfish-0.8.0}/tests/test_vault.py +0 -0
  54. {tinyfish-0.6.0 → tinyfish-0.8.0}/tests/testing_guide.md +0 -0
@@ -1,5 +1,33 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.8.0](https://github.com/tinyfish-io/ux-labs/compare/sdk-py/v0.7.0...sdk-py/v0.8.0) (2026-09-02)
4
+
5
+
6
+ ### Features
7
+
8
+ * **sdk-python:** add fetch highlights ([#4785](https://github.com/tinyfish-io/ux-labs/issues/4785)) ([29d6400](https://github.com/tinyfish-io/ux-labs/commit/29d6400ba410b5c0a80f57c82f7183be3683cb97))
9
+
10
+ ## [0.7.0](https://github.com/tinyfish-io/ux-labs/compare/sdk-py/v0.6.1...sdk-py/v0.7.0) (2026-08-18)
11
+
12
+
13
+ ### Features
14
+
15
+ * **sdk-cli:** add agent run parity fields ([#3260](https://github.com/tinyfish-io/ux-labs/issues/3260)) ([1ec839e](https://github.com/tinyfish-io/ux-labs/commit/1ec839ed578811d6fea859a8240bd1a9c89086e0))
16
+
17
+
18
+ ### Documentation
19
+
20
+ * compress agent-facing docs, cap code comments at 11 words ([#4364](https://github.com/tinyfish-io/ux-labs/issues/4364)) ([4ea055c](https://github.com/tinyfish-io/ux-labs/commit/4ea055c515e1af78da8b5f6049b84a8433c64221))
21
+ * **wallet:** wallet surfaces on docs.tinyfish.ai, dual-mode billing copy (PF-3480) ([#4316](https://github.com/tinyfish-io/ux-labs/issues/4316)) ([267db96](https://github.com/tinyfish-io/ux-labs/commit/267db967c8eeba73ae8de33b800812f95b65fa19))
22
+
23
+ ## [0.6.1](https://github.com/tinyfish-io/ux-labs/compare/sdk-py/v0.6.0...sdk-py/v0.6.1) (2026-08-12)
24
+
25
+
26
+ ### Bug Fixes
27
+
28
+ * **sdk:** emit wallet types without vendor-internal fields ([#4257](https://github.com/tinyfish-io/ux-labs/issues/4257)) ([dfefbab](https://github.com/tinyfish-io/ux-labs/commit/dfefbab17420cf617cc1acd0184d580c7b597cdc))
29
+ * **wallet:** gate unreleased wallet reads behind wallet_enabled with typed 404 (PF-3513) ([#4245](https://github.com/tinyfish-io/ux-labs/issues/4245)) ([6d9dc56](https://github.com/tinyfish-io/ux-labs/commit/6d9dc5603996659c8eec8828308fb053d82ed8dc))
30
+
3
31
  ## [0.6.0](https://github.com/tinyfish-io/ux-labs/compare/sdk-py/v0.5.0...sdk-py/v0.6.0) (2026-08-11)
4
32
 
5
33
 
@@ -1,9 +1,8 @@
1
1
  # TinyFish Python SDK (`tinyfish`)
2
2
 
3
- Official Python SDK for TinyFish. Provides sync (`TinyFish`) and async (`AsyncTinyFish`) clients for running
4
- automations, streaming events, and managing runs.
3
+ Official Python SDK. Sync (`TinyFish`) and async (`AsyncTinyFish`) clients for running automations, streaming events, managing runs.
5
4
 
6
- For full method reference and examples: see `README.md`.
5
+ Full method reference and examples: `README.md`.
7
6
 
8
7
  ---
9
8
 
@@ -57,4 +56,4 @@ cd sdk/sdk-python && uv run ruff check . && uv run ruff format .
57
56
 
58
57
  ## Further Reading
59
58
 
60
- See `README.md` for full usage examples, authentication patterns, and SDK changelog.
59
+ `README.md` — usage examples, authentication patterns, SDK changelog.
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.4
1
+ Metadata-Version: 2.5
2
2
  Name: tinyfish
3
- Version: 0.6.0
3
+ Version: 0.8.0
4
4
  Summary: Official Python SDK for the TinyFish API
5
5
  Requires-Python: >=3.11
6
6
  Requires-Dist: httpx>=0.27.0
@@ -57,7 +57,7 @@ Every method below is available on both `TinyFish` (sync) and `AsyncTinyFish` (a
57
57
  | [`runs.get()`](#runsget--retrieve-a-single-run) | Retrieve a single run by ID | `Run` | — |
58
58
  | [`runs.list()`](#runslist--list-and-filter-runs) | List runs with filtering, sorting, pagination | `RunListResponse` | — |
59
59
  | [`search.query()`](#searchquery--search-the-web) | Search the web for ranked results | `SearchQueryResponse` | Yes |
60
- | `wallet.get()` | Get the caller's wallet balance, auto-reload, and rates | `WalletResponse` | — |
60
+ | [`wallet.get()`](#walletget--get-your-balance) | Get the caller's wallet balance, auto-reload, and rates | `WalletResponse` | — |
61
61
 
62
62
  ---
63
63
 
@@ -212,6 +212,8 @@ print(response.errors)
212
212
 
213
213
  `fetch.get_contents()` accepts 1 to 10 URLs. Set `per_url_timeout_ms` to apply an independent timeout budget to each URL in the batch; slow URLs return in `errors` with `timeout` while siblings can still complete.
214
214
 
215
+ Pass `highlights={"query": "pricing tiers"}` (beta, markdown format only) to get query-ranked `HighlightSnippet` lists on each result instead of the full `text`; set `include_full_page_text=True` to keep both. Accounts not enrolled in the beta get `PermissionDeniedError`.
216
+
215
217
  **Returns `FetchResponse`:**
216
218
 
217
219
  | Field | Type | Description |
@@ -354,6 +356,55 @@ Filter validation rules:
354
356
 
355
357
  ---
356
358
 
359
+ ### `wallet.get()` — get your balance
360
+
361
+ Returns the caller's current balance, auto-reload configuration, per-product rates, and any in-flight top-up.
362
+
363
+ ```python
364
+ from tinyfish import TinyFish, WalletAutoReloadState
365
+
366
+ client = TinyFish()
367
+
368
+ wallet = client.wallet.get()
369
+
370
+ print(f"{wallet.available_balance} {wallet.currency}")
371
+
372
+ if wallet.auto_reload and wallet.auto_reload.state == WalletAutoReloadState.ON:
373
+ print(f"Auto-reload at {wallet.auto_reload.threshold}, tops up to {wallet.auto_reload.recharge_to}")
374
+
375
+ if wallet.pending_top_up:
376
+ print(f"Pending top-up: {wallet.pending_top_up.amount}")
377
+ ```
378
+
379
+ **Returns `WalletResponse`:**
380
+
381
+ | Field | Type | Description |
382
+ |-------|------|-------------|
383
+ | `available_balance` | `str` | Current spendable balance. Negative means the wallet is overdrawn. |
384
+ | `currency` | `str` | ISO 4217 currency code, e.g. `USD` |
385
+ | `as_of` | `str` | ISO timestamp the wallet was read |
386
+ | `auto_reload` | `WalletAutoReload \| None` | `None` means the auto-reload read failed — not the same as `state == "unconfigured"`, which means the read succeeded and nothing is set |
387
+ | `pending_top_up` | `WalletPendingTopUp \| None` | `None` means no in-flight top-up, or the ledger read failed |
388
+ | `rates` | `WalletRates \| None` | `None` means the rates read failed, or the wallet has no rate contract yet |
389
+
390
+ `auto_reload.state` is one of `WalletAutoReloadState.UNCONFIGURED`, `ON`, `OFF`, `PAUSED_PAYMENT_FAILED`, or `NEEDS_PAYMENT_METHOD`. `threshold` and `recharge_to` are only present for the four configured states.
391
+
392
+ Accounts are on either wallet billing or a legacy subscription/credits plan. `wallet.get()` raises `NotFoundError` (404) with `.code` of `"FEATURE_NOT_AVAILABLE"` when the account is on the legacy plan. A wallet account that hasn't added money yet is not an error — it returns normally with an `available_balance` of `"0"`.
393
+
394
+ ```python
395
+ from tinyfish import NotFoundError
396
+
397
+ try:
398
+ wallet = client.wallet.get()
399
+ except NotFoundError as e:
400
+ if e.code == "FEATURE_NOT_AVAILABLE":
401
+ print("Account is on the legacy subscription/credits plan, not a wallet.")
402
+ else:
403
+ raise
404
+ ```
405
+
406
+ ---
407
+
357
408
  ## Sync vs Async
358
409
 
359
410
  Use `AsyncTinyFish` when you're in an async context (FastAPI, aiohttp, etc.):
@@ -376,7 +427,7 @@ client = AsyncTinyFish()
376
427
  response = await client.agent.run(goal="...", url="...")
377
428
  ```
378
429
 
379
- All seven methods (`agent.run()`, `agent.queue()`, `agent.stream()`, `fetch.get_contents()`, `runs.get()`, `runs.list()`, `search.query()`) work the same way — same parameters, just `await`-ed.
430
+ All eight methods (`agent.run()`, `agent.queue()`, `agent.stream()`, `fetch.get_contents()`, `runs.get()`, `runs.list()`, `search.query()`, `wallet.get()`) work the same way — same parameters, just `await`-ed.
380
431
 
381
432
  ## Configuration
382
433
 
@@ -414,6 +465,31 @@ response = client.agent.run(
414
465
  )
415
466
  ```
416
467
 
468
+ ### Agent controls and capture
469
+
470
+ `agent.run()`, `agent.queue()`, and `agent.stream()` also accept `agent_config`, `capture_config`, `webhook_url`, `use_profile`, and `profile_id`:
471
+
472
+ ```python
473
+ from tinyfish import AgentConfig, CaptureConfig
474
+
475
+ response = client.agent.run(
476
+ goal="...",
477
+ url="...",
478
+ agent_config=AgentConfig(mode="strict", cursor_style="standard", max_duration_seconds=300),
479
+ capture_config=CaptureConfig(screenshots=True, html=True),
480
+ webhook_url="https://example.com/tinyfish-webhook",
481
+ use_profile=True,
482
+ profile_id="prof_abc123def4567890",
483
+ )
484
+ ```
485
+
486
+ - `agent_config` (`AgentConfig`) — `mode`, `cursor_style`, `max_steps`, `max_duration_seconds`
487
+ - `capture_config` (`CaptureConfig`) — `elements`, `snapshots`, `screenshots`, `recording`, `html`
488
+ - `webhook_url` — HTTPS URL notified on run lifecycle events
489
+ - `profile_id` — a specific Browser Context Profile; requires `use_profile=True`
490
+
491
+ `elements` and `recording` are gated capabilities: an account without them enabled gets a 403 saying the capability is not enabled.
492
+
417
493
  ### Browser Context Profiles
418
494
 
419
495
  Use Browser Context Profiles when a run should start from saved logged-in state. Pass `use_profile=True` for your default profile, or add `profile_id` for a specific profile. Pair with `use_vault=True` when TinyFish should repair stale sessions with saved credentials.
@@ -47,7 +47,7 @@ Every method below is available on both `TinyFish` (sync) and `AsyncTinyFish` (a
47
47
  | [`runs.get()`](#runsget--retrieve-a-single-run) | Retrieve a single run by ID | `Run` | — |
48
48
  | [`runs.list()`](#runslist--list-and-filter-runs) | List runs with filtering, sorting, pagination | `RunListResponse` | — |
49
49
  | [`search.query()`](#searchquery--search-the-web) | Search the web for ranked results | `SearchQueryResponse` | Yes |
50
- | `wallet.get()` | Get the caller's wallet balance, auto-reload, and rates | `WalletResponse` | — |
50
+ | [`wallet.get()`](#walletget--get-your-balance) | Get the caller's wallet balance, auto-reload, and rates | `WalletResponse` | — |
51
51
 
52
52
  ---
53
53
 
@@ -202,6 +202,8 @@ print(response.errors)
202
202
 
203
203
  `fetch.get_contents()` accepts 1 to 10 URLs. Set `per_url_timeout_ms` to apply an independent timeout budget to each URL in the batch; slow URLs return in `errors` with `timeout` while siblings can still complete.
204
204
 
205
+ Pass `highlights={"query": "pricing tiers"}` (beta, markdown format only) to get query-ranked `HighlightSnippet` lists on each result instead of the full `text`; set `include_full_page_text=True` to keep both. Accounts not enrolled in the beta get `PermissionDeniedError`.
206
+
205
207
  **Returns `FetchResponse`:**
206
208
 
207
209
  | Field | Type | Description |
@@ -344,6 +346,55 @@ Filter validation rules:
344
346
 
345
347
  ---
346
348
 
349
+ ### `wallet.get()` — get your balance
350
+
351
+ Returns the caller's current balance, auto-reload configuration, per-product rates, and any in-flight top-up.
352
+
353
+ ```python
354
+ from tinyfish import TinyFish, WalletAutoReloadState
355
+
356
+ client = TinyFish()
357
+
358
+ wallet = client.wallet.get()
359
+
360
+ print(f"{wallet.available_balance} {wallet.currency}")
361
+
362
+ if wallet.auto_reload and wallet.auto_reload.state == WalletAutoReloadState.ON:
363
+ print(f"Auto-reload at {wallet.auto_reload.threshold}, tops up to {wallet.auto_reload.recharge_to}")
364
+
365
+ if wallet.pending_top_up:
366
+ print(f"Pending top-up: {wallet.pending_top_up.amount}")
367
+ ```
368
+
369
+ **Returns `WalletResponse`:**
370
+
371
+ | Field | Type | Description |
372
+ |-------|------|-------------|
373
+ | `available_balance` | `str` | Current spendable balance. Negative means the wallet is overdrawn. |
374
+ | `currency` | `str` | ISO 4217 currency code, e.g. `USD` |
375
+ | `as_of` | `str` | ISO timestamp the wallet was read |
376
+ | `auto_reload` | `WalletAutoReload \| None` | `None` means the auto-reload read failed — not the same as `state == "unconfigured"`, which means the read succeeded and nothing is set |
377
+ | `pending_top_up` | `WalletPendingTopUp \| None` | `None` means no in-flight top-up, or the ledger read failed |
378
+ | `rates` | `WalletRates \| None` | `None` means the rates read failed, or the wallet has no rate contract yet |
379
+
380
+ `auto_reload.state` is one of `WalletAutoReloadState.UNCONFIGURED`, `ON`, `OFF`, `PAUSED_PAYMENT_FAILED`, or `NEEDS_PAYMENT_METHOD`. `threshold` and `recharge_to` are only present for the four configured states.
381
+
382
+ Accounts are on either wallet billing or a legacy subscription/credits plan. `wallet.get()` raises `NotFoundError` (404) with `.code` of `"FEATURE_NOT_AVAILABLE"` when the account is on the legacy plan. A wallet account that hasn't added money yet is not an error — it returns normally with an `available_balance` of `"0"`.
383
+
384
+ ```python
385
+ from tinyfish import NotFoundError
386
+
387
+ try:
388
+ wallet = client.wallet.get()
389
+ except NotFoundError as e:
390
+ if e.code == "FEATURE_NOT_AVAILABLE":
391
+ print("Account is on the legacy subscription/credits plan, not a wallet.")
392
+ else:
393
+ raise
394
+ ```
395
+
396
+ ---
397
+
347
398
  ## Sync vs Async
348
399
 
349
400
  Use `AsyncTinyFish` when you're in an async context (FastAPI, aiohttp, etc.):
@@ -366,7 +417,7 @@ client = AsyncTinyFish()
366
417
  response = await client.agent.run(goal="...", url="...")
367
418
  ```
368
419
 
369
- All seven methods (`agent.run()`, `agent.queue()`, `agent.stream()`, `fetch.get_contents()`, `runs.get()`, `runs.list()`, `search.query()`) work the same way — same parameters, just `await`-ed.
420
+ All eight methods (`agent.run()`, `agent.queue()`, `agent.stream()`, `fetch.get_contents()`, `runs.get()`, `runs.list()`, `search.query()`, `wallet.get()`) work the same way — same parameters, just `await`-ed.
370
421
 
371
422
  ## Configuration
372
423
 
@@ -404,6 +455,31 @@ response = client.agent.run(
404
455
  )
405
456
  ```
406
457
 
458
+ ### Agent controls and capture
459
+
460
+ `agent.run()`, `agent.queue()`, and `agent.stream()` also accept `agent_config`, `capture_config`, `webhook_url`, `use_profile`, and `profile_id`:
461
+
462
+ ```python
463
+ from tinyfish import AgentConfig, CaptureConfig
464
+
465
+ response = client.agent.run(
466
+ goal="...",
467
+ url="...",
468
+ agent_config=AgentConfig(mode="strict", cursor_style="standard", max_duration_seconds=300),
469
+ capture_config=CaptureConfig(screenshots=True, html=True),
470
+ webhook_url="https://example.com/tinyfish-webhook",
471
+ use_profile=True,
472
+ profile_id="prof_abc123def4567890",
473
+ )
474
+ ```
475
+
476
+ - `agent_config` (`AgentConfig`) — `mode`, `cursor_style`, `max_steps`, `max_duration_seconds`
477
+ - `capture_config` (`CaptureConfig`) — `elements`, `snapshots`, `screenshots`, `recording`, `html`
478
+ - `webhook_url` — HTTPS URL notified on run lifecycle events
479
+ - `profile_id` — a specific Browser Context Profile; requires `use_profile=True`
480
+
481
+ `elements` and `recording` are gated capabilities: an account without them enabled gets a 403 saying the capability is not enabled.
482
+
407
483
  ### Browser Context Profiles
408
484
 
409
485
  Use Browser Context Profiles when a run should start from saved logged-in state. Pass `use_profile=True` for your default profile, or add `profile_id` for a specific profile. Pair with `use_vault=True` when TinyFish should repair stale sessions with saved credentials.
@@ -74,7 +74,7 @@ SDKError
74
74
  └─ APIError ← carries .request and .response
75
75
  ├─ APIConnectionError ← network failed
76
76
  │ └─ APITimeoutError ← specifically a timeout
77
- └─ APIStatusError ← carries .status_code too
77
+ └─ APIStatusError ← carries .status_code and .code (machine-readable, from error.code) too
78
78
  ├─ BadRequestError (400)
79
79
  ├─ AuthenticationError (401)
80
80
  ├─ PermissionDeniedError (403)
@@ -74,7 +74,7 @@ SDKError
74
74
  └─ APIError ← carries .request and .response
75
75
  ├─ APIConnectionError ← network failed
76
76
  │ └─ APITimeoutError ← specifically a timeout
77
- └─ APIStatusError ← carries .status_code too
77
+ └─ APIStatusError ← carries .status_code and .code (machine-readable, from error.code) too
78
78
  ├─ BadRequestError (400)
79
79
  ├─ AuthenticationError (401)
80
80
  ├─ PermissionDeniedError (403)
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "tinyfish"
3
- version = "0.6.0"
3
+ version = "0.8.0"
4
4
  description = "Official Python SDK for the TinyFish API"
5
5
  readme = "README.md"
6
6
  requires-python = ">=3.11"
@@ -27,11 +27,15 @@ from ._utils.exceptions import (
27
27
  # Agent resource
28
28
  from .agent import AgentStream, AsyncAgentStream
29
29
  from .agent.types import (
30
+ AgentConfig,
31
+ AgentMode,
30
32
  AgentRunAsyncResponse,
31
33
  AgentRunResponse,
32
34
  AgentRunWithStreamingResponse,
33
35
  BrowserProfile,
36
+ CaptureConfig,
34
37
  CompleteEvent,
38
+ CursorStyle,
35
39
  EventType,
36
40
  HeartbeatEvent,
37
41
  ProgressEvent,
@@ -47,8 +51,10 @@ from .client import AsyncTinyFish, TinyFish
47
51
  from .fetch.types import (
48
52
  FetchError,
49
53
  FetchFormat,
54
+ FetchHighlights,
50
55
  FetchResponse,
51
56
  FetchResult,
57
+ HighlightSnippet,
52
58
  )
53
59
 
54
60
  # Runs types
@@ -120,7 +126,11 @@ __all__ = [
120
126
  "BrowserSessionCreateParams",
121
127
  # Agent types
122
128
  "EventType",
129
+ "AgentConfig",
130
+ "AgentMode",
123
131
  "BrowserProfile",
132
+ "CaptureConfig",
133
+ "CursorStyle",
124
134
  "ProxyCountryCode",
125
135
  "ProxyConfig",
126
136
  "AgentRunResponse",
@@ -136,6 +146,8 @@ __all__ = [
136
146
  "FetchResult",
137
147
  "FetchError",
138
148
  "FetchResponse",
149
+ "FetchHighlights",
150
+ "HighlightSnippet",
139
151
  # Search types
140
152
  "SearchResult",
141
153
  "SearchQueryResponse",
@@ -151,17 +151,20 @@ class _BaseClient:
151
151
  else:
152
152
  error_class = error_map.get(response.status_code, APIStatusError)
153
153
 
154
- # Try to parse error message from JSON response
154
+ # Try to parse the message and machine-readable code from the JSON error body.
155
+ code: str | None = None
155
156
  try:
156
- error_data = response.json()
157
- message = error_data.get("error", {}).get("message", response.text)
157
+ error_data = response.json().get("error", {})
158
+ message = error_data.get("message", response.text)
159
+ raw_code = error_data.get("code")
160
+ code = raw_code if isinstance(raw_code, str) else None
158
161
  except Exception:
159
162
  message = response.text or f"HTTP {response.status_code}"
160
163
 
161
164
  if error_class is APIStatusError:
162
165
  # Fallback: no concrete subclass matched, so pass the raw status code.
163
- return error_class(message=message, response=response, status_code=response.status_code)
164
- return error_class(message=message, response=response)
166
+ return error_class(message=message, response=response, status_code=response.status_code, code=code)
167
+ return error_class(message=message, response=response, code=code)
165
168
 
166
169
  def _parse_response(
167
170
  self,
@@ -83,10 +83,13 @@ class APIStatusError(APIError):
83
83
  *,
84
84
  response: httpx.Response,
85
85
  status_code: int,
86
+ code: str | None = None,
86
87
  request: httpx.Request | None = None,
87
88
  ) -> None:
88
89
  super().__init__(message, request=request, response=response)
89
90
  self.status_code = status_code
91
+ #: Machine-readable error code from the response body's `error.code`, when the server sent one.
92
+ self.code = code
90
93
 
91
94
  def __repr__(self) -> str:
92
95
  return f"{self.__class__.__name__}(status_code={self.status_code}, message={self.message!r})"
@@ -95,57 +98,83 @@ class APIStatusError(APIError):
95
98
  class BadRequestError(APIStatusError):
96
99
  """400 Bad Request."""
97
100
 
98
- def __init__(self, message: str, *, response: httpx.Response, request: httpx.Request | None = None) -> None:
99
- super().__init__(message, response=response, status_code=int(httpx.codes.BAD_REQUEST), request=request)
101
+ def __init__(
102
+ self, message: str, *, response: httpx.Response, code: str | None = None, request: httpx.Request | None = None
103
+ ) -> None:
104
+ super().__init__(
105
+ message, response=response, status_code=int(httpx.codes.BAD_REQUEST), code=code, request=request
106
+ )
100
107
 
101
108
 
102
109
  class AuthenticationError(APIStatusError):
103
110
  """401 Unauthorized."""
104
111
 
105
- def __init__(self, message: str, *, response: httpx.Response, request: httpx.Request | None = None) -> None:
106
- super().__init__(message, response=response, status_code=int(httpx.codes.UNAUTHORIZED), request=request)
112
+ def __init__(
113
+ self, message: str, *, response: httpx.Response, code: str | None = None, request: httpx.Request | None = None
114
+ ) -> None:
115
+ super().__init__(
116
+ message, response=response, status_code=int(httpx.codes.UNAUTHORIZED), code=code, request=request
117
+ )
107
118
 
108
119
 
109
120
  class PermissionDeniedError(APIStatusError):
110
121
  """403 Forbidden."""
111
122
 
112
- def __init__(self, message: str, *, response: httpx.Response, request: httpx.Request | None = None) -> None:
113
- super().__init__(message, response=response, status_code=int(httpx.codes.FORBIDDEN), request=request)
123
+ def __init__(
124
+ self, message: str, *, response: httpx.Response, code: str | None = None, request: httpx.Request | None = None
125
+ ) -> None:
126
+ super().__init__(message, response=response, status_code=int(httpx.codes.FORBIDDEN), code=code, request=request)
114
127
 
115
128
 
116
129
  class NotFoundError(APIStatusError):
117
130
  """404 Not Found."""
118
131
 
119
- def __init__(self, message: str, *, response: httpx.Response, request: httpx.Request | None = None) -> None:
120
- super().__init__(message, response=response, status_code=int(httpx.codes.NOT_FOUND), request=request)
132
+ def __init__(
133
+ self, message: str, *, response: httpx.Response, code: str | None = None, request: httpx.Request | None = None
134
+ ) -> None:
135
+ super().__init__(message, response=response, status_code=int(httpx.codes.NOT_FOUND), code=code, request=request)
121
136
 
122
137
 
123
138
  class RequestTimeoutError(APIStatusError):
124
139
  """408 Request Timeout."""
125
140
 
126
- def __init__(self, message: str, *, response: httpx.Response, request: httpx.Request | None = None) -> None:
127
- super().__init__(message, response=response, status_code=int(httpx.codes.REQUEST_TIMEOUT), request=request)
141
+ def __init__(
142
+ self, message: str, *, response: httpx.Response, code: str | None = None, request: httpx.Request | None = None
143
+ ) -> None:
144
+ super().__init__(
145
+ message, response=response, status_code=int(httpx.codes.REQUEST_TIMEOUT), code=code, request=request
146
+ )
128
147
 
129
148
 
130
149
  class ConflictError(APIStatusError):
131
150
  """409 Conflict."""
132
151
 
133
- def __init__(self, message: str, *, response: httpx.Response, request: httpx.Request | None = None) -> None:
134
- super().__init__(message, response=response, status_code=int(httpx.codes.CONFLICT), request=request)
152
+ def __init__(
153
+ self, message: str, *, response: httpx.Response, code: str | None = None, request: httpx.Request | None = None
154
+ ) -> None:
155
+ super().__init__(message, response=response, status_code=int(httpx.codes.CONFLICT), code=code, request=request)
135
156
 
136
157
 
137
158
  class UnprocessableEntityError(APIStatusError):
138
159
  """422 Unprocessable Entity."""
139
160
 
140
- def __init__(self, message: str, *, response: httpx.Response, request: httpx.Request | None = None) -> None:
141
- super().__init__(message, response=response, status_code=int(httpx.codes.UNPROCESSABLE_ENTITY), request=request)
161
+ def __init__(
162
+ self, message: str, *, response: httpx.Response, code: str | None = None, request: httpx.Request | None = None
163
+ ) -> None:
164
+ super().__init__(
165
+ message, response=response, status_code=int(httpx.codes.UNPROCESSABLE_ENTITY), code=code, request=request
166
+ )
142
167
 
143
168
 
144
169
  class RateLimitError(APIStatusError):
145
170
  """429 Too Many Requests."""
146
171
 
147
- def __init__(self, message: str, *, response: httpx.Response, request: httpx.Request | None = None) -> None:
148
- super().__init__(message, response=response, status_code=int(httpx.codes.TOO_MANY_REQUESTS), request=request)
172
+ def __init__(
173
+ self, message: str, *, response: httpx.Response, code: str | None = None, request: httpx.Request | None = None
174
+ ) -> None:
175
+ super().__init__(
176
+ message, response=response, status_code=int(httpx.codes.TOO_MANY_REQUESTS), code=code, request=request
177
+ )
149
178
 
150
179
 
151
180
  class InternalServerError(APIStatusError):
@@ -155,5 +184,7 @@ class InternalServerError(APIStatusError):
155
184
  is preserved in the status_code attribute for accurate monitoring/alerting.
156
185
  """
157
186
 
158
- def __init__(self, message: str, *, response: httpx.Response, request: httpx.Request | None = None) -> None:
159
- super().__init__(message, response=response, status_code=response.status_code, request=request)
187
+ def __init__(
188
+ self, message: str, *, response: httpx.Response, code: str | None = None, request: httpx.Request | None = None
189
+ ) -> None:
190
+ super().__init__(message, response=response, status_code=response.status_code, code=code, request=request)