Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -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" }
Expand Down
2 changes: 1 addition & 1 deletion src/scrapebadger/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1356,7 +1356,7 @@ async def main():
ZestimateHistoryPoint as ZillowZestimateHistoryPoint,
)

__version__ = "0.80.0"
__version__ = "0.81.0"

__all__ = [
# TikTok core models
Expand Down
2 changes: 1 addition & 1 deletion src/scrapebadger/_internal/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}"


Expand Down
12 changes: 12 additions & 0 deletions src/scrapebadger/perplexity/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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(
Expand Down
4 changes: 3 additions & 1 deletion tests/test_async_requests.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
16 changes: 16 additions & 0 deletions tests/test_perplexity.py
Original file line number Diff line number Diff line change
Expand Up @@ -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},
)
2 changes: 1 addition & 1 deletion uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading