tinyfish 0.9.0__tar.gz → 0.11.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 (71) hide show
  1. {tinyfish-0.9.0 → tinyfish-0.11.0}/CHANGELOG.md +38 -0
  2. tinyfish-0.11.0/CLAUDE.md +24 -0
  3. {tinyfish-0.9.0 → tinyfish-0.11.0}/PKG-INFO +142 -2
  4. {tinyfish-0.9.0 → tinyfish-0.11.0}/README.md +141 -1
  5. {tinyfish-0.9.0 → tinyfish-0.11.0}/docs/internal/exceptions-and-errors-guide.md +1 -0
  6. {tinyfish-0.9.0 → tinyfish-0.11.0}/docs/proxy-and-browser-profiles.md +1 -9
  7. {tinyfish-0.9.0 → tinyfish-0.11.0}/pyproject.toml +4 -1
  8. {tinyfish-0.9.0 → tinyfish-0.11.0}/src/tinyfish/__init__.py +158 -0
  9. {tinyfish-0.9.0 → tinyfish-0.11.0}/src/tinyfish/_utils/client/_base.py +13 -5
  10. {tinyfish-0.9.0 → tinyfish-0.11.0}/src/tinyfish/_utils/client/async_.py +49 -11
  11. {tinyfish-0.9.0 → tinyfish-0.11.0}/src/tinyfish/_utils/client/sync.py +48 -10
  12. {tinyfish-0.9.0 → tinyfish-0.11.0}/src/tinyfish/_utils/exceptions.py +20 -0
  13. {tinyfish-0.9.0 → tinyfish-0.11.0}/src/tinyfish/_utils/resource.py +4 -0
  14. tinyfish-0.11.0/src/tinyfish/_utils/sse_parser.py +120 -0
  15. {tinyfish-0.9.0 → tinyfish-0.11.0}/src/tinyfish/agent/types.py +3 -3
  16. {tinyfish-0.9.0 → tinyfish-0.11.0}/src/tinyfish/client.py +20 -0
  17. tinyfish-0.11.0/src/tinyfish/datasets/__init__.py +358 -0
  18. tinyfish-0.11.0/src/tinyfish/datasets/types.py +199 -0
  19. tinyfish-0.11.0/src/tinyfish/monitors/__init__.py +212 -0
  20. tinyfish-0.11.0/src/tinyfish/monitors/types.py +113 -0
  21. tinyfish-0.11.0/src/tinyfish/profiles/__init__.py +113 -0
  22. tinyfish-0.11.0/src/tinyfish/profiles/types.py +66 -0
  23. tinyfish-0.11.0/src/tinyfish/research/__init__.py +604 -0
  24. tinyfish-0.11.0/src/tinyfish/research/types.py +213 -0
  25. {tinyfish-0.9.0 → tinyfish-0.11.0}/tests/test_agent.py +4 -4
  26. tinyfish-0.11.0/tests/test_datasets.py +286 -0
  27. tinyfish-0.11.0/tests/test_datasets_events.py +355 -0
  28. {tinyfish-0.9.0 → tinyfish-0.11.0}/tests/test_errors.py +3 -0
  29. tinyfish-0.11.0/tests/test_monitors.py +369 -0
  30. tinyfish-0.11.0/tests/test_profiles.py +139 -0
  31. tinyfish-0.11.0/tests/test_research.py +268 -0
  32. tinyfish-0.11.0/tests/test_research_events.py +373 -0
  33. tinyfish-0.11.0/tests/test_sse_parser.py +24 -0
  34. {tinyfish-0.9.0 → tinyfish-0.11.0}/uv.lock +8 -5
  35. tinyfish-0.9.0/CLAUDE.md +0 -59
  36. tinyfish-0.9.0/src/tinyfish/_utils/sse_parser.py +0 -62
  37. {tinyfish-0.9.0 → tinyfish-0.11.0}/.gitignore +0 -0
  38. {tinyfish-0.9.0 → tinyfish-0.11.0}/.pre-commit-config.yaml +0 -0
  39. {tinyfish-0.9.0 → tinyfish-0.11.0}/AGENTS.md +0 -0
  40. {tinyfish-0.9.0 → tinyfish-0.11.0}/RELEASE.md +0 -0
  41. {tinyfish-0.9.0 → tinyfish-0.11.0}/docs/exceptions-and-errors-guide.md +0 -0
  42. {tinyfish-0.9.0 → tinyfish-0.11.0}/docs/internal/api-integration-header.md +0 -0
  43. {tinyfish-0.9.0 → tinyfish-0.11.0}/docs/internal/publishing-private-guide.md +0 -0
  44. {tinyfish-0.9.0 → tinyfish-0.11.0}/docs/pagination-guide.md +0 -0
  45. {tinyfish-0.9.0 → tinyfish-0.11.0}/docs/streaming-guide.md +0 -0
  46. {tinyfish-0.9.0 → tinyfish-0.11.0}/src/tinyfish/_utils/__init__.py +0 -0
  47. {tinyfish-0.9.0 → tinyfish-0.11.0}/src/tinyfish/_utils/client/__init__.py +0 -0
  48. {tinyfish-0.9.0 → tinyfish-0.11.0}/src/tinyfish/agent/__init__.py +0 -0
  49. {tinyfish-0.9.0 → tinyfish-0.11.0}/src/tinyfish/browser/__init__.py +0 -0
  50. {tinyfish-0.9.0 → tinyfish-0.11.0}/src/tinyfish/browser/types.py +0 -0
  51. {tinyfish-0.9.0 → tinyfish-0.11.0}/src/tinyfish/fetch/__init__.py +0 -0
  52. {tinyfish-0.9.0 → tinyfish-0.11.0}/src/tinyfish/fetch/types.py +0 -0
  53. {tinyfish-0.9.0 → tinyfish-0.11.0}/src/tinyfish/py.typed +0 -0
  54. {tinyfish-0.9.0 → tinyfish-0.11.0}/src/tinyfish/runs/__init__.py +0 -0
  55. {tinyfish-0.9.0 → tinyfish-0.11.0}/src/tinyfish/runs/types.py +0 -0
  56. {tinyfish-0.9.0 → tinyfish-0.11.0}/src/tinyfish/search/__init__.py +0 -0
  57. {tinyfish-0.9.0 → tinyfish-0.11.0}/src/tinyfish/search/types.py +0 -0
  58. {tinyfish-0.9.0 → tinyfish-0.11.0}/src/tinyfish/vault/__init__.py +0 -0
  59. {tinyfish-0.9.0 → tinyfish-0.11.0}/src/tinyfish/vault/types.py +0 -0
  60. {tinyfish-0.9.0 → tinyfish-0.11.0}/src/tinyfish/wallet/__init__.py +0 -0
  61. {tinyfish-0.9.0 → tinyfish-0.11.0}/src/tinyfish/wallet/types.py +0 -0
  62. {tinyfish-0.9.0 → tinyfish-0.11.0}/tests/__init__.py +0 -0
  63. {tinyfish-0.9.0 → tinyfish-0.11.0}/tests/conftest.py +0 -0
  64. {tinyfish-0.9.0 → tinyfish-0.11.0}/tests/test_browser.py +0 -0
  65. {tinyfish-0.9.0 → tinyfish-0.11.0}/tests/test_client.py +0 -0
  66. {tinyfish-0.9.0 → tinyfish-0.11.0}/tests/test_fetch.py +0 -0
  67. {tinyfish-0.9.0 → tinyfish-0.11.0}/tests/test_runs.py +0 -0
  68. {tinyfish-0.9.0 → tinyfish-0.11.0}/tests/test_search.py +0 -0
  69. {tinyfish-0.9.0 → tinyfish-0.11.0}/tests/test_vault.py +0 -0
  70. {tinyfish-0.9.0 → tinyfish-0.11.0}/tests/test_wallet.py +0 -0
  71. {tinyfish-0.9.0 → tinyfish-0.11.0}/tests/testing_guide.md +0 -0
