diff --git a/CHANGELOG.md b/CHANGELOG.md index 786a039..3994d10 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,12 @@ # Changelog +## [0.81.0] - 2026-11-18 + +### Added +- `perplexity.ask_perplexity_a_question(..., html=True)` adds `answer_html`: the answer rendered as an HTML fragment, each `[n]` citation linked to its source. +- `perplexity.ask_perplexity_a_question(..., raw=True)` adds `raw`: Perplexity's own final answer object as it sent it. +- Both are sent only when True, so existing calls are unchanged. The POST form takes `"html": true` / `"raw": true` in the payload. + ## [0.80.0] - 2026-11-18 - **Async requests and webhooks.** Run any slow call asynchronously and get the result by polling or by a signed webhook. Submitting and polling are free; the call is billed once, when it completes. (SCR-652) diff --git a/pyproject.toml b/pyproject.toml index d7b0117..bc05018 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "scrapebadger" -version = "0.80.0" +version = "0.81.0" description = "Official Python SDK for ScrapeBadger - Async web scraping APIs for Twitter and more" readme = "README.md" license = { text = "MIT" } diff --git a/src/scrapebadger/__init__.py b/src/scrapebadger/__init__.py index 3e2116d..d649102 100644 --- a/src/scrapebadger/__init__.py +++ b/src/scrapebadger/__init__.py @@ -1356,7 +1356,7 @@ async def main(): ZestimateHistoryPoint as ZillowZestimateHistoryPoint, ) -__version__ = "0.80.0" +__version__ = "0.81.0" __all__ = [ # TikTok core models diff --git a/src/scrapebadger/_internal/client.py b/src/scrapebadger/_internal/client.py index 3258932..8484e08 100644 --- a/src/scrapebadger/_internal/client.py +++ b/src/scrapebadger/_internal/client.py @@ -56,7 +56,7 @@ T = TypeVar("T") # User agent for SDK requests -SDK_VERSION = "0.80.0" +SDK_VERSION = "0.81.0" USER_AGENT = f"scrapebadger-python/{SDK_VERSION}" diff --git a/src/scrapebadger/perplexity/client.py b/src/scrapebadger/perplexity/client.py index 748351c..c75a9d1 100644 --- a/src/scrapebadger/perplexity/client.py +++ b/src/scrapebadger/perplexity/client.py @@ -21,10 +21,18 @@ async def ask_perplexity_a_question( country: str | None = None, strict_country: bool = False, location: str | None = None, + html: bool = False, + raw: bool = False, ) -> dict[str, Any]: """Ask Perplexity a question. Generated from the OpenAPI spec; returns the raw response dict. + + Args: + html: Also return ``answer_html``, the answer rendered as an HTML fragment with + each ``[n]`` citation linked to its source. Sent only when True. + raw: Also return ``raw``, Perplexity's own final answer object as it sent it. + Sent only when True. """ params = { k: v @@ -36,6 +44,10 @@ async def ask_perplexity_a_question( }.items() if v is not None } + if html: + params["html"] = True + if raw: + params["raw"] = True return await self._client.get("/v1/perplexity/ask", params=params) async def ask_perplexity_a_question_post( diff --git a/tests/test_async_requests.py b/tests/test_async_requests.py index 9565dad..161b07f 100644 --- a/tests/test_async_requests.py +++ b/tests/test_async_requests.py @@ -629,4 +629,6 @@ def test_public_exports() -> None: "webhooks", ): assert name in scrapebadger.__all__ - assert scrapebadger.__version__ == "0.80.0" + from scrapebadger._internal.client import SDK_VERSION + + assert scrapebadger.__version__ == SDK_VERSION diff --git a/tests/test_perplexity.py b/tests/test_perplexity.py index 636b2ce..7b48774 100644 --- a/tests/test_perplexity.py +++ b/tests/test_perplexity.py @@ -100,3 +100,19 @@ async def test_brand_visibility_location(perplexity: PerplexityClient, base: Mag base.get.reset_mock() await perplexity.measure_a_brand_s_visibility_in_a_perplexity_answer(prompt="q", brand="Nike") assert "location" not in base.get.await_args.kwargs["params"] + + +async def test_ask_omits_html_and_raw_by_default( + perplexity: PerplexityClient, base: MagicMock +) -> None: + await perplexity.ask_perplexity_a_question(prompt="q") + params = base.get.await_args.kwargs["params"] + assert "html" not in params and "raw" not in params + + +async def test_ask_sends_html_and_raw(perplexity: PerplexityClient, base: MagicMock) -> None: + await perplexity.ask_perplexity_a_question(prompt="q", html=True, raw=True) + base.get.assert_awaited_once_with( + "/v1/perplexity/ask", + params={"prompt": "q", "strict_country": False, "html": True, "raw": True}, + ) diff --git a/uv.lock b/uv.lock index 1314146..08189a2 100644 --- a/uv.lock +++ b/uv.lock @@ -930,7 +930,7 @@ wheels = [ [[package]] name = "scrapebadger" -version = "0.80.0" +version = "0.81.0" source = { editable = "." } dependencies = [ { name = "httpx" },