tinyfish 0.10.0__tar.gz → 0.11.1__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 (69) hide show
  1. {tinyfish-0.10.0 → tinyfish-0.11.1}/CHANGELOG.md +20 -0
  2. {tinyfish-0.10.0 → tinyfish-0.11.1}/PKG-INFO +43 -5
  3. {tinyfish-0.10.0 → tinyfish-0.11.1}/README.md +42 -4
  4. {tinyfish-0.10.0 → tinyfish-0.11.1}/docs/pagination-guide.md +2 -0
  5. {tinyfish-0.10.0 → tinyfish-0.11.1}/pyproject.toml +1 -1
  6. {tinyfish-0.10.0 → tinyfish-0.11.1}/src/tinyfish/__init__.py +50 -0
  7. {tinyfish-0.10.0 → tinyfish-0.11.1}/src/tinyfish/_utils/client/_base.py +13 -0
  8. {tinyfish-0.10.0 → tinyfish-0.11.1}/src/tinyfish/_utils/client/async_.py +14 -24
  9. {tinyfish-0.10.0 → tinyfish-0.11.1}/src/tinyfish/_utils/client/sync.py +14 -24
  10. {tinyfish-0.10.0 → tinyfish-0.11.1}/src/tinyfish/_utils/sse_parser.py +11 -4
  11. {tinyfish-0.10.0 → tinyfish-0.11.1}/src/tinyfish/client.py +5 -0
  12. tinyfish-0.11.1/src/tinyfish/datasets/__init__.py +364 -0
  13. tinyfish-0.11.1/src/tinyfish/datasets/types.py +212 -0
  14. {tinyfish-0.10.0 → tinyfish-0.11.1}/src/tinyfish/research/__init__.py +0 -66
  15. {tinyfish-0.10.0 → tinyfish-0.11.1}/src/tinyfish/runs/types.py +4 -1
  16. tinyfish-0.11.1/tests/test_datasets.py +315 -0
  17. tinyfish-0.11.1/tests/test_datasets_events.py +355 -0
  18. {tinyfish-0.10.0 → tinyfish-0.11.1}/tests/test_errors.py +46 -0
  19. {tinyfish-0.10.0 → tinyfish-0.11.1}/tests/test_research.py +34 -7
  20. {tinyfish-0.10.0 → tinyfish-0.11.1}/tests/test_research_events.py +1 -1
  21. tinyfish-0.11.1/tests/test_sse_parser.py +24 -0
  22. {tinyfish-0.10.0 → tinyfish-0.11.1}/uv.lock +1 -1
  23. {tinyfish-0.10.0 → tinyfish-0.11.1}/.gitignore +0 -0
  24. {tinyfish-0.10.0 → tinyfish-0.11.1}/.pre-commit-config.yaml +0 -0
  25. {tinyfish-0.10.0 → tinyfish-0.11.1}/AGENTS.md +0 -0
  26. {tinyfish-0.10.0 → tinyfish-0.11.1}/CLAUDE.md +0 -0
  27. {tinyfish-0.10.0 → tinyfish-0.11.1}/RELEASE.md +0 -0
  28. {tinyfish-0.10.0 → tinyfish-0.11.1}/docs/exceptions-and-errors-guide.md +0 -0
  29. {tinyfish-0.10.0 → tinyfish-0.11.1}/docs/internal/api-integration-header.md +0 -0
  30. {tinyfish-0.10.0 → tinyfish-0.11.1}/docs/internal/exceptions-and-errors-guide.md +0 -0
  31. {tinyfish-0.10.0 → tinyfish-0.11.1}/docs/internal/publishing-private-guide.md +0 -0
  32. {tinyfish-0.10.0 → tinyfish-0.11.1}/docs/proxy-and-browser-profiles.md +0 -0
  33. {tinyfish-0.10.0 → tinyfish-0.11.1}/docs/streaming-guide.md +0 -0
  34. {tinyfish-0.10.0 → tinyfish-0.11.1}/src/tinyfish/_utils/__init__.py +0 -0
  35. {tinyfish-0.10.0 → tinyfish-0.11.1}/src/tinyfish/_utils/client/__init__.py +0 -0
  36. {tinyfish-0.10.0 → tinyfish-0.11.1}/src/tinyfish/_utils/exceptions.py +0 -0
  37. {tinyfish-0.10.0 → tinyfish-0.11.1}/src/tinyfish/_utils/resource.py +0 -0
  38. {tinyfish-0.10.0 → tinyfish-0.11.1}/src/tinyfish/agent/__init__.py +0 -0
  39. {tinyfish-0.10.0 → tinyfish-0.11.1}/src/tinyfish/agent/types.py +0 -0
  40. {tinyfish-0.10.0 → tinyfish-0.11.1}/src/tinyfish/browser/__init__.py +0 -0
  41. {tinyfish-0.10.0 → tinyfish-0.11.1}/src/tinyfish/browser/types.py +0 -0
  42. {tinyfish-0.10.0 → tinyfish-0.11.1}/src/tinyfish/fetch/__init__.py +0 -0
  43. {tinyfish-0.10.0 → tinyfish-0.11.1}/src/tinyfish/fetch/types.py +0 -0
  44. {tinyfish-0.10.0 → tinyfish-0.11.1}/src/tinyfish/monitors/__init__.py +0 -0
  45. {tinyfish-0.10.0 → tinyfish-0.11.1}/src/tinyfish/monitors/types.py +0 -0
  46. {tinyfish-0.10.0 → tinyfish-0.11.1}/src/tinyfish/profiles/__init__.py +0 -0
  47. {tinyfish-0.10.0 → tinyfish-0.11.1}/src/tinyfish/profiles/types.py +0 -0
  48. {tinyfish-0.10.0 → tinyfish-0.11.1}/src/tinyfish/py.typed +0 -0
  49. {tinyfish-0.10.0 → tinyfish-0.11.1}/src/tinyfish/research/types.py +0 -0
  50. {tinyfish-0.10.0 → tinyfish-0.11.1}/src/tinyfish/runs/__init__.py +0 -0
  51. {tinyfish-0.10.0 → tinyfish-0.11.1}/src/tinyfish/search/__init__.py +0 -0
  52. {tinyfish-0.10.0 → tinyfish-0.11.1}/src/tinyfish/search/types.py +0 -0
  53. {tinyfish-0.10.0 → tinyfish-0.11.1}/src/tinyfish/vault/__init__.py +0 -0
  54. {tinyfish-0.10.0 → tinyfish-0.11.1}/src/tinyfish/vault/types.py +0 -0
  55. {tinyfish-0.10.0 → tinyfish-0.11.1}/src/tinyfish/wallet/__init__.py +0 -0
  56. {tinyfish-0.10.0 → tinyfish-0.11.1}/src/tinyfish/wallet/types.py +0 -0
  57. {tinyfish-0.10.0 → tinyfish-0.11.1}/tests/__init__.py +0 -0
  58. {tinyfish-0.10.0 → tinyfish-0.11.1}/tests/conftest.py +0 -0
  59. {tinyfish-0.10.0 → tinyfish-0.11.1}/tests/test_agent.py +0 -0
  60. {tinyfish-0.10.0 → tinyfish-0.11.1}/tests/test_browser.py +0 -0
  61. {tinyfish-0.10.0 → tinyfish-0.11.1}/tests/test_client.py +0 -0
  62. {tinyfish-0.10.0 → tinyfish-0.11.1}/tests/test_fetch.py +0 -0
  63. {tinyfish-0.10.0 → tinyfish-0.11.1}/tests/test_monitors.py +0 -0
  64. {tinyfish-0.10.0 → tinyfish-0.11.1}/tests/test_profiles.py +0 -0
  65. {tinyfish-0.10.0 → tinyfish-0.11.1}/tests/test_runs.py +0 -0
  66. {tinyfish-0.10.0 → tinyfish-0.11.1}/tests/test_search.py +0 -0
  67. {tinyfish-0.10.0 → tinyfish-0.11.1}/tests/test_vault.py +0 -0
  68. {tinyfish-0.10.0 → tinyfish-0.11.1}/tests/test_wallet.py +0 -0
  69. {tinyfish-0.10.0 → tinyfish-0.11.1}/tests/testing_guide.md +0 -0
