tinyfish 0.8.1__tar.gz → 0.10.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 (66) hide show
  1. {tinyfish-0.8.1 → tinyfish-0.10.0}/CHANGELOG.md +37 -0
  2. tinyfish-0.10.0/CLAUDE.md +24 -0
  3. {tinyfish-0.8.1 → tinyfish-0.10.0}/PKG-INFO +104 -2
  4. {tinyfish-0.8.1 → tinyfish-0.10.0}/README.md +103 -1
  5. {tinyfish-0.8.1 → tinyfish-0.10.0}/docs/internal/exceptions-and-errors-guide.md +1 -0
  6. {tinyfish-0.8.1 → tinyfish-0.10.0}/docs/proxy-and-browser-profiles.md +24 -9
  7. {tinyfish-0.8.1 → tinyfish-0.10.0}/pyproject.toml +4 -1
  8. {tinyfish-0.8.1 → tinyfish-0.10.0}/src/tinyfish/__init__.py +110 -1
  9. {tinyfish-0.8.1 → tinyfish-0.10.0}/src/tinyfish/_utils/client/_base.py +13 -5
  10. {tinyfish-0.8.1 → tinyfish-0.10.0}/src/tinyfish/_utils/client/async_.py +49 -11
  11. {tinyfish-0.8.1 → tinyfish-0.10.0}/src/tinyfish/_utils/client/sync.py +48 -10
  12. {tinyfish-0.8.1 → tinyfish-0.10.0}/src/tinyfish/_utils/exceptions.py +20 -0
  13. {tinyfish-0.8.1 → tinyfish-0.10.0}/src/tinyfish/_utils/resource.py +4 -0
  14. {tinyfish-0.8.1 → tinyfish-0.10.0}/src/tinyfish/_utils/sse_parser.py +52 -1
  15. {tinyfish-0.8.1 → tinyfish-0.10.0}/src/tinyfish/agent/types.py +3 -3
  16. {tinyfish-0.8.1 → tinyfish-0.10.0}/src/tinyfish/browser/__init__.py +9 -3
  17. tinyfish-0.10.0/src/tinyfish/browser/types.py +52 -0
  18. {tinyfish-0.8.1 → tinyfish-0.10.0}/src/tinyfish/client.py +15 -0
  19. tinyfish-0.10.0/src/tinyfish/monitors/__init__.py +212 -0
  20. tinyfish-0.10.0/src/tinyfish/monitors/types.py +113 -0
  21. tinyfish-0.10.0/src/tinyfish/profiles/__init__.py +113 -0
  22. tinyfish-0.10.0/src/tinyfish/profiles/types.py +66 -0
  23. tinyfish-0.10.0/src/tinyfish/research/__init__.py +604 -0
  24. tinyfish-0.10.0/src/tinyfish/research/types.py +213 -0
  25. {tinyfish-0.8.1 → tinyfish-0.10.0}/tests/test_agent.py +4 -4
  26. {tinyfish-0.8.1 → tinyfish-0.10.0}/tests/test_browser.py +51 -1
  27. {tinyfish-0.8.1 → tinyfish-0.10.0}/tests/test_errors.py +3 -0
  28. tinyfish-0.10.0/tests/test_monitors.py +369 -0
  29. tinyfish-0.10.0/tests/test_profiles.py +139 -0
  30. tinyfish-0.10.0/tests/test_research.py +268 -0
  31. tinyfish-0.10.0/tests/test_research_events.py +373 -0
  32. {tinyfish-0.8.1 → tinyfish-0.10.0}/uv.lock +15 -12
  33. tinyfish-0.8.1/CLAUDE.md +0 -59
  34. tinyfish-0.8.1/src/tinyfish/browser/types.py +0 -24
  35. {tinyfish-0.8.1 → tinyfish-0.10.0}/.gitignore +0 -0
  36. {tinyfish-0.8.1 → tinyfish-0.10.0}/.pre-commit-config.yaml +0 -0
  37. {tinyfish-0.8.1 → tinyfish-0.10.0}/AGENTS.md +0 -0
  38. {tinyfish-0.8.1 → tinyfish-0.10.0}/RELEASE.md +0 -0
  39. {tinyfish-0.8.1 → tinyfish-0.10.0}/docs/exceptions-and-errors-guide.md +0 -0
  40. {tinyfish-0.8.1 → tinyfish-0.10.0}/docs/internal/api-integration-header.md +0 -0
  41. {tinyfish-0.8.1 → tinyfish-0.10.0}/docs/internal/publishing-private-guide.md +0 -0
  42. {tinyfish-0.8.1 → tinyfish-0.10.0}/docs/pagination-guide.md +0 -0
  43. {tinyfish-0.8.1 → tinyfish-0.10.0}/docs/streaming-guide.md +0 -0
  44. {tinyfish-0.8.1 → tinyfish-0.10.0}/src/tinyfish/_utils/__init__.py +0 -0
  45. {tinyfish-0.8.1 → tinyfish-0.10.0}/src/tinyfish/_utils/client/__init__.py +0 -0
  46. {tinyfish-0.8.1 → tinyfish-0.10.0}/src/tinyfish/agent/__init__.py +0 -0
  47. {tinyfish-0.8.1 → tinyfish-0.10.0}/src/tinyfish/fetch/__init__.py +0 -0
  48. {tinyfish-0.8.1 → tinyfish-0.10.0}/src/tinyfish/fetch/types.py +0 -0
  49. {tinyfish-0.8.1 → tinyfish-0.10.0}/src/tinyfish/py.typed +0 -0
  50. {tinyfish-0.8.1 → tinyfish-0.10.0}/src/tinyfish/runs/__init__.py +0 -0
  51. {tinyfish-0.8.1 → tinyfish-0.10.0}/src/tinyfish/runs/types.py +0 -0
  52. {tinyfish-0.8.1 → tinyfish-0.10.0}/src/tinyfish/search/__init__.py +0 -0
  53. {tinyfish-0.8.1 → tinyfish-0.10.0}/src/tinyfish/search/types.py +0 -0
  54. {tinyfish-0.8.1 → tinyfish-0.10.0}/src/tinyfish/vault/__init__.py +0 -0
  55. {tinyfish-0.8.1 → tinyfish-0.10.0}/src/tinyfish/vault/types.py +0 -0
  56. {tinyfish-0.8.1 → tinyfish-0.10.0}/src/tinyfish/wallet/__init__.py +0 -0
  57. {tinyfish-0.8.1 → tinyfish-0.10.0}/src/tinyfish/wallet/types.py +0 -0
  58. {tinyfish-0.8.1 → tinyfish-0.10.0}/tests/__init__.py +0 -0
  59. {tinyfish-0.8.1 → tinyfish-0.10.0}/tests/conftest.py +0 -0
  60. {tinyfish-0.8.1 → tinyfish-0.10.0}/tests/test_client.py +0 -0
  61. {tinyfish-0.8.1 → tinyfish-0.10.0}/tests/test_fetch.py +0 -0
  62. {tinyfish-0.8.1 → tinyfish-0.10.0}/tests/test_runs.py +0 -0
  63. {tinyfish-0.8.1 → tinyfish-0.10.0}/tests/test_search.py +0 -0
  64. {tinyfish-0.8.1 → tinyfish-0.10.0}/tests/test_vault.py +0 -0
  65. {tinyfish-0.8.1 → tinyfish-0.10.0}/tests/test_wallet.py +0 -0
  66. {tinyfish-0.8.1 → tinyfish-0.10.0}/tests/testing_guide.md +0 -0
