add resulting url
Build and Push Docker Images / build-and-push (push) Successful in 1m24s

This commit is contained in:
2026-04-29 15:47:10 +02:00
parent 6ada34a8c8
commit a93bca3c73
25 changed files with 21 additions and 4 deletions
+9 -3
View File
@@ -44,9 +44,9 @@ class Viewport(BaseModel):
class InteractionsRequest(BaseModel):
url: str = Field(..., description="Target URL (will be URL-decoded server-side).")
returnType: Optional[Literal["screenshot", "html"]] = Field(
returnType: Optional[Literal["screenshot", "html", "resulting_url"]] = Field(
"screenshot",
description="Return a PNG screenshot or HTML content.",
description="Return a PNG screenshot, HTML content, or the resulting URL after interactions.",
)
viewport: Optional[Viewport] = None
scrollX: Optional[int] = None
@@ -124,7 +124,8 @@ async def screenshot_url(url: str, fullPage: bool = True, x_api_key: Optional[st
description=(
"Run a sequence of interactions (click/type) on a page.\n\n"
"- `returnType=screenshot` returns `image/png`\n"
"- `returnType=html` returns `text/html`"
"- `returnType=html` returns `text/html`\n"
"- `returnType=resulting_url` returns `application/json` with the final URL"
),
responses={
200: {
@@ -158,6 +159,11 @@ async def run_interactions(payload: InteractionsRequest, x_api_key: Optional[str
if isinstance(result, dict) and result.get("status") == "error":
raise HTTPException(status_code=500, detail=result.get("error", "Interaction failed"))
if return_type == "resulting_url":
if not isinstance(result, dict):
raise HTTPException(status_code=500, detail="Unexpected resulting_url response")
return result
if return_type == "html":
if not isinstance(result, str):
raise HTTPException(status_code=500, detail="Unexpected HTML response")