@@ -1,5 +1,25 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.11.1](https://github.com/tinyfish-io/ux-labs/compare/sdk-py/v0.11.0...sdk-py/v0.11.1) (2026-12-01)
4
+
5
+
6
+ ### Bug Fixes
7
+
8
+ * **datasets:** lower the default rows from 100 to 40 (PROD-5182) ([#7587](https://github.com/tinyfish-io/ux-labs/issues/7587)) ([a27985f](https://github.com/tinyfish-io/ux-labs/commit/a27985f430267e07ea30835086d064aded4d4f64))
9
+
10
+ ## [0.11.0](https://github.com/tinyfish-io/ux-labs/compare/sdk-py/v0.10.0...sdk-py/v0.11.0) (2026-10-23)
11
+
12
+
13
+ ### Features
14
+
15
+ * **sdk-py:** add datasets resource ([#6579](https://github.com/tinyfish-io/ux-labs/issues/6579)) ([36b6607](https://github.com/tinyfish-io/ux-labs/commit/36b66072798b562d2ffef4c7d5376d632fd93c3a))
16
+ * **sdk-py:** carry SSE event names on frames ([#6578](https://github.com/tinyfish-io/ux-labs/issues/6578)) ([72b5896](https://github.com/tinyfish-io/ux-labs/commit/72b58966bf98548bc6cd374363c0913b98570415))
17
+
18
+
19
+ ### Documentation
20
+
21
+ * **research:** align public Research docs with code, gate CLI examples in CI ([#6584](https://github.com/tinyfish-io/ux-labs/issues/6584)) ([1d40ed7](https://github.com/tinyfish-io/ux-labs/commit/1d40ed7a20abf074ed0f7a47ee7f6e917c7bea25))
22
+
3
23
  ## [0.10.0](https://github.com/tinyfish-io/ux-labs/compare/sdk-py/v0.9.0...sdk-py/v0.10.0) (2026-10-21)
4
24
 
5
25
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: tinyfish
3
- Version: 0.10.0
3
+ Version: 0.11.1
4
4
  Summary: Official Python SDK for the TinyFish API
5
5
  Requires-Python: >=3.11
6
6
  Requires-Dist: httpx>=0.27.0
@@ -64,6 +64,11 @@ Every method below is available on both `TinyFish` (sync) and `AsyncTinyFish` (a
64
64
  | [`research.stream()`](#research--deep-research) | Start deep research, stream its events | `ResearchStream` | No |
65
65
  | [`research.events()`](#research--deep-research) | Attach or reconnect to a run's events | `ResearchStream` | No |
66
66
  | [`research.get()` / `list()` / `cancel()`](#research--deep-research) | Read, list, and cancel research runs | `ResearchRunDetail` and friends | — |
67
+ | [`datasets.create()`](#datasets--build-a-dataset-from-a-prompt) | Plan a dataset from a prompt (or a spec) and start filling it | `Dataset` | No |
68
+ | [`datasets.plan()`](#datasets--build-a-dataset-from-a-prompt) | Get the planner's schema for a prompt, to review first | `DatasetPlanResponse` | Yes |
69
+ | [`datasets.events()`](#datasets--build-a-dataset-from-a-prompt) | Follow a run's status, rows and log | `DatasetRunStream` | No |
70
+ | [`datasets.rows()` / `populate()` / `cancel_run()`](#datasets--build-a-dataset-from-a-prompt) | Read rows, fill again, stop a run | `DatasetRowsResponse` and friends | — |
71
+ | [`datasets.list()` / `get()` / `delete()`](#datasets--build-a-dataset-from-a-prompt) | List, read, and delete datasets | `Dataset` and friends | — |
67
72
  | [`wallet.get()`](#walletget--get-your-balance) | Get the caller's wallet balance, auto-reload, and rates | `WalletResponse` | — |
68
73
  | [`profiles.setup.start()`](#profilessetup--sign-in-once-reuse-the-session) | Open a browser to sign in to a profile | `ProfileSetupSession` | — |
69
74
  | [`profiles.setup.save()`](#profilessetup--sign-in-once-reuse-the-session) | Save the signed-in state into the profile | `ProfileSaveResult` | Yes |
@@ -300,7 +305,7 @@ if response.pagination.has_more:
300
305
  | Field | Type | Description |
301
306
  |-------|------|-------------|
302
307
  | `data` | `list[Run]` | List of runs |
303
- | `pagination.total` | `int` | Total runs matching filters |
308
+ | `pagination.total` | `int` | Total runs matching filters; for a team's workflow key, it stops at 1,000 |
304
309
  | `pagination.has_more` | `bool` | Whether more pages exist |
305
310
  | `pagination.next_cursor` | `str \| None` | Pass to `cursor=` for the next page |
306
311
 
@@ -396,7 +401,7 @@ client.monitors.cancel(monitor_id) # deletes the Monitor and its schedule
396
401
 
397
402
  ### `research` — deep research
398
403
 
399
- Same shape as `agent`, with keyword-only arguments: `run()` blocks, `queue()` returns at once, `stream()` yields events. Options: `output_language`, `domain_type`, `after_date` / `before_date`, `recency_minutes`, `weak_sources_enabled`, `domain_filter`, `prior_run_id` or `session_id`. `mode` is `"deep"` (default, 5–20 min) or `"max"` (5–45 min). Starts are billed and never retried, since a retry could bill a second run.
404
+ Same shape as `agent`, with keyword-only arguments: `run()` blocks, `queue()` returns at once, `stream()` yields events. Options: `output_language`, `domain_filter`, `prior_run_id` or `session_id`. `mode` is `"deep"` (default, 5–20 min) or `"max"` (5–45 min). Each completed run is billed (`deep` $2, `max` $3). Starts are never retried, since a retry could start (and bill) a second run. See [Research limits](https://docs.tinyfish.ai/research-api/reference#limits).
400
405
 
401
406
  ```python
402
407
  run = client.research.run(query="Compare long-duration energy storage approaches", mode="deep")
@@ -427,6 +432,39 @@ with client.research.events(run_id) as stream: # `async with` / `async for` on
427
432
 
428
433
  ---
429
434
 
435
+ ### `datasets` — build a dataset from a prompt
436
+
437
+ `create()` plans a schema from a prompt (or takes a `spec` from `plan()`), creates the dataset and starts filling it to `target_rows` (default 40, at most 250). `events()` follows the run; `rows()` reads the rows. `create()` and `populate()` are billed and never retried, since a retry could start a second run.
438
+
439
+ ```python
440
+ dataset = client.datasets.create(prompt="Specialty coffee shops in Oakland with their website and rating", target_rows=50)
441
+ assert dataset.run is not None # None only when created with populate=False
442
+
443
+ with client.datasets.events(dataset.id, dataset.run.id, on_row=lambda e: print(e.data)) as stream:
444
+ for event in stream:
445
+ if isinstance(event, DatasetRunStatusEvent):
446
+ print(event.status) # running, then done, failed or cancelled
447
+
448
+ after = None
449
+ while True:
450
+ page = client.datasets.rows(dataset.id, limit=500, after=after)
451
+ for row in page.rows:
452
+ print(row.data)
453
+ if (after := page.next_cursor) is None:
454
+ break
455
+
456
+ spec = client.datasets.plan(prompt="...").spec # edit, then create(spec=spec)
457
+ client.datasets.get(dataset.id) # status: empty, populating, ready, failed or cancelled
458
+ dataset = client.datasets.populate(dataset.id, reset=True, target_rows=100) # ConflictError while a run is live
459
+ client.datasets.cancel_run(dataset.id, dataset.run.id) # the new run
460
+ client.datasets.list(limit=20)
461
+ client.datasets.delete(dataset.id) # ConflictError while a run is live
462
+ ```
463
+
464
+ `events()` has no overall time limit, a 60s idle timeout, and reconnects a dropped connection up to `max_retries` times. Run frames carry no event ids: a reconnect re-sends the current status and does not replay rows landed in the gap, so read `rows()` after the run. Leaving the `with` block detaches; only `cancel_run()` stops the run. Unknown event names are skipped, as in `agent.stream()`.
465
+
466
+ ---
467
+
430
468
  ### `wallet.get()` — get your balance
431
469
 
432
470
  Returns the caller's current balance, auto-reload configuration, per-product rates, and any in-flight top-up.
@@ -548,7 +586,7 @@ client = TinyFish(
548
586
  )
549
587
  ```
550
588
 
551
- The SDK retries `408`, `429`, and `5xx` errors automatically with exponential backoff (0.5s multiplier, max 8s wait).
589
+ The SDK retries `408`, `429`, and `5xx` errors automatically with exponential backoff (0.5s multiplier, max 8s wait). Daily allowance errors (`429` with `error.details.reason: "free_allowance_exhausted"`) fail immediately.
552
590
 
553
591
  ### Browser profiles
554
592
 
@@ -641,7 +679,7 @@ except SDKError:
641
679
  print("Something else went wrong")
642
680
  ```
643
681
 
644
- The SDK automatically retries transient errors (`408`, `429`, `5xx`) up to `max_retries` times with exponential backoff. Non-retryable errors (`401`, `400`, `404`) raise immediately.
682
+ The SDK automatically retries transient errors (`408`, `429`, `5xx`) up to `max_retries` times with exponential backoff. Daily allowance errors (`429` with `error.details.reason: "free_allowance_exhausted"`) and non-retryable errors (`401`, `400`, `404`) raise immediately.
645
683
 
646
684
  For the full exception hierarchy and internal architecture, see [docs/internal/exceptions-and-errors-guide.md](docs/internal/exceptions-and-errors-guide.md).
647
685
 
@@ -54,6 +54,11 @@ Every method below is available on both `TinyFish` (sync) and `AsyncTinyFish` (a
54
54
  | [`research.stream()`](#research--deep-research) | Start deep research, stream its events | `ResearchStream` | No |
55
55
  | [`research.events()`](#research--deep-research) | Attach or reconnect to a run's events | `ResearchStream` | No |
56
56
  | [`research.get()` / `list()` / `cancel()`](#research--deep-research) | Read, list, and cancel research runs | `ResearchRunDetail` and friends | — |
57
+ | [`datasets.create()`](#datasets--build-a-dataset-from-a-prompt) | Plan a dataset from a prompt (or a spec) and start filling it | `Dataset` | No |
58
+ | [`datasets.plan()`](#datasets--build-a-dataset-from-a-prompt) | Get the planner's schema for a prompt, to review first | `DatasetPlanResponse` | Yes |
59
+ | [`datasets.events()`](#datasets--build-a-dataset-from-a-prompt) | Follow a run's status, rows and log | `DatasetRunStream` | No |
60
+ | [`datasets.rows()` / `populate()` / `cancel_run()`](#datasets--build-a-dataset-from-a-prompt) | Read rows, fill again, stop a run | `DatasetRowsResponse` and friends | — |
61
+ | [`datasets.list()` / `get()` / `delete()`](#datasets--build-a-dataset-from-a-prompt) | List, read, and delete datasets | `Dataset` and friends | — |
57
62
  | [`wallet.get()`](#walletget--get-your-balance) | Get the caller's wallet balance, auto-reload, and rates | `WalletResponse` | — |
58
63
  | [`profiles.setup.start()`](#profilessetup--sign-in-once-reuse-the-session) | Open a browser to sign in to a profile | `ProfileSetupSession` | — |
59
64
  | [`profiles.setup.save()`](#profilessetup--sign-in-once-reuse-the-session) | Save the signed-in state into the profile | `ProfileSaveResult` | Yes |
@@ -290,7 +295,7 @@ if response.pagination.has_more:
290
295
  | Field | Type | Description |
291
296
  |-------|------|-------------|
292
297
  | `data` | `list[Run]` | List of runs |
293
- | `pagination.total` | `int` | Total runs matching filters |
298
+ | `pagination.total` | `int` | Total runs matching filters; for a team's workflow key, it stops at 1,000 |
294
299
  | `pagination.has_more` | `bool` | Whether more pages exist |
295
300
  | `pagination.next_cursor` | `str \| None` | Pass to `cursor=` for the next page |
296
301
 
@@ -386,7 +391,7 @@ client.monitors.cancel(monitor_id) # deletes the Monitor and its schedule
386
391
 
387
392
  ### `research` — deep research
388
393
 
389
- Same shape as `agent`, with keyword-only arguments: `run()` blocks, `queue()` returns at once, `stream()` yields events. Options: `output_language`, `domain_type`, `after_date` / `before_date`, `recency_minutes`, `weak_sources_enabled`, `domain_filter`, `prior_run_id` or `session_id`. `mode` is `"deep"` (default, 5–20 min) or `"max"` (5–45 min). Starts are billed and never retried, since a retry could bill a second run.
394
+ Same shape as `agent`, with keyword-only arguments: `run()` blocks, `queue()` returns at once, `stream()` yields events. Options: `output_language`, `domain_filter`, `prior_run_id` or `session_id`. `mode` is `"deep"` (default, 5–20 min) or `"max"` (5–45 min). Each completed run is billed (`deep` $2, `max` $3). Starts are never retried, since a retry could start (and bill) a second run. See [Research limits](https://docs.tinyfish.ai/research-api/reference#limits).
390
395
 
391
396
  ```python
392
397
  run = client.research.run(query="Compare long-duration energy storage approaches", mode="deep")
@@ -417,6 +422,39 @@ with client.research.events(run_id) as stream: # `async with` / `async for` on
417
422
 
418
423
  ---
419
424
 
425
+ ### `datasets` — build a dataset from a prompt
426
+
427
+ `create()` plans a schema from a prompt (or takes a `spec` from `plan()`), creates the dataset and starts filling it to `target_rows` (default 40, at most 250). `events()` follows the run; `rows()` reads the rows. `create()` and `populate()` are billed and never retried, since a retry could start a second run.
428
+
429
+ ```python
430
+ dataset = client.datasets.create(prompt="Specialty coffee shops in Oakland with their website and rating", target_rows=50)
431
+ assert dataset.run is not None # None only when created with populate=False
432
+
433
+ with client.datasets.events(dataset.id, dataset.run.id, on_row=lambda e: print(e.data)) as stream:
434
+ for event in stream:
435
+ if isinstance(event, DatasetRunStatusEvent):
436
+ print(event.status) # running, then done, failed or cancelled
437
+
438
+ after = None
439
+ while True:
440
+ page = client.datasets.rows(dataset.id, limit=500, after=after)
441
+ for row in page.rows:
442
+ print(row.data)
443
+ if (after := page.next_cursor) is None:
444
+ break
445
+
446
+ spec = client.datasets.plan(prompt="...").spec # edit, then create(spec=spec)
447
+ client.datasets.get(dataset.id) # status: empty, populating, ready, failed or cancelled
448
+ dataset = client.datasets.populate(dataset.id, reset=True, target_rows=100) # ConflictError while a run is live
449
+ client.datasets.cancel_run(dataset.id, dataset.run.id) # the new run
450
+ client.datasets.list(limit=20)
451
+ client.datasets.delete(dataset.id) # ConflictError while a run is live
452
+ ```
453
+
454
+ `events()` has no overall time limit, a 60s idle timeout, and reconnects a dropped connection up to `max_retries` times. Run frames carry no event ids: a reconnect re-sends the current status and does not replay rows landed in the gap, so read `rows()` after the run. Leaving the `with` block detaches; only `cancel_run()` stops the run. Unknown event names are skipped, as in `agent.stream()`.
455
+
456
+ ---
457
+
420
458
  ### `wallet.get()` — get your balance
421
459
 
422
460
  Returns the caller's current balance, auto-reload configuration, per-product rates, and any in-flight top-up.
@@ -538,7 +576,7 @@ client = TinyFish(
538
576
  )
539
577
  ```
540
578
 
541
- The SDK retries `408`, `429`, and `5xx` errors automatically with exponential backoff (0.5s multiplier, max 8s wait).
579
+ The SDK retries `408`, `429`, and `5xx` errors automatically with exponential backoff (0.5s multiplier, max 8s wait). Daily allowance errors (`429` with `error.details.reason: "free_allowance_exhausted"`) fail immediately.
542
580
 
543
581
  ### Browser profiles
544
582
 
@@ -631,7 +669,7 @@ except SDKError:
631
669
  print("Something else went wrong")
632
670
  ```
633
671
 
634
- The SDK automatically retries transient errors (`408`, `429`, `5xx`) up to `max_retries` times with exponential backoff. Non-retryable errors (`401`, `400`, `404`) raise immediately.
672
+ The SDK automatically retries transient errors (`408`, `429`, `5xx`) up to `max_retries` times with exponential backoff. Daily allowance errors (`429` with `error.details.reason: "free_allowance_exhausted"`) and non-retryable errors (`401`, `400`, `404`) raise immediately.
635
673
 
636
674
  For the full exception hierarchy and internal architecture, see [docs/internal/exceptions-and-errors-guide.md](docs/internal/exceptions-and-errors-guide.md).
637
675
 
@@ -95,6 +95,8 @@ print(response.pagination.has_more) # True if more pages exist
95
95
  print(response.pagination.next_cursor) # Pass to cursor= for the next page
96
96
  ```
97
97
 
98
+ For a team's workflow key, `total` stops counting at 1,000, so a total of 1,000 means at least 1,000 runs. To read every run, keep paging while `has_more` is true.
99
+
98
100
  ### Full pagination loop
99
101
 
100
102
  ```python
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "tinyfish"
3
- version = "0.10.0"
3
+ version = "0.11.1"
4
4
  description = "Official Python SDK for the TinyFish API"
5
5
  readme = "README.md"
6
6
  requires-python = ">=3.11"
@@ -49,6 +49,32 @@ from .agent.types import (
49
49
  # Browser types
50
50
  from .browser.types import BrowserProxyConfig, BrowserSession, BrowserSessionCreateParams
51
51
  from .client import AsyncTinyFish, TinyFish
52
+ from .datasets import AsyncDatasetRunStream, DatasetRunStream
53
+
54
+ # Datasets types
55
+ from .datasets.types import (
56
+ Dataset,
57
+ DatasetCancelRunResponse,
58
+ DatasetColumnType,
59
+ DatasetDeleteResponse,
60
+ DatasetKeepWhen,
61
+ DatasetListResponse,
62
+ DatasetPagination,
63
+ DatasetPlanResponse,
64
+ DatasetRow,
65
+ DatasetRowColumn,
66
+ DatasetRowsResponse,
67
+ DatasetRun,
68
+ DatasetRunDoneEvent,
69
+ DatasetRunEvent,
70
+ DatasetRunLogEvent,
71
+ DatasetRunRowEvent,
72
+ DatasetRunStatus,
73
+ DatasetRunStatusEvent,
74
+ DatasetSpec,
75
+ DatasetSpecColumn,
76
+ DatasetStatus,
77
+ )
52
78
  from .fetch.types import (
53
79
  FetchError,
54
80
  FetchFormat,
@@ -182,6 +208,8 @@ __all__ = [
182
208
  "AsyncAgentStream",
183
209
  "ResearchStream",
184
210
  "AsyncResearchStream",
211
+ "DatasetRunStream",
212
+ "AsyncDatasetRunStream",
185
213
  # Browser types
186
214
  "BrowserSession",
187
215
  "BrowserProxyConfig",
@@ -233,6 +261,28 @@ __all__ = [
233
261
  "MonitorListResponse",
234
262
  "MonitorRunResponse",
235
263
  "MonitorDeleteResponse",
264
+ # Datasets types
265
+ "Dataset",
266
+ "DatasetCancelRunResponse",
267
+ "DatasetColumnType",
268
+ "DatasetDeleteResponse",
269
+ "DatasetKeepWhen",
270
+ "DatasetListResponse",
271
+ "DatasetPagination",
272
+ "DatasetPlanResponse",
273
+ "DatasetRow",
274
+ "DatasetRowColumn",
275
+ "DatasetRowsResponse",
276
+ "DatasetRun",
277
+ "DatasetRunDoneEvent",
278
+ "DatasetRunEvent",
279
+ "DatasetRunLogEvent",
280
+ "DatasetRunRowEvent",
281
+ "DatasetRunStatus",
282
+ "DatasetRunStatusEvent",
283
+ "DatasetSpec",
284
+ "DatasetSpecColumn",
285
+ "DatasetStatus",
236
286
  # Research types
237
287
  "ResearchMode",
238
288
  "ResearchRunStatus",
@@ -34,6 +34,19 @@ _RETRY_MULTIPLIER: float = 0.5
34
34
  _RETRY_MAX_WAIT: float = 8.0
35
35
 
36
36
 
37
+ def _should_retry(error: BaseException) -> bool:
38
+ if isinstance(error, RateLimitError) and error.response is not None:
39
+ try:
40
+ body = error.response.json()
41
+ api_error = body.get("error") if isinstance(body, dict) else None
42
+ details = api_error.get("details") if isinstance(api_error, dict) else None
43
+ if isinstance(details, dict) and details.get("reason") == "free_allowance_exhausted":
44
+ return False # Daily allowance cannot recover during short backoff.
45
+ except ValueError:
46
+ pass # Non-JSON 429 responses keep the ordinary retry policy.
47
+ return isinstance(error, (RequestTimeoutError, RateLimitError, InternalServerError, httpx.RequestError))
48
+
49
+
37
50
  def _sanitize_client_header(value: str) -> str:
38
51
  """Non-printable chars raise in httpx; 128 is the server cap (client_name varchar(128))."""
39
52
  return "".join(ch for ch in value if 32 <= ord(ch) <= 126).strip()[:128]
@@ -7,16 +7,20 @@ from typing import Any, Self, TypeVar
7
7
 
8
8
  import httpx
9
9
  from pydantic import BaseModel
10
- from tenacity import retry, retry_if_exception_type, stop_after_attempt, wait_exponential
10
+ from tenacity import retry, retry_if_exception, stop_after_attempt, wait_exponential
11
11
 
12
12
  from ..exceptions import (
13
13
  APIConnectionError,
14
14
  APITimeoutError,
15
- InternalServerError,
16
- RateLimitError,
17
- RequestTimeoutError,
18
15
  )
19
- from ._base import _DEFAULT_MAX_RETRIES, _DEFAULT_TIMEOUT, _RETRY_MAX_WAIT, _RETRY_MULTIPLIER, _BaseClient
16
+ from ._base import (
17
+ _DEFAULT_MAX_RETRIES,
18
+ _DEFAULT_TIMEOUT,
19
+ _RETRY_MAX_WAIT,
20
+ _RETRY_MULTIPLIER,
21
+ _BaseClient,
22
+ _should_retry,
23
+ )
20
24
 
21
25
  ResponseT = TypeVar("ResponseT", bound=BaseModel)
22
26
 
@@ -59,7 +63,7 @@ class BaseAsyncAPIClient(_BaseClient):
59
63
  """
60
64
  Make async HTTP request with automatic retries.
61
65
 
62
- Retryable errors: 408, 429, 5xx, and network errors.
66
+ Retryable errors: 408, transient 429, 5xx, and network errors.
63
67
  Non-retryable errors (400, 401, 403, 404, …) propagate immediately.
64
68
 
65
69
  Args:
@@ -76,20 +80,13 @@ class BaseAsyncAPIClient(_BaseClient):
76
80
  json = self._inject_integration(path, json)
77
81
  max_attempts = (self._max_retries if max_retries is None else max_retries) + 1
78
82
 
79
- # Retryable: 408, 429, 5xx, and network errors (TimeoutException ⊂ RequestError).
83
+ # Retryable: 408, transient 429, 5xx, and network errors (TimeoutException ⊂ RequestError).
80
84
  # Non-retryable status errors (400, 401, 403, 404, …) propagate immediately.
81
85
  # After retries exhausted: httpx errors are wrapped into SDK types by the outer try/except.
82
86
  @retry(
83
87
  stop=stop_after_attempt(max_attempts),
84
88
  wait=wait_exponential(multiplier=_RETRY_MULTIPLIER, max=_RETRY_MAX_WAIT),
85
- retry=retry_if_exception_type(
86
- (
87
- RequestTimeoutError,
88
- RateLimitError,
89
- InternalServerError,
90
- httpx.RequestError, # covers TimeoutException and connection errors
91
- )
92
- ),
89
+ retry=retry_if_exception(_should_retry),
93
90
  reraise=True,
94
91
  )
95
92
  async def _execute() -> httpx.Response:
@@ -164,7 +161,7 @@ class BaseAsyncAPIClient(_BaseClient):
164
161
  ) -> AsyncGenerator[str, None]:
165
162
  """POST request that streams raw response lines (for SSE). Does not parse JSON.
166
163
 
167
- Retries the initial connection on 429/5xx with exponential backoff,
164
+ Retries the initial connection on transient 429/5xx with exponential backoff,
168
165
  matching the retry behaviour of ``_request()``. Once a 200 response
169
166
  is received and streaming begins, no further retries are attempted.
170
167
  """
@@ -197,14 +194,7 @@ class BaseAsyncAPIClient(_BaseClient):
197
194
  @retry(
198
195
  stop=stop_after_attempt(max_attempts),
199
196
  wait=wait_exponential(multiplier=_RETRY_MULTIPLIER, max=_RETRY_MAX_WAIT),
200
- retry=retry_if_exception_type(
201
- (
202
- RequestTimeoutError,
203
- RateLimitError,
204
- InternalServerError,
205
- httpx.RequestError,
206
- )
207
- ),
197
+ retry=retry_if_exception(_should_retry),
208
198
  reraise=True,
209
199
  )
210
200
  async def _connect() -> httpx.Response:
@@ -7,16 +7,20 @@ from typing import Any, Self, TypeVar
7
7
 
8
8
  import httpx
9
9
  from pydantic import BaseModel
10
- from tenacity import retry, retry_if_exception_type, stop_after_attempt, wait_exponential
10
+ from tenacity import retry, retry_if_exception, stop_after_attempt, wait_exponential
11
11
 
12
12
  from ..exceptions import (
13
13
  APIConnectionError,
14
14
  APITimeoutError,
15
- InternalServerError,
16
- RateLimitError,
17
- RequestTimeoutError,
18
15
  )
19
- from ._base import _DEFAULT_MAX_RETRIES, _DEFAULT_TIMEOUT, _RETRY_MAX_WAIT, _RETRY_MULTIPLIER, _BaseClient
16
+ from ._base import (
17
+ _DEFAULT_MAX_RETRIES,
18
+ _DEFAULT_TIMEOUT,
19
+ _RETRY_MAX_WAIT,
20
+ _RETRY_MULTIPLIER,
21
+ _BaseClient,
22
+ _should_retry,
23
+ )
20
24
 
21
25
  ResponseT = TypeVar("ResponseT", bound=BaseModel)
22
26
 
@@ -59,7 +63,7 @@ class BaseSyncAPIClient(_BaseClient):
59
63
  """
60
64
  Make HTTP request with automatic retries.
61
65
 
62
- Retryable errors: 408, 429, 5xx, and network errors.
66
+ Retryable errors: 408, transient 429, 5xx, and network errors.
63
67
  Non-retryable errors (400, 401, 403, 404, …) propagate immediately.
64
68
 
65
69
  Args:
@@ -76,20 +80,13 @@ class BaseSyncAPIClient(_BaseClient):
76
80
  json = self._inject_integration(path, json)
77
81
  max_attempts = (self._max_retries if max_retries is None else max_retries) + 1
78
82
 
79
- # Retryable: 408, 429, 5xx, and network errors (TimeoutException ⊂ RequestError).
83
+ # Retryable: 408, transient 429, 5xx, and network errors (TimeoutException ⊂ RequestError).
80
84
  # Non-retryable status errors (400, 401, 403, 404, …) propagate immediately.
81
85
  # After retries exhausted: httpx errors are wrapped into SDK types by the outer try/except.
82
86
  @retry(
83
87
  stop=stop_after_attempt(max_attempts),
84
88
  wait=wait_exponential(multiplier=_RETRY_MULTIPLIER, max=_RETRY_MAX_WAIT),
85
- retry=retry_if_exception_type(
86
- (
87
- RequestTimeoutError,
88
- RateLimitError,
89
- InternalServerError,
90
- httpx.RequestError, # covers TimeoutException and connection errors
91
- )
92
- ),
89
+ retry=retry_if_exception(_should_retry),
93
90
  reraise=True,
94
91
  )
95
92
  def _execute() -> httpx.Response:
@@ -164,7 +161,7 @@ class BaseSyncAPIClient(_BaseClient):
164
161
  ) -> Generator[str, None, None]:
165
162
  """POST request that streams raw response lines (for SSE). Does not parse JSON.
166
163
 
167
- Retries the initial connection on 429/5xx with exponential backoff,
164
+ Retries the initial connection on transient 429/5xx with exponential backoff,
168
165
  matching the retry behaviour of ``_request()``. Once a 200 response
169
166
  is received and streaming begins, no further retries are attempted.
170
167
  """
@@ -197,14 +194,7 @@ class BaseSyncAPIClient(_BaseClient):
197
194
  @retry(
198
195
  stop=stop_after_attempt(max_attempts),
199
196
  wait=wait_exponential(multiplier=_RETRY_MULTIPLIER, max=_RETRY_MAX_WAIT),
200
- retry=retry_if_exception_type(
201
- (
202
- RequestTimeoutError,
203
- RateLimitError,
204
- InternalServerError,
205
- httpx.RequestError,
206
- )
207
- ),
197
+ retry=retry_if_exception(_should_retry),
208
198
  reraise=True,
209
199
  )
210
200
  def _connect() -> httpx.Response:
@@ -63,15 +63,18 @@ async def async_parse_sse_line_stream(lines: AsyncIterator[str]) -> AsyncIterato
63
63
 
64
64
 
65
65
  class SSEFrame(NamedTuple):
66
- """One SSE event: its id, if any, and parsed JSON data."""
66
+ """One SSE event: its id, if any, parsed JSON data, and its event name."""
67
67
 
68
68
  id: str | None
69
69
  data: dict[str, Any]
70
+ # Last, with a default: positional SSEFrame(id, data) stays valid.
71
+ event: str | None = None
70
72
 
71
73
 
72
74
  class _FrameBuilder:
73
75
  def __init__(self) -> None:
74
76
  self._id: str | None = None
77
+ self._event: str | None = None
75
78
  self._data: list[str] = []
76
79
 
77
80
  def feed(self, line: str) -> SSEFrame | None:
@@ -82,17 +85,21 @@ class _FrameBuilder:
82
85
  value = value.removeprefix(" ")
83
86
  if name == "id":
84
87
  self._id = value
88
+ elif name == "event":
89
+ self._event = value
85
90
  elif name == "data":
86
91
  self._data.append(value)
87
92
  return None
88
93
 
89
94
  def flush(self) -> SSEFrame | None:
90
- frame_id, data = self._id, "\n".join(self._data)
91
- self._id, self._data = None, []
95
+ # id, event and data all reset per frame; resume across reconnects
96
+ # is the caller's job (research._EventCursor keeps the last id).
97
+ frame_id, event, data = self._id, self._event, "\n".join(self._data)
98
+ self._id, self._event, self._data = None, None, []
92
99
  if not data:
93
100
  return None
94
101
  try:
95
- return SSEFrame(frame_id, json.loads(data))
102
+ return SSEFrame(frame_id, json.loads(data), event)
96
103
  except json.JSONDecodeError as e:
97
104
  raise SSEParseError(f"Malformed JSON in SSE event: {e}", line=data) from e
98
105
 
@@ -5,6 +5,7 @@ from tinyfish._utils.client._base import _DEFAULT_TIMEOUT, DEFAULT_BASE_URL
5
5
 
6
6
  from .agent import AgentResource, AsyncAgentResource
7
7
  from .browser import AsyncBrowserResource, BrowserResource
8
+ from .datasets import AsyncDatasetsResource, DatasetsResource
8
9
  from .fetch import AsyncFetchResource, FetchResource
9
10
  from .monitors import AsyncMonitorsResource, MonitorsResource
10
11
  from .profiles import AsyncProfilesResource, ProfilesResource
@@ -30,6 +31,7 @@ class TinyFish(BaseSyncAPIClient):
30
31
  # did `pip install tinyfish`.
31
32
  agent: AgentResource
32
33
  browser: BrowserResource
34
+ datasets: DatasetsResource
33
35
  fetch: FetchResource
34
36
  monitors: MonitorsResource
35
37
  profiles: ProfilesResource
@@ -59,6 +61,7 @@ class TinyFish(BaseSyncAPIClient):
59
61
 
60
62
  self.agent = AgentResource(self)
61
63
  self.browser = BrowserResource(self)
64
+ self.datasets = DatasetsResource(self)
62
65
  self.fetch = FetchResource(self)
63
66
  self.monitors = MonitorsResource(self)
64
67
  self.profiles = ProfilesResource(self)
@@ -77,6 +80,7 @@ class AsyncTinyFish(BaseAsyncAPIClient):
77
80
  # the sync variants) when resolving types from an installed package.
78
81
  agent: AsyncAgentResource
79
82
  browser: AsyncBrowserResource
83
+ datasets: AsyncDatasetsResource
80
84
  fetch: AsyncFetchResource
81
85
  monitors: AsyncMonitorsResource
82
86
  profiles: AsyncProfilesResource
@@ -106,6 +110,7 @@ class AsyncTinyFish(BaseAsyncAPIClient):
106
110
 
107
111
  self.agent = AsyncAgentResource(self)
108
112
  self.browser = AsyncBrowserResource(self)
113
+ self.datasets = AsyncDatasetsResource(self)
109
114
  self.fetch = AsyncFetchResource(self)
110
115
  self.monitors = AsyncMonitorsResource(self)
111
116
  self.profiles = AsyncProfilesResource(self)