@@ -1,5 +1,42 @@
1
1
  # Changelog
2
2
 
3
+ ## [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
+
5
+
6
+ ### Features
7
+
8
+ * **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))
9
+ * **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))
10
+ * **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))
11
+ * **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))
12
+ * **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))
13
+ * **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))
14
+ * **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))
15
+
16
+
17
+ ### Bug Fixes
18
+
19
+ * **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))
20
+ * **security:** bump certifi to 2026.10.19 for GHSA-6q48-6c7w-9gw2 ([eab8d98](https://github.com/tinyfish-io/ux-labs/commit/eab8d98ea5df33a0c338e904481d14b062df087c))
21
+ * **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))
22
+
23
+
24
+ ### Documentation
25
+
26
+ * 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))
27
+
28
+ ## [0.9.0](https://github.com/tinyfish-io/ux-labs/compare/sdk-py/v0.8.1...sdk-py/v0.9.0) (2026-09-29)
29
+
30
+
31
+ ### Features
32
+
33
+ * **sdk:** add proxy_config to browser session create ([#5593](https://github.com/tinyfish-io/ux-labs/issues/5593)) ([f7333f8](https://github.com/tinyfish-io/ux-labs/commit/f7333f82c9b8c366edf4656f2885ea98cdfc5def))
34
+
35
+
36
+ ### Bug Fixes
37
+
38
+ * **security:** upgrade anyio to 4.14.2+ across Python lockfiles ([#5213](https://github.com/tinyfish-io/ux-labs/issues/5213)) ([c65a598](https://github.com/tinyfish-io/ux-labs/commit/c65a598ea0971b44155b8cea6be3f39b955603b6))
39
+
3
40
  ## [0.8.1](https://github.com/tinyfish-io/ux-labs/compare/sdk-py/v0.8.0...sdk-py/v0.8.1) (2026-09-16)
4
41
 
5
42
 
@@ -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.8.1
3
+ Version: 0.10.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,17 @@ 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 | — |
60
67
  | [`wallet.get()`](#walletget--get-your-balance) | Get the caller's wallet balance, auto-reload, and rates | `WalletResponse` | — |
68
+ | [`profiles.setup.start()`](#profilessetup--sign-in-once-reuse-the-session) | Open a browser to sign in to a profile | `ProfileSetupSession` | — |
69
+ | [`profiles.setup.save()`](#profilessetup--sign-in-once-reuse-the-session) | Save the signed-in state into the profile | `ProfileSaveResult` | Yes |
70
+ | [`profiles.setup.cancel()`](#profilessetup--sign-in-once-reuse-the-session) | Close the setup browser without saving | `ProfileSetupCancelled` | — |
61
71
 
62
72
  ---
63
73
 
@@ -76,7 +86,7 @@ response = client.agent.run(
76
86
  browser_profile=BrowserProfile.STEALTH, # optional — "lite" (default) or "stealth"
77
87
  proxy_config=ProxyConfig( # optional — proxy settings
78
88
  enabled=True,
79
- country_code=ProxyCountryCode.US, # optional — US, GB, CA, DE, FR, JP, AU
89
+ country_code=ProxyCountryCode.US, # optional — any ISO 3166-1 alpha-2 code, e.g. "IN"
80
90
  ),
81
91
  output_schema={ # require structured output
82
92
  "type": "object",
@@ -356,6 +366,67 @@ Filter validation rules:
356
366
 
357
367
  ---
358
368
 
369
+ ### `monitors` — re-run a search or fetch on a schedule
370
+
371
+ A Monitor repeats a search query or page fetch on a cron schedule and reports what changed. `create()` and `run()` are billed.
372
+
373
+ ```python
374
+ from tinyfish import TinyFish
375
+
376
+ client = TinyFish()
377
+
378
+ created = client.monitors.create(
379
+ "fetch",
380
+ {"url": "https://example.com/pricing", "format": "markdown"},
381
+ "0 9 * * *",
382
+ purpose="A plan price changes",
383
+ )
384
+ monitor_id = created.monitor.id
385
+
386
+ client.monitors.pause(monitor_id)
387
+ client.monitors.update(monitor_id, schedule_cron="0 8 * * 1-5", webhook_url=None) # None clears a field
388
+ client.monitors.resume(monitor_id)
389
+ run = client.monitors.run(monitor_id).run # SearchMonitorRun or FetchMonitorRun
390
+ client.monitors.cancel(monitor_id) # deletes the Monitor and its schedule
391
+ ```
392
+
393
+ `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.
394
+
395
+ ---
396
+
397
+ ### `research` — deep research
398
+
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.
400
+
401
+ ```python
402
+ run = client.research.run(query="Compare long-duration energy storage approaches", mode="deep")
403
+ if run.status == "COMPLETED" and run.deep_result: # partial reports survive failures
404
+ print(run.deep_result.result, run.deep_result.citations)
405
+
406
+ with client.research.stream(
407
+ query="Compare long-duration energy storage approaches",
408
+ on_progress=lambda e: print(e.event), # also on_created, on_heartbeat, on_final_result, on_error
409
+ ) as stream:
410
+ for event in stream:
411
+ if isinstance(event, ResearchFinalResultEvent):
412
+ print(event.result)
413
+
414
+ run_id = client.research.queue(query="Compare long-duration energy storage approaches", mode="deep").research_run_id
415
+ run = client.research.get(run_id) # ResearchRunDetail: status, deep_result, research_plan, evidence
416
+ client.research.list(status="COMPLETED", limit=20)
417
+ client.research.cancel(run_id) # cancelled=False if it already finished
418
+ ```
419
+
420
+ `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.
421
+
422
+ ```python
423
+ with client.research.events(run_id) as stream: # `async with` / `async for` on AsyncTinyFish
424
+ for event in stream:
425
+ print(event.event) # created, plan_updated, ..., final_result, done
426
+ ```
427
+
428
+ ---
429
+
359
430
  ### `wallet.get()` — get your balance
360
431
 
361
432
  Returns the caller's current balance, auto-reload configuration, per-product rates, and any in-flight top-up.
@@ -405,6 +476,37 @@ except NotFoundError as e:
405
476
 
406
477
  ---
407
478
 
479
+ ### `profiles.setup` — sign in once, reuse the session
480
+
481
+ 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.
482
+
483
+ ```python
484
+ from playwright.sync_api import sync_playwright
485
+ from tinyfish import TinyFish
486
+
487
+ client = TinyFish()
488
+
489
+ session = client.profiles.setup.start("prof_abc123def4567890", url="https://github.com/login")
490
+ with sync_playwright() as p:
491
+ browser = p.chromium.connect_over_cdp(session.cdp_url)
492
+ page = browser.contexts[0].pages[0]
493
+ page.fill("#login_field", "me@example.com")
494
+ page.fill("#password", "...")
495
+ page.click("input[type=submit]")
496
+ page.wait_for_url("https://github.com/")
497
+
498
+ result = client.profiles.setup.save(
499
+ "prof_abc123def4567890",
500
+ session_id=session.session_id,
501
+ signed_in_sites=["github.com"],
502
+ )
503
+ print(result.cookie_count, result.sign_in)
504
+ ```
505
+
506
+ `cancel(profile_id, session_id=...)` closes the browser without saving. Sessions expire at `session.expires_at`; a save after that returns `409`.
507
+
508
+ ---
509
+
408
510
  ## Sync vs Async
409
511
 
410
512
  Use `AsyncTinyFish` when you're in an async context (FastAPI, aiohttp, etc.):
@@ -47,7 +47,17 @@ 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 | — |
50
57
  | [`wallet.get()`](#walletget--get-your-balance) | Get the caller's wallet balance, auto-reload, and rates | `WalletResponse` | — |
58
+ | [`profiles.setup.start()`](#profilessetup--sign-in-once-reuse-the-session) | Open a browser to sign in to a profile | `ProfileSetupSession` | — |
59
+ | [`profiles.setup.save()`](#profilessetup--sign-in-once-reuse-the-session) | Save the signed-in state into the profile | `ProfileSaveResult` | Yes |
60
+ | [`profiles.setup.cancel()`](#profilessetup--sign-in-once-reuse-the-session) | Close the setup browser without saving | `ProfileSetupCancelled` | — |
51
61
 
52
62
  ---
53
63
 
@@ -66,7 +76,7 @@ response = client.agent.run(
66
76
  browser_profile=BrowserProfile.STEALTH, # optional — "lite" (default) or "stealth"
67
77
  proxy_config=ProxyConfig( # optional — proxy settings
68
78
  enabled=True,
69
- country_code=ProxyCountryCode.US, # optional — US, GB, CA, DE, FR, JP, AU
79
+ country_code=ProxyCountryCode.US, # optional — any ISO 3166-1 alpha-2 code, e.g. "IN"
70
80
  ),
71
81
  output_schema={ # require structured output
72
82
  "type": "object",
@@ -346,6 +356,67 @@ Filter validation rules:
346
356
 
347
357
  ---
348
358
 
359
+ ### `monitors` — re-run a search or fetch on a schedule
360
+
361
+ A Monitor repeats a search query or page fetch on a cron schedule and reports what changed. `create()` and `run()` are billed.
362
+
363
+ ```python
364
+ from tinyfish import TinyFish
365
+
366
+ client = TinyFish()
367
+
368
+ created = client.monitors.create(
369
+ "fetch",
370
+ {"url": "https://example.com/pricing", "format": "markdown"},
371
+ "0 9 * * *",
372
+ purpose="A plan price changes",
373
+ )
374
+ monitor_id = created.monitor.id
375
+
376
+ client.monitors.pause(monitor_id)
377
+ client.monitors.update(monitor_id, schedule_cron="0 8 * * 1-5", webhook_url=None) # None clears a field
378
+ client.monitors.resume(monitor_id)
379
+ run = client.monitors.run(monitor_id).run # SearchMonitorRun or FetchMonitorRun
380
+ client.monitors.cancel(monitor_id) # deletes the Monitor and its schedule
381
+ ```
382
+
383
+ `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.
384
+
385
+ ---
386
+
387
+ ### `research` — deep research
388
+
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.
390
+
391
+ ```python
392
+ run = client.research.run(query="Compare long-duration energy storage approaches", mode="deep")
393
+ if run.status == "COMPLETED" and run.deep_result: # partial reports survive failures
394
+ print(run.deep_result.result, run.deep_result.citations)
395
+
396
+ with client.research.stream(
397
+ query="Compare long-duration energy storage approaches",
398
+ on_progress=lambda e: print(e.event), # also on_created, on_heartbeat, on_final_result, on_error
399
+ ) as stream:
400
+ for event in stream:
401
+ if isinstance(event, ResearchFinalResultEvent):
402
+ print(event.result)
403
+
404
+ run_id = client.research.queue(query="Compare long-duration energy storage approaches", mode="deep").research_run_id
405
+ run = client.research.get(run_id) # ResearchRunDetail: status, deep_result, research_plan, evidence
406
+ client.research.list(status="COMPLETED", limit=20)
407
+ client.research.cancel(run_id) # cancelled=False if it already finished
408
+ ```
409
+
410
+ `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.
411
+
412
+ ```python
413
+ with client.research.events(run_id) as stream: # `async with` / `async for` on AsyncTinyFish
414
+ for event in stream:
415
+ print(event.event) # created, plan_updated, ..., final_result, done
416
+ ```
417
+
418
+ ---
419
+
349
420
  ### `wallet.get()` — get your balance
350
421
 
351
422
  Returns the caller's current balance, auto-reload configuration, per-product rates, and any in-flight top-up.
@@ -395,6 +466,37 @@ except NotFoundError as e:
395
466
 
396
467
  ---
397
468
 
469
+ ### `profiles.setup` — sign in once, reuse the session
470
+
471
+ 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.
472
+
473
+ ```python
474
+ from playwright.sync_api import sync_playwright
475
+ from tinyfish import TinyFish
476
+
477
+ client = TinyFish()
478
+
479
+ session = client.profiles.setup.start("prof_abc123def4567890", url="https://github.com/login")
480
+ with sync_playwright() as p:
481
+ browser = p.chromium.connect_over_cdp(session.cdp_url)
482
+ page = browser.contexts[0].pages[0]
483
+ page.fill("#login_field", "me@example.com")
484
+ page.fill("#password", "...")
485
+ page.click("input[type=submit]")
486
+ page.wait_for_url("https://github.com/")
487
+
488
+ result = client.profiles.setup.save(
489
+ "prof_abc123def4567890",
490
+ session_id=session.session_id,
491
+ signed_in_sites=["github.com"],
492
+ )
493
+ print(result.cookie_count, result.sign_in)
494
+ ```
495
+
496
+ `cancel(profile_id, session_id=...)` closes the browser without saving. Sessions expire at `session.expires_at`; a save after that returns `409`.
497
+
498
+ ---
499
+
398
500
  ## Sync vs Async
399
501
 
400
502
  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
 
@@ -121,3 +113,26 @@ run = client.runs.get("run_abc123")
121
113
  print(run.browser_config.proxy_enabled) # True/False
122
114
  print(run.browser_config.proxy_country_code) # "US" or None
123
115
  ```
116
+
117
+ ## Browser API sessions
118
+
119
+ `client.browser.sessions.create()` takes its own `proxy_config` (`BrowserProxyConfig`). Omit it to use the TinyFish residential proxy in the US; the session keeps the same exit IP across its connections.
120
+
121
+ ```python
122
+ from tinyfish import BrowserProxyConfig, TinyFish
123
+
124
+ client = TinyFish()
125
+
126
+ # Another country (any ISO 3166-1 alpha-2 code)
127
+ session = client.browser.sessions.create(proxy_config=BrowserProxyConfig(country_code="DE"))
128
+
129
+ # Your own HTTP(S) proxy
130
+ session = client.browser.sessions.create(
131
+ proxy_config=BrowserProxyConfig(
132
+ type="custom", url="http://proxy.example.com:8080", username="user", password="pass"
133
+ )
134
+ )
135
+
136
+ # No proxy
137
+ session = client.browser.sessions.create(proxy_config=BrowserProxyConfig(enabled=False))
138
+ ```
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "tinyfish"
3
- version = "0.8.1"
3
+ version = "0.10.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,
@@ -46,7 +47,7 @@ from .agent.types import (
46
47
  )
47
48
 
48
49
  # Browser types
49
- from .browser.types import BrowserSession, BrowserSessionCreateParams
50
+ from .browser.types import BrowserProxyConfig, BrowserSession, BrowserSessionCreateParams
50
51
  from .client import AsyncTinyFish, TinyFish
51
52
  from .fetch.types import (
52
53
  FetchError,
@@ -57,6 +58,63 @@ from .fetch.types import (
57
58
  HighlightSnippet,
58
59
  )
59
60
 
61
+ # Monitors types
62
+ from .monitors.types import (
63
+ FetchMonitorConfig,
64
+ FetchMonitorResult,
65
+ FetchMonitorRun,
66
+ Monitor,
67
+ MonitorConfig,
68
+ MonitorCreateResponse,
69
+ MonitorDeleteResponse,
70
+ MonitorListResponse,
71
+ MonitorRun,
72
+ MonitorRunResponse,
73
+ MonitorStatus,
74
+ MonitorType,
75
+ SearchMonitorConfig,
76
+ SearchMonitorRun,
77
+ )
78
+
79
+ # Profiles types
80
+ from .profiles.types import (
81
+ ProfileDomainsSkipped,
82
+ ProfileRejectedSite,
83
+ ProfileSaveResult,
84
+ ProfileSetupCancelled,
85
+ ProfileSetupSession,
86
+ ProfileSetupSignIn,
87
+ ProfileUserConfirmedSites,
88
+ )
89
+ from .research import AsyncResearchStream, ResearchStream
90
+
91
+ # Research types
92
+ from .research.types import (
93
+ ResearchCancelResponse,
94
+ ResearchClaim,
95
+ ResearchCreatedEvent,
96
+ ResearchDomainFilter,
97
+ ResearchDomainType,
98
+ ResearchDoneEvent,
99
+ ResearchError,
100
+ ResearchErrorEvent,
101
+ ResearchEvent,
102
+ ResearchEvidence,
103
+ ResearchFinalResultEvent,
104
+ ResearchListResponse,
105
+ ResearchMode,
106
+ ResearchPlan,
107
+ ResearchProgressEventName,
108
+ ResearchQuickResult,
109
+ ResearchReport,
110
+ ResearchRun,
111
+ ResearchRunAsyncResponse,
112
+ ResearchRunDetail,
113
+ ResearchRunStatus,
114
+ ResearchStreamEvent,
115
+ ResearchSubquestion,
116
+ )
117
+
60
118
  # Runs types
61
119
  from .runs.types import (
62
120
  ErrorCategory,
@@ -111,6 +169,7 @@ __all__ = [
111
169
  "APIStatusError",
112
170
  "BadRequestError",
113
171
  "AuthenticationError",
172
+ "PaymentRequiredError",
114
173
  "PermissionDeniedError",
115
174
  "NotFoundError",
116
175
  "RequestTimeoutError",
@@ -121,9 +180,20 @@ __all__ = [
121
180
  # Agent resource
122
181
  "AgentStream",
123
182
  "AsyncAgentStream",
183
+ "ResearchStream",
184
+ "AsyncResearchStream",
124
185
  # Browser types
125
186
  "BrowserSession",
187
+ "BrowserProxyConfig",
126
188
  "BrowserSessionCreateParams",
189
+ # Profiles types
190
+ "ProfileSetupSession",
191
+ "ProfileSaveResult",
192
+ "ProfileSetupCancelled",
193
+ "ProfileSetupSignIn",
194
+ "ProfileUserConfirmedSites",
195
+ "ProfileRejectedSite",
196
+ "ProfileDomainsSkipped",
127
197
  # Agent types
128
198
  "EventType",
129
199
  "AgentConfig",
@@ -148,6 +218,45 @@ __all__ = [
148
218
  "FetchResponse",
149
219
  "FetchHighlights",
150
220
  "HighlightSnippet",
221
+ # Monitors types
222
+ "MonitorType",
223
+ "MonitorStatus",
224
+ "SearchMonitorConfig",
225
+ "FetchMonitorConfig",
226
+ "MonitorConfig",
227
+ "Monitor",
228
+ "SearchMonitorRun",
229
+ "FetchMonitorRun",
230
+ "FetchMonitorResult",
231
+ "MonitorRun",
232
+ "MonitorCreateResponse",
233
+ "MonitorListResponse",
234
+ "MonitorRunResponse",
235
+ "MonitorDeleteResponse",
236
+ # Research types
237
+ "ResearchMode",
238
+ "ResearchRunStatus",
239
+ "ResearchDomainType",
240
+ "ResearchDomainFilter",
241
+ "ResearchError",
242
+ "ResearchQuickResult",
243
+ "ResearchReport",
244
+ "ResearchRun",
245
+ "ResearchRunDetail",
246
+ "ResearchPlan",
247
+ "ResearchSubquestion",
248
+ "ResearchEvidence",
249
+ "ResearchClaim",
250
+ "ResearchRunAsyncResponse",
251
+ "ResearchListResponse",
252
+ "ResearchCancelResponse",
253
+ "ResearchEvent",
254
+ "ResearchCreatedEvent",
255
+ "ResearchFinalResultEvent",
256
+ "ResearchErrorEvent",
257
+ "ResearchDoneEvent",
258
+ "ResearchStreamEvent",
259
+ "ResearchProgressEventName",
151
260
  # Search types
152
261
  "SearchResult",
153
262
  "SearchQueryResponse",
@@ -17,6 +17,7 @@ from ..exceptions import (
17
17
  ConflictError,
18
18
  InternalServerError,
19
19
  NotFoundError,
20
+ PaymentRequiredError,
20
21
  PermissionDeniedError,
21
22
  RateLimitError,
22
23
  RequestTimeoutError,
@@ -26,7 +27,7 @@ from ..exceptions import (
26
27
  ResponseT = TypeVar("ResponseT", bound=BaseModel)
27
28
 
28
29
  # 600 s = 10 min — matches the platform's own run timeout
29
- # (frontend/app/v1/lib/one-off-run.ts: RUN_TIMEOUT_MS = 60_000 * 10)
30
+ # (frontend/app/v1/lib/runs/one-off-run.ts: RUN_TIMEOUT_MS = 60_000 * 10)
30
31
  _DEFAULT_TIMEOUT: float = 600.0
31
32
  _DEFAULT_MAX_RETRIES: int = 2
32
33
  _RETRY_MULTIPLIER: float = 0.5
@@ -129,10 +130,10 @@ class _BaseClient:
129
130
  return headers
130
131
 
131
132
  @staticmethod
132
- def _inject_integration(json: dict[str, Any] | None) -> dict[str, Any] | None:
133
- """Inject api_integration from TF_API_INTEGRATION env var into JSON body."""
134
- if json is None:
135
- return None
133
+ def _inject_integration(path: str, json: dict[str, Any] | None) -> dict[str, Any] | None:
134
+ """Only agent runs accept api_integration; other routes reject unknown fields."""
135
+ if json is None or not path.startswith("/v1/automation/"):
136
+ return json
136
137
  integration = os.environ.get("TF_API_INTEGRATION", "").strip()
137
138
  if integration:
138
139
  json["api_integration"] = integration
@@ -151,6 +152,7 @@ class _BaseClient:
151
152
  error_map: dict[int, type[APIStatusError]] = {
152
153
  int(httpx.codes.BAD_REQUEST): BadRequestError,
153
154
  int(httpx.codes.UNAUTHORIZED): AuthenticationError,
155
+ int(httpx.codes.PAYMENT_REQUIRED): PaymentRequiredError,
154
156
  int(httpx.codes.FORBIDDEN): PermissionDeniedError,
155
157
  int(httpx.codes.NOT_FOUND): NotFoundError,
156
158
  int(httpx.codes.REQUEST_TIMEOUT): RequestTimeoutError,
@@ -166,14 +168,20 @@ class _BaseClient:
166
168
 
167
169
  # Try to parse the message and machine-readable code from the JSON error body.
168
170
  code: str | None = None
171
+ wallet_url: str | None = None
169
172
  try:
170
173
  error_data = response.json().get("error", {})
171
174
  message = error_data.get("message", response.text)
172
175
  raw_code = error_data.get("code")
173
176
  code = raw_code if isinstance(raw_code, str) else None
177
+ details = error_data.get("details")
178
+ raw_wallet_url = details.get("wallet_url") if isinstance(details, dict) else None
179
+ wallet_url = raw_wallet_url if isinstance(raw_wallet_url, str) else None
174
180
  except Exception:
175
181
  message = response.text or f"HTTP {response.status_code}"
176
182
 
183
+ if error_class is PaymentRequiredError:
184
+ return PaymentRequiredError(message=message, response=response, code=code, wallet_url=wallet_url)
177
185
  if error_class is APIStatusError:
178
186
  # Fallback: no concrete subclass matched, so pass the raw status code.
179
187
  return error_class(message=message, response=response, status_code=response.status_code, code=code)