From 03ef06ec9ab4d2992068dadf0a61a5f67de03cb9 Mon Sep 17 00:00:00 2001 From: Ricardo Batista <138892976+rbatista191@users.noreply.github.com> Date: Sat, 21 Nov 2026 20:18:41 +0100 Subject: [PATCH] feat(ENG-1220): add monitor.bing() for Bing Search (0.5.0) Add Bing Search (POST /v1/monitor/bing). The endpoint shipped in cloro-dev/backend#569 and cloro-dev/browsers#2117. - Add monitor.bing(query, country, include=...). include accepts html and aioverview. aioverview is True or {"markdown": True}. - Add BING to the task types of client.async_tasks. - Update the README (with the price), the CHANGELOG, the description and the keywords. The Unreleased CHANGELOG section becomes 0.5.0. - Add tests for the request and the BING task type. - Change the version from 0.4.0 to 0.5.0. Claude-Session: https://claude.ai/code/session_01Vi9vyg6uVJVBT2qvUFeKeq --- CHANGELOG.md | 10 +++++- README.md | 38 +++++++++++++++++--- pyproject.toml | 3 +- src/cloro/__init__.py | 4 +-- src/cloro/_client.py | 4 +-- src/cloro/_version.py | 2 +- src/cloro/resources/async_tasks.py | 4 +-- src/cloro/resources/monitor.py | 18 +++++++++- tests/test_client.py | 56 ++++++++++++++++++++++++++++++ 9 files changed, 125 insertions(+), 14 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7803497..c686350 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,15 @@ All notable changes to this project are documented here. The format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/) and the project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). -## [Unreleased] +## [0.5.0] + +### Added + +- `client.monitor.bing()` for Bing Search, `POST /v1/monitor/bing`. It accepts + `query`, `country` and `include` (`html`, and `aioverview` as `True` or + `{"markdown": True}`). The result has `organicResults` and, when requested + and Bing shows one, `aioverview`, in the same shapes as Google Search. +- The `BING` task type for `client.async_tasks`. ### Removed diff --git a/README.md b/README.md index ba61e78..c390eff 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,8 @@ # cloro Python SDK The official Python SDK for [**cloro**](https://cloro.dev), the API for Google Search -and AI answers. It gives you a Google SERP API, a Google News API, and answers from -ChatGPT, Gemini, Google AI Mode, Bing AI Mode and Google AI Overview. cloro +and AI answers. It gives you a Google SERP API, a Google News API, a Bing SERP API, +and answers from ChatGPT, Gemini, Google AI Mode, Bing AI Mode and Google AI Overview. cloro also runs an [MCP server](https://cloro.dev/docs/integrations/mcp) that exposes its monitor endpoints as tools for Claude, Codex, Cursor or your own agent. @@ -46,7 +46,7 @@ pass `api_key=`. Get a key (and 500 free credits) at ## Engines Every engine is a method on `client.monitor`. AI engines take a `prompt`; -Google Search and Google News take a `query`. +Google Search, Google News and Bing Search take a `query`. ```python client.monitor.chatgpt(prompt="...", country="US") @@ -56,6 +56,7 @@ client.monitor.bing_aimode(prompt="...", country="US") # Bing AI Mode client.monitor.google(query="best crm", country="US", pages=1) client.monitor.google_news(query="acme corp", country="US") +client.monitor.bing(query="best crm", country="US") # Bing Search ``` Pass `include={...}` to request extra formats: `markdown`, `html`, @@ -87,6 +88,34 @@ request costs 4 credits, plus 2 credits for a sync request and 2 credits when you set `state`. An async task (`BING_AIMODE`) does not have the 2-credit sync charge. `client.countries(model="bing_aimode")` gives the supported countries. +### Bing Search + +`bing()` gets the Bing results with the AI Overview. The result has +`organicResults` and, when you request it and Bing shows one, `aioverview`. +Both have the same shape as in Google Search. Set `include` to get `html` (the +results page), or `aioverview`. Set `aioverview` to `True`, or to +`{"markdown": True}` to also get the AI Overview as markdown. Bing Search has no +`state`, `device` or `pages`. The country selects the Bing market. + +```python +res = client.monitor.bing( + query="best running shoes for flat feet", + country="US", + include={"aioverview": {"markdown": True}}, +) + +for r in res["result"]["organicResults"]: + print(r["position"], r["link"], r["title"]) +if "aioverview" in res["result"]: + print(res["result"]["aioverview"]["markdown"]) +``` + +The query can have a maximum of 3,500 characters after URL encoding. Non-Latin +scripts take more characters when encoded, so the limit for them is lower. A +request costs 3 credits, plus 2 credits for a sync request and 2 credits when +you set `aioverview`. An async task (`BING`) does not have the 2-credit sync +charge. `client.countries(model="bing")` gives the supported countries. + ## Async task queue For high-volume or long-running work, enqueue tasks and poll them to completion. @@ -134,7 +163,7 @@ client.async_tasks.status() # queued / processing counts, concurrency usage ``` Valid `task_type` values: `CHATGPT`, `GEMINI`, `AIMODE`, `BING_AIMODE`, -`GOOGLE`, `GOOGLE_NEWS`. +`GOOGLE`, `GOOGLE_NEWS`, `BING`. ## Configuration @@ -182,6 +211,7 @@ with `TaskFailedError` / `TaskTimeoutError` from the poller and client.countries() # supported countries client.countries(model="chatgpt") client.countries(model="bing_aimode") +client.countries(model="bing") client.states() # US states for location-targeted Google ``` diff --git a/pyproject.toml b/pyproject.toml index 193136e..6609544 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -5,7 +5,7 @@ build-backend = "hatchling.build" [project] name = "cloro" dynamic = ["version"] -description = "Official Python SDK for the cloro API: one API for Google Search and every AI answer engine (ChatGPT, Gemini, AI Overview, Google AI Mode, Bing AI Mode)." +description = "Official Python SDK for the cloro API: one API for Google Search, Bing Search and every AI answer engine (ChatGPT, Gemini, AI Overview, Google AI Mode, Bing AI Mode)." readme = "README.md" requires-python = ">=3.8" license = { text = "MIT" } @@ -19,6 +19,7 @@ keywords = [ "gemini", "bing", "google search", + "bing search", "web scraping", "seo", "geo", diff --git a/src/cloro/__init__.py b/src/cloro/__init__.py index 16ee7f2..9c24683 100644 --- a/src/cloro/__init__.py +++ b/src/cloro/__init__.py @@ -1,7 +1,7 @@ """cloro — the official Python SDK. -One API for Google Search and every AI answer engine (ChatGPT, Gemini, -AI Overview, Google AI Mode, Bing AI Mode). Real-time, structured JSON. +One API for Google Search, Bing Search and every AI answer engine (ChatGPT, +Gemini, AI Overview, Google AI Mode, Bing AI Mode). Real-time, structured JSON. from cloro import Cloro diff --git a/src/cloro/_client.py b/src/cloro/_client.py index 45d9a9b..51ee642 100644 --- a/src/cloro/_client.py +++ b/src/cloro/_client.py @@ -86,8 +86,8 @@ def _make_status_error(response: httpx.Response) -> APIStatusError: class Cloro: """Client for the cloro API. - One API for Google Search and every AI answer engine (ChatGPT, Gemini, - AI Overview, Google AI Mode, Bing AI Mode). Real-time, structured JSON. + One API for Google Search, Bing Search and every AI answer engine (ChatGPT, + Gemini, AI Overview, Google AI Mode, Bing AI Mode). Real-time, structured JSON. Args: api_key: Your cloro API key (``sk_live_...``). Falls back to the diff --git a/src/cloro/_version.py b/src/cloro/_version.py index 6a9beea..3d18726 100644 --- a/src/cloro/_version.py +++ b/src/cloro/_version.py @@ -1 +1 @@ -__version__ = "0.4.0" +__version__ = "0.5.0" diff --git a/src/cloro/resources/async_tasks.py b/src/cloro/resources/async_tasks.py index 317fc81..96e5ae7 100644 --- a/src/cloro/resources/async_tasks.py +++ b/src/cloro/resources/async_tasks.py @@ -88,9 +88,9 @@ def create( Args: task_type: One of ``CHATGPT``, ``GEMINI``, ``AIMODE``, ``BING_AIMODE``, - ``GOOGLE``, ``GOOGLE_NEWS``. + ``GOOGLE``, ``GOOGLE_NEWS``, ``BING``. payload: Provider-specific body (e.g. ``{"prompt": ..., "country": ...}``, - or ``{"query": ..., "country": ...}`` for Google Search). + or ``{"query": ..., "country": ...}`` for Google Search and Bing Search). priority: 1-10, higher runs first (default 1). idempotency_key: Unique string to dedupe task creation. webhook: ``{"url": ...}`` to be notified on completion. diff --git a/src/cloro/resources/monitor.py b/src/cloro/resources/monitor.py index 4eac144..756401c 100644 --- a/src/cloro/resources/monitor.py +++ b/src/cloro/resources/monitor.py @@ -1,4 +1,4 @@ -"""Synchronous monitor endpoints — one call per AI engine or Google Search.""" +"""Synchronous monitor endpoints — one call per AI engine, Google Search or Bing Search.""" from __future__ import annotations from typing import TYPE_CHECKING, Any, Dict, Optional @@ -108,3 +108,19 @@ def google_news( "/v1/monitor/google/news", {"query": query, "country": country, "include": include, **extra}, ) + + # -- Bing Search (query-based) -------------------------------------- + + def bing( + self, query: str, country: str, *, include: Optional[Dict[str, Any]] = None, **extra: Any + ) -> Any: + """Monitor Bing Search (SERP). ``POST /v1/monitor/bing``. + + The query can have a maximum of 3,500 characters after URL encoding. + The country selects the Bing market. ``include`` accepts ``html`` and + ``aioverview``. ``aioverview`` is ``True`` or ``{"markdown": True}``. + """ + return self._run( + "/v1/monitor/bing", + {"query": query, "country": country, "include": include, **extra}, + ) diff --git a/tests/test_client.py b/tests/test_client.py index 41e347a..17607ce 100644 --- a/tests/test_client.py +++ b/tests/test_client.py @@ -152,6 +152,62 @@ def handler(request: httpx.Request) -> httpx.Response: assert seen["url"] == "https://api.cloro.dev/v1/countries?model=bing_aimode" +def test_monitor_bing_request_and_response(): + seen = {} + + def handler(request: httpx.Request) -> httpx.Response: + seen["url"] = str(request.url) + seen["body"] = json.loads(request.content) + return httpx.Response( + 200, + json={ + "success": True, + "result": { + "organicResults": [ + {"position": 1, "title": "A", "link": "https://a.example", + "displayedLink": "a.example", "snippet": "s", "page": 1} + ], + "aioverview": {"text": "hi", "sources": [], "markdown": "hi"}, + }, + }, + ) + + client = make_client(handler) + res = client.monitor.bing( + query="best crm", country="US", include={"html": True, "aioverview": {"markdown": True}} + ) + + assert seen["url"] == "https://api.cloro.dev/v1/monitor/bing" + assert seen["body"] == { + "query": "best crm", + "country": "US", + "include": {"html": True, "aioverview": {"markdown": True}}, + } + assert res["result"]["organicResults"][0]["link"] == "https://a.example" + assert res["result"]["aioverview"]["markdown"] == "hi" + + +def test_async_create_bing_task(): + seen = {} + + def handler(request: httpx.Request) -> httpx.Response: + seen["body"] = json.loads(request.content) + return httpx.Response( + 200, + json={ + "success": True, + "task": {"id": "t-3", "taskType": "BING", "status": "QUEUED", + "priority": 1, "createdAt": "2026-11-21T12:00:00.000Z"}, + "credits": {"creditsToCharge": 3, "creditsCharged": None}, + }, + ) + + client = make_client(handler) + task = client.async_tasks.create(task_type="BING", payload={"query": "x", "country": "US"}) + assert seen["body"] == {"taskType": "BING", "payload": {"query": "x", "country": "US"}} + assert task.task_type == "BING" + + def test_discontinued_engines_are_not_exposed(): client = Cloro(api_key="sk_test") assert not hasattr(client.monitor, "copilot")