@@ -1,5 +1,43 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.11.0](https://github.com/tinyfish-io/ux-labs/compare/sdk-py/v0.10.0...sdk-py/v0.11.0) (2026-10-23)
4
+
5
+
6
+ ### Features
7
+
8
+ * **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))
9
+ * **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))
10
+
11
+
12
+ ### Documentation
13
+
14
+ * **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))
15
+
16
+ ## [0.10.0](https://github.com/tinyfish-io/ux-labs/compare/sdk-py/v0.9.0...sdk-py/v0.10.0) (2026-10-21)
17
+
18
+
19
+ ### Features
20
+
21
+ * **sdk-py:** add monitors resource ([#6220](https://github.com/tinyfish-io/ux-labs/issues/6220)) ([e6e6213](https://github.com/tinyfish-io/ux-labs/commit/e6e6213601b1337f00de67b0cb12f552cc18036f))
22
+ * **sdk-python:** add profiles.setup start, save and cancel ([#6182](https://github.com/tinyfish-io/ux-labs/issues/6182)) ([98558cf](https://github.com/tinyfish-io/ux-labs/commit/98558cf0530513e031ae96401c05b1d8db734e91))
23
+ * **sdk-python:** deep research client (queue, get, cancel) ([#6450](https://github.com/tinyfish-io/ux-labs/issues/6450)) ([bdcda58](https://github.com/tinyfish-io/ux-labs/commit/bdcda58332c880c28d06275fbcefe8ff2e8b918c))
24
+ * **sdk-python:** research events() with typed events and resume ([#6456](https://github.com/tinyfish-io/ux-labs/issues/6456)) ([ef2ff5d](https://github.com/tinyfish-io/ux-labs/commit/ef2ff5d8bd05455e08877da387494d6332e789a5))
25
+ * **sdk-python:** research run() and stream(), like agent ([#6458](https://github.com/tinyfish-io/ux-labs/issues/6458)) ([ef2ff5d](https://github.com/tinyfish-io/ux-labs/commit/ef2ff5d8bd05455e08877da387494d6332e789a5))
26
+ * **sdk-python:** research.list() with filters and cursor pagination ([#6469](https://github.com/tinyfish-io/ux-labs/issues/6469)) ([10e76fa](https://github.com/tinyfish-io/ux-labs/commit/10e76fa3d3dfa4f2ca3ce123f8d3ed43a0795947))
27
+ * **sdk:** accept any ISO country for proxy_config ([#6251](https://github.com/tinyfish-io/ux-labs/issues/6251)) ([b68d7f4](https://github.com/tinyfish-io/ux-labs/commit/b68d7f415411ade1953ec6785fb4638f191bf965))
28
+
29
+
30
+ ### Bug Fixes
31
+
32
+ * **docs:** escape Monitor pricing dollar signs ([#5917](https://github.com/tinyfish-io/ux-labs/issues/5917)) ([405df5e](https://github.com/tinyfish-io/ux-labs/commit/405df5e3b71f8f497c9fb0c3b255015052589f69))
33
+ * **security:** bump certifi to 2026.10.19 for GHSA-6q48-6c7w-9gw2 ([eab8d98](https://github.com/tinyfish-io/ux-labs/commit/eab8d98ea5df33a0c338e904481d14b062df087c))
34
+ * **security:** bump certifi to 2026.10.19 for GHSA-6q48-6c7w-9gw2 ([#6417](https://github.com/tinyfish-io/ux-labs/issues/6417)) ([eab8d98](https://github.com/tinyfish-io/ux-labs/commit/eab8d98ea5df33a0c338e904481d14b062df087c))
35
+
36
+
37
+ ### Documentation
38
+
39
+ * one REVIEW.md per area, read by every agent and CodeRabbit ([#6167](https://github.com/tinyfish-io/ux-labs/issues/6167)) ([a1a7bf2](https://github.com/tinyfish-io/ux-labs/commit/a1a7bf21d5dea35aab94593b7751e60c63d21684))
40
+
3
41
  ## [0.9.0](https://github.com/tinyfish-io/ux-labs/compare/sdk-py/v0.8.1...sdk-py/v0.9.0) (2026-09-29)
4
42
 
5
43
 
@@ -0,0 +1,24 @@
1
+ # TinyFish Python SDK (`tinyfish`)
2
+
3
+ Sync `TinyFish` and async `AsyncTinyFish` clients: run automations, stream events, manage runs. Method reference, auth patterns, changelog: `README.md`. PyPI name `tinyfish`; the npm org is `@tiny-fish/`.
4
+
5
+ ```
6
+ src/tinyfish/__init__.py exports TinyFish, AsyncTinyFish, public types
7
+ src/tinyfish/client.py sync client
8
+ src/tinyfish/agent/ agent.run(), agent.queue(), agent.stream()
9
+ src/tinyfish/runs/ runs.get(), runs.list()
10
+ src/tinyfish/_utils/ HTTP base (sync + async), retry, errors
11
+ ```
12
+
13
+ ```python
14
+ from tinyfish import TinyFish
15
+
16
+ client = TinyFish(api_key="...") # or TINYFISH_API_KEY
17
+ client.agent.run(goal="...", url="https://...").result
18
+ ```
19
+
20
+ ```bash
21
+ uv run pytest # uv, not pip or poetry
22
+ uv run ruff check . && uv run ruff format .
23
+ pre-commit install # ruff format, ruff check, uv-lock; rerun after dep changes
24
+ ```
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: tinyfish
3
- Version: 0.9.0
3
+ Version: 0.11.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,22 @@ 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
+ | [`monitors.create()`](#monitors--re-run-a-search-or-fetch-on-a-schedule) | Create a scheduled search or fetch Monitor and run its baseline | `MonitorCreateResponse` | Yes |
61
+ | [`monitors.list()` / `get()` / `update()` / `pause()` / `resume()` / `run()` / `cancel()`](#monitors--re-run-a-search-or-fetch-on-a-schedule) | Manage Monitors | `Monitor` and friends | — |
62
+ | [`research.run()`](#research--deep-research) | Run deep research, wait for the report | `ResearchRunDetail` | Yes |
63
+ | [`research.queue()`](#research--deep-research) | Queue a deep research run, return its ID | `ResearchRunAsyncResponse` | No |
64
+ | [`research.stream()`](#research--deep-research) | Start deep research, stream its events | `ResearchStream` | No |
65
+ | [`research.events()`](#research--deep-research) | Attach or reconnect to a run's events | `ResearchStream` | No |
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 | — |
60
72
  | [`wallet.get()`](#walletget--get-your-balance) | Get the caller's wallet balance, auto-reload, and rates | `WalletResponse` | — |
73
+ | [`profiles.setup.start()`](#profilessetup--sign-in-once-reuse-the-session) | Open a browser to sign in to a profile | `ProfileSetupSession` | — |
74
+ | [`profiles.setup.save()`](#profilessetup--sign-in-once-reuse-the-session) | Save the signed-in state into the profile | `ProfileSaveResult` | Yes |
75
+ | [`profiles.setup.cancel()`](#profilessetup--sign-in-once-reuse-the-session) | Close the setup browser without saving | `ProfileSetupCancelled` | — |
61
76
 
62
77
  ---
63
78
 
@@ -76,7 +91,7 @@ response = client.agent.run(
76
91
  browser_profile=BrowserProfile.STEALTH, # optional — "lite" (default) or "stealth"
77
92
  proxy_config=ProxyConfig( # optional — proxy settings
78
93
  enabled=True,
79
- country_code=ProxyCountryCode.US, # optional — US, GB, CA, DE, FR, JP, AU
94
+ country_code=ProxyCountryCode.US, # optional — any ISO 3166-1 alpha-2 code, e.g. "IN"
80
95
  ),
81
96
  output_schema={ # require structured output
82
97
  "type": "object",
@@ -356,6 +371,100 @@ Filter validation rules:
356
371
 
357
372
  ---
358
373
 
374
+ ### `monitors` — re-run a search or fetch on a schedule
375
+
376
+ A Monitor repeats a search query or page fetch on a cron schedule and reports what changed. `create()` and `run()` are billed.
377
+
378
+ ```python
379
+ from tinyfish import TinyFish
380
+
381
+ client = TinyFish()
382
+
383
+ created = client.monitors.create(
384
+ "fetch",
385
+ {"url": "https://example.com/pricing", "format": "markdown"},
386
+ "0 9 * * *",
387
+ purpose="A plan price changes",
388
+ )
389
+ monitor_id = created.monitor.id
390
+
391
+ client.monitors.pause(monitor_id)
392
+ client.monitors.update(monitor_id, schedule_cron="0 8 * * 1-5", webhook_url=None) # None clears a field
393
+ client.monitors.resume(monitor_id)
394
+ run = client.monitors.run(monitor_id).run # SearchMonitorRun or FetchMonitorRun
395
+ client.monitors.cancel(monitor_id) # deletes the Monitor and its schedule
396
+ ```
397
+
398
+ `config` is a `SearchMonitorConfig` / `FetchMonitorConfig` or a dict, and must match `type`. A `402` raises `PaymentRequiredError`; its `wallet_url` points to where to add money.
399
+
400
+ ---
401
+
402
+ ### `research` — deep research
403
+
404
+ 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). Completed runs beyond the daily free allowance are billed. 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).
405
+
406
+ ```python
407
+ run = client.research.run(query="Compare long-duration energy storage approaches", mode="deep")
408
+ if run.status == "COMPLETED" and run.deep_result: # partial reports survive failures
409
+ print(run.deep_result.result, run.deep_result.citations)
410
+
411
+ with client.research.stream(
412
+ query="Compare long-duration energy storage approaches",
413
+ on_progress=lambda e: print(e.event), # also on_created, on_heartbeat, on_final_result, on_error
414
+ ) as stream:
415
+ for event in stream:
416
+ if isinstance(event, ResearchFinalResultEvent):
417
+ print(event.result)
418
+
419
+ run_id = client.research.queue(query="Compare long-duration energy storage approaches", mode="deep").research_run_id
420
+ run = client.research.get(run_id) # ResearchRunDetail: status, deep_result, research_plan, evidence
421
+ client.research.list(status="COMPLETED", limit=20)
422
+ client.research.cancel(run_id) # cancelled=False if it already finished
423
+ ```
424
+
425
+ `events(run_id)` attaches or reconnects to a run and yields typed events until `done`. It has no overall time limit, resumes a dropped connection from the last event (`Last-Event-ID`), and leaving the `with` block detaches without cancelling. Streams have a 60s idle timeout and yield each event once; unknown event names are skipped, as in `agent.stream()`. Interrupting `run()` (Ctrl+C or task cancellation) only stops reading, as in `agent`; call `cancel(run_id)` to stop the run.
426
+
427
+ ```python
428
+ with client.research.events(run_id) as stream: # `async with` / `async for` on AsyncTinyFish
429
+ for event in stream:
430
+ print(event.event) # created, plan_updated, ..., final_result, done
431
+ ```
432
+
433
+ ---
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 100, 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
+
359
468
  ### `wallet.get()` — get your balance
360
469
 
361
470
  Returns the caller's current balance, auto-reload configuration, per-product rates, and any in-flight top-up.
@@ -405,6 +514,37 @@ except NotFoundError as e:
405
514
 
406
515
  ---
407
516
 
517
+ ### `profiles.setup` — sign in once, reuse the session
518
+
519
+ Start a setup browser for a Browser Context Profile, sign in through `cdp_url`, then save. Runs that pass `profile_id` start from that signed-in state.
520
+
521
+ ```python
522
+ from playwright.sync_api import sync_playwright
523
+ from tinyfish import TinyFish
524
+
525
+ client = TinyFish()
526
+
527
+ session = client.profiles.setup.start("prof_abc123def4567890", url="https://github.com/login")
528
+ with sync_playwright() as p:
529
+ browser = p.chromium.connect_over_cdp(session.cdp_url)
530
+ page = browser.contexts[0].pages[0]
531
+ page.fill("#login_field", "me@example.com")
532
+ page.fill("#password", "...")
533
+ page.click("input[type=submit]")
534
+ page.wait_for_url("https://github.com/")
535
+
536
+ result = client.profiles.setup.save(
537
+ "prof_abc123def4567890",
538
+ session_id=session.session_id,
539
+ signed_in_sites=["github.com"],
540
+ )
541
+ print(result.cookie_count, result.sign_in)
542
+ ```
543
+
544
+ `cancel(profile_id, session_id=...)` closes the browser without saving. Sessions expire at `session.expires_at`; a save after that returns `409`.
545
+
546
+ ---
547
+
408
548
  ## Sync vs Async
409
549
 
410
550
  Use `AsyncTinyFish` when you're in an async context (FastAPI, aiohttp, etc.):
@@ -47,7 +47,22 @@ 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
+ | [`monitors.create()`](#monitors--re-run-a-search-or-fetch-on-a-schedule) | Create a scheduled search or fetch Monitor and run its baseline | `MonitorCreateResponse` | Yes |
51
+ | [`monitors.list()` / `get()` / `update()` / `pause()` / `resume()` / `run()` / `cancel()`](#monitors--re-run-a-search-or-fetch-on-a-schedule) | Manage Monitors | `Monitor` and friends | — |
52
+ | [`research.run()`](#research--deep-research) | Run deep research, wait for the report | `ResearchRunDetail` | Yes |
53
+ | [`research.queue()`](#research--deep-research) | Queue a deep research run, return its ID | `ResearchRunAsyncResponse` | No |
54
+ | [`research.stream()`](#research--deep-research) | Start deep research, stream its events | `ResearchStream` | No |
55
+ | [`research.events()`](#research--deep-research) | Attach or reconnect to a run's events | `ResearchStream` | No |
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 | — |
50
62
  | [`wallet.get()`](#walletget--get-your-balance) | Get the caller's wallet balance, auto-reload, and rates | `WalletResponse` | — |
63
+ | [`profiles.setup.start()`](#profilessetup--sign-in-once-reuse-the-session) | Open a browser to sign in to a profile | `ProfileSetupSession` | — |
64
+ | [`profiles.setup.save()`](#profilessetup--sign-in-once-reuse-the-session) | Save the signed-in state into the profile | `ProfileSaveResult` | Yes |
65
+ | [`profiles.setup.cancel()`](#profilessetup--sign-in-once-reuse-the-session) | Close the setup browser without saving | `ProfileSetupCancelled` | — |
51
66
 
52
67
  ---
53
68
 
@@ -66,7 +81,7 @@ response = client.agent.run(
66
81
  browser_profile=BrowserProfile.STEALTH, # optional — "lite" (default) or "stealth"
67
82
  proxy_config=ProxyConfig( # optional — proxy settings
68
83
  enabled=True,
69
- country_code=ProxyCountryCode.US, # optional — US, GB, CA, DE, FR, JP, AU
84
+ country_code=ProxyCountryCode.US, # optional — any ISO 3166-1 alpha-2 code, e.g. "IN"
70
85
  ),
71
86
  output_schema={ # require structured output
72
87
  "type": "object",
@@ -346,6 +361,100 @@ Filter validation rules:
346
361
 
347
362
  ---
348
363
 
364
+ ### `monitors` — re-run a search or fetch on a schedule
365
+
366
+ A Monitor repeats a search query or page fetch on a cron schedule and reports what changed. `create()` and `run()` are billed.
367
+
368
+ ```python
369
+ from tinyfish import TinyFish
370
+
371
+ client = TinyFish()
372
+
373
+ created = client.monitors.create(
374
+ "fetch",
375
+ {"url": "https://example.com/pricing", "format": "markdown"},
376
+ "0 9 * * *",
377
+ purpose="A plan price changes",
378
+ )
379
+ monitor_id = created.monitor.id
380
+
381
+ client.monitors.pause(monitor_id)
382
+ client.monitors.update(monitor_id, schedule_cron="0 8 * * 1-5", webhook_url=None) # None clears a field
383
+ client.monitors.resume(monitor_id)
384
+ run = client.monitors.run(monitor_id).run # SearchMonitorRun or FetchMonitorRun
385
+ client.monitors.cancel(monitor_id) # deletes the Monitor and its schedule
386
+ ```
387
+
388
+ `config` is a `SearchMonitorConfig` / `FetchMonitorConfig` or a dict, and must match `type`. A `402` raises `PaymentRequiredError`; its `wallet_url` points to where to add money.
389
+
390
+ ---
391
+
392
+ ### `research` — deep research
393
+
394
+ 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). Completed runs beyond the daily free allowance are billed. 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).
395
+
396
+ ```python
397
+ run = client.research.run(query="Compare long-duration energy storage approaches", mode="deep")
398
+ if run.status == "COMPLETED" and run.deep_result: # partial reports survive failures
399
+ print(run.deep_result.result, run.deep_result.citations)
400
+
401
+ with client.research.stream(
402
+ query="Compare long-duration energy storage approaches",
403
+ on_progress=lambda e: print(e.event), # also on_created, on_heartbeat, on_final_result, on_error
404
+ ) as stream:
405
+ for event in stream:
406
+ if isinstance(event, ResearchFinalResultEvent):
407
+ print(event.result)
408
+
409
+ run_id = client.research.queue(query="Compare long-duration energy storage approaches", mode="deep").research_run_id
410
+ run = client.research.get(run_id) # ResearchRunDetail: status, deep_result, research_plan, evidence
411
+ client.research.list(status="COMPLETED", limit=20)
412
+ client.research.cancel(run_id) # cancelled=False if it already finished
413
+ ```
414
+
415
+ `events(run_id)` attaches or reconnects to a run and yields typed events until `done`. It has no overall time limit, resumes a dropped connection from the last event (`Last-Event-ID`), and leaving the `with` block detaches without cancelling. Streams have a 60s idle timeout and yield each event once; unknown event names are skipped, as in `agent.stream()`. Interrupting `run()` (Ctrl+C or task cancellation) only stops reading, as in `agent`; call `cancel(run_id)` to stop the run.
416
+
417
+ ```python
418
+ with client.research.events(run_id) as stream: # `async with` / `async for` on AsyncTinyFish
419
+ for event in stream:
420
+ print(event.event) # created, plan_updated, ..., final_result, done
421
+ ```
422
+
423
+ ---
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 100, 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
+
349
458
  ### `wallet.get()` — get your balance
350
459
 
351
460
  Returns the caller's current balance, auto-reload configuration, per-product rates, and any in-flight top-up.
@@ -395,6 +504,37 @@ except NotFoundError as e:
395
504
 
396
505
  ---
397
506
 
507
+ ### `profiles.setup` — sign in once, reuse the session
508
+
509
+ Start a setup browser for a Browser Context Profile, sign in through `cdp_url`, then save. Runs that pass `profile_id` start from that signed-in state.
510
+
511
+ ```python
512
+ from playwright.sync_api import sync_playwright
513
+ from tinyfish import TinyFish
514
+
515
+ client = TinyFish()
516
+
517
+ session = client.profiles.setup.start("prof_abc123def4567890", url="https://github.com/login")
518
+ with sync_playwright() as p:
519
+ browser = p.chromium.connect_over_cdp(session.cdp_url)
520
+ page = browser.contexts[0].pages[0]
521
+ page.fill("#login_field", "me@example.com")
522
+ page.fill("#password", "...")
523
+ page.click("input[type=submit]")
524
+ page.wait_for_url("https://github.com/")
525
+
526
+ result = client.profiles.setup.save(
527
+ "prof_abc123def4567890",
528
+ session_id=session.session_id,
529
+ signed_in_sites=["github.com"],
530
+ )
531
+ print(result.cookie_count, result.sign_in)
532
+ ```
533
+
534
+ `cancel(profile_id, session_id=...)` closes the browser without saving. Sessions expire at `session.expires_at`; a save after that returns `409`.
535
+
536
+ ---
537
+
398
538
  ## Sync vs Async
399
539
 
400
540
  Use `AsyncTinyFish` when you're in an async context (FastAPI, aiohttp, etc.):
@@ -77,6 +77,7 @@ SDKError
77
77
  └─ APIStatusError ← carries .status_code and .code (machine-readable, from error.code) too
78
78
  ├─ BadRequestError (400)
79
79
  ├─ AuthenticationError (401)
80
+ ├─ PaymentRequiredError (402) ← also .wallet_url, from error.details
80
81
  ├─ PermissionDeniedError (403)
81
82
  ├─ NotFoundError (404)
82
83
  ├─ RequestTimeoutError (408) ← server-side timeout
@@ -73,15 +73,7 @@ response = client.agent.run(
73
73
 
74
74
  ### Available countries
75
75
 
76
- | Code | Country |
77
- |------|---------|
78
- | `US` | United States |
79
- | `GB` | United Kingdom |
80
- | `CA` | Canada |
81
- | `DE` | Germany |
82
- | `FR` | France |
83
- | `JP` | Japan |
84
- | `AU` | Australia |
76
+ Any ISO 3166-1 alpha-2 code, for example `"IN"`. `ProxyCountryCode` has constants for common ones: `US`, `GB`, `CA`, `DE`, `FR`, `JP`, `AU`.
85
77
 
86
78
  ## Works with all integration methods
87
79
 
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "tinyfish"
3
- version = "0.9.0"
3
+ version = "0.11.0"
4
4
  description = "Official Python SDK for the TinyFish API"
5
5
  readme = "README.md"
6
6
  requires-python = ">=3.11"
@@ -16,6 +16,9 @@ constraint-dependencies = [
16
16
  "pygments>=2.20.0",
17
17
  ]
18
18
 
19
+ [tool.uv.exclude-newer-package]
20
+ certifi = false # adopt GHSA-6q48-6c7w-9gw2 fix despite 7-day gate
21
+
19
22
  [build-system]
20
23
  requires = ["hatchling"]
21
24
  build-backend = "hatchling.build"
@@ -16,6 +16,7 @@ from ._utils.exceptions import (
16
16
  ConflictError,
17
17
  InternalServerError,
18
18
  NotFoundError,
19
+ PaymentRequiredError,
19
20
  PermissionDeniedError,
20
21
  RateLimitError,
21
22
  RequestTimeoutError,
@@ -48,6 +49,32 @@ from .agent.types import (
48
49
  # Browser types
49
50
  from .browser.types import BrowserProxyConfig, BrowserSession, BrowserSessionCreateParams
50
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
+ )
51
78
  from .fetch.types import (
52
79
  FetchError,
53
80
  FetchFormat,
@@ -57,6 +84,63 @@ from .fetch.types import (
57
84
  HighlightSnippet,
58
85
  )
59
86
 
87
+ # Monitors types
88
+ from .monitors.types import (
89
+ FetchMonitorConfig,
90
+ FetchMonitorResult,
91
+ FetchMonitorRun,
92
+ Monitor,
93
+ MonitorConfig,
94
+ MonitorCreateResponse,
95
+ MonitorDeleteResponse,
96
+ MonitorListResponse,
97
+ MonitorRun,
98
+ MonitorRunResponse,
99
+ MonitorStatus,
100
+ MonitorType,
101
+ SearchMonitorConfig,
102
+ SearchMonitorRun,
103
+ )
104
+
105
+ # Profiles types
106
+ from .profiles.types import (
107
+ ProfileDomainsSkipped,
108
+ ProfileRejectedSite,
109
+ ProfileSaveResult,
110
+ ProfileSetupCancelled,
111
+ ProfileSetupSession,
112
+ ProfileSetupSignIn,
113
+ ProfileUserConfirmedSites,
114
+ )
115
+ from .research import AsyncResearchStream, ResearchStream
116
+
117
+ # Research types
118
+ from .research.types import (
119
+ ResearchCancelResponse,
120
+ ResearchClaim,
121
+ ResearchCreatedEvent,
122
+ ResearchDomainFilter,
123
+ ResearchDomainType,
124
+ ResearchDoneEvent,
125
+ ResearchError,
126
+ ResearchErrorEvent,
127
+ ResearchEvent,
128
+ ResearchEvidence,
129
+ ResearchFinalResultEvent,
130
+ ResearchListResponse,
131
+ ResearchMode,
132
+ ResearchPlan,
133
+ ResearchProgressEventName,
134
+ ResearchQuickResult,
135
+ ResearchReport,
136
+ ResearchRun,
137
+ ResearchRunAsyncResponse,
138
+ ResearchRunDetail,
139
+ ResearchRunStatus,
140
+ ResearchStreamEvent,
141
+ ResearchSubquestion,
142
+ )
143
+
60
144
  # Runs types
61
145
  from .runs.types import (
62
146
  ErrorCategory,
@@ -111,6 +195,7 @@ __all__ = [
111
195
  "APIStatusError",
112
196
  "BadRequestError",
113
197
  "AuthenticationError",
198
+ "PaymentRequiredError",
114
199
  "PermissionDeniedError",
115
200
  "NotFoundError",
116
201
  "RequestTimeoutError",
@@ -121,10 +206,22 @@ __all__ = [
121
206
  # Agent resource
122
207
  "AgentStream",
123
208
  "AsyncAgentStream",
209
+ "ResearchStream",
210
+ "AsyncResearchStream",
211
+ "DatasetRunStream",
212
+ "AsyncDatasetRunStream",
124
213
  # Browser types
125
214
  "BrowserSession",
126
215
  "BrowserProxyConfig",
127
216
  "BrowserSessionCreateParams",
217
+ # Profiles types
218
+ "ProfileSetupSession",
219
+ "ProfileSaveResult",
220
+ "ProfileSetupCancelled",
221
+ "ProfileSetupSignIn",
222
+ "ProfileUserConfirmedSites",
223
+ "ProfileRejectedSite",
224
+ "ProfileDomainsSkipped",
128
225
  # Agent types
129
226
  "EventType",
130
227
  "AgentConfig",
@@ -149,6 +246,67 @@ __all__ = [
149
246
  "FetchResponse",
150
247
  "FetchHighlights",
151
248
  "HighlightSnippet",
249
+ # Monitors types
250
+ "MonitorType",
251
+ "MonitorStatus",
252
+ "SearchMonitorConfig",
253
+ "FetchMonitorConfig",
254
+ "MonitorConfig",
255
+ "Monitor",
256
+ "SearchMonitorRun",
257
+ "FetchMonitorRun",
258
+ "FetchMonitorResult",
259
+ "MonitorRun",
260
+ "MonitorCreateResponse",
261
+ "MonitorListResponse",
262
+ "MonitorRunResponse",
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",
286
+ # Research types
287
+ "ResearchMode",
288
+ "ResearchRunStatus",
289
+ "ResearchDomainType",
290
+ "ResearchDomainFilter",
291
+ "ResearchError",
292
+ "ResearchQuickResult",
293
+ "ResearchReport",
294
+ "ResearchRun",
295
+ "ResearchRunDetail",
296
+ "ResearchPlan",
297
+ "ResearchSubquestion",
298
+ "ResearchEvidence",
299
+ "ResearchClaim",
300
+ "ResearchRunAsyncResponse",
301
+ "ResearchListResponse",
302
+ "ResearchCancelResponse",
303
+ "ResearchEvent",
304
+ "ResearchCreatedEvent",
305
+ "ResearchFinalResultEvent",
306
+ "ResearchErrorEvent",
307
+ "ResearchDoneEvent",
308
+ "ResearchStreamEvent",
309
+ "ResearchProgressEventName",
152
310
  # Search types
153
311
  "SearchResult",
154
312
  "SearchQueryResponse",