From 1d1dc076d5f9f10da363c973cf9e9a404a1248d4 Mon Sep 17 00:00:00 2001 From: nikhil Date: Thu, 19 Nov 2026 14:22:25 -0800 Subject: [PATCH 1/2] Add statusCode and finalUrl to fetch results The API now returns the HTTP status of the fetched page and the URL it ended on after redirects, for fetch, batch fetch and web crawl. Add both as optional fields on FetchResponseData and PageData so callers can tell an error or block page from real content without casting. Bump version to 1.5.6. Co-Authored-By: Claude Fable 5.2 --- package.json | 2 +- src/types/web/common.ts | 10 ++++++++++ src/types/web/fetch.ts | 10 ++++++++++ tests/unit/public-types-contract.test.ts | 19 +++++++++++++++++++ 4 files changed, 40 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index d3733ac..93ab44d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@hyperbrowser/sdk", - "version": "1.5.5", + "version": "1.5.6", "description": "Node SDK for Hyperbrowser API", "author": "", "repository": { diff --git a/src/types/web/common.ts b/src/types/web/common.ts index b7bbe20..b0f58be 100644 --- a/src/types/web/common.ts +++ b/src/types/web/common.ts @@ -32,6 +32,16 @@ export interface PageData { status: PageStatus; error?: string; metadata?: Record; + /** + * HTTP status of the page the content came from. Absent when the browser + * received no response, and on results cached before this field existed. + */ + statusCode?: number; + /** + * URL the page ended on after redirects. For a document such as a PDF, the + * URL of the downloaded file. + */ + finalUrl?: string; markdown?: string; html?: string; links?: string[]; diff --git a/src/types/web/fetch.ts b/src/types/web/fetch.ts index ae0573b..e5d03ab 100644 --- a/src/types/web/fetch.ts +++ b/src/types/web/fetch.ts @@ -20,6 +20,16 @@ export interface FetchParams { export interface FetchResponseData { metadata?: Record; + /** + * HTTP status of the page the content came from. Absent when the browser + * received no response, and on results cached before this field existed. + */ + statusCode?: number; + /** + * URL the page ended on after redirects. For a document such as a PDF, the + * URL of the downloaded file. + */ + finalUrl?: string; html?: string; markdown?: string; links?: string[]; diff --git a/tests/unit/public-types-contract.test.ts b/tests/unit/public-types-contract.test.ts index deb6139..b36275a 100644 --- a/tests/unit/public-types-contract.test.ts +++ b/tests/unit/public-types-contract.test.ts @@ -3,6 +3,7 @@ import type { BatchScrapeJobResponse, ClickActionParams, DragActionParams, + FetchResponseData, ScrollActionParams, ScrollAtCursorActionParams, ComputerActionParams, @@ -15,6 +16,7 @@ import type { CreateSessionProfile, GetBatchScrapeJobParams, GetWebCrawlJobParams, + PageData, Sandbox, SandboxExecParams, SandboxImageBuildInputFormat, @@ -164,6 +166,23 @@ describe("public type compatibility", () => { expectTypeOf().toEqualTypeOf(); }); + test("exposes the HTTP status and final URL of fetched pages as optional fields", () => { + const cachedBeforeTheFieldsExisted: FetchResponseData = { markdown: "# Title" }; + const blockedPage: PageData = { + url: "https://example.com/old", + status: "completed", + statusCode: 403, + finalUrl: "https://example.com/blocked", + }; + + expect(cachedBeforeTheFieldsExisted.statusCode).toBeUndefined(); + expect(blockedPage.statusCode).toBe(403); + expectTypeOf().toEqualTypeOf(); + expectTypeOf().toEqualTypeOf(); + expectTypeOf().toEqualTypeOf(); + expectTypeOf().toEqualTypeOf(); + }); + test("includes public server region and status values", () => { const region: SessionRegion = "us"; const status: SessionStatus = "close-error"; From 40bf79453c4912789c7654bd2d26d70b944201d0 Mon Sep 17 00:00:00 2001 From: nikhil Date: Thu, 19 Nov 2026 14:29:20 -0800 Subject: [PATCH 2/2] Drop the cached-results caveat from the fetch field comments Co-Authored-By: Claude Fable 5.2 --- src/types/web/common.ts | 2 +- src/types/web/fetch.ts | 2 +- tests/unit/public-types-contract.test.ts | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/types/web/common.ts b/src/types/web/common.ts index b0f58be..76c72ce 100644 --- a/src/types/web/common.ts +++ b/src/types/web/common.ts @@ -34,7 +34,7 @@ export interface PageData { metadata?: Record; /** * HTTP status of the page the content came from. Absent when the browser - * received no response, and on results cached before this field existed. + * received no response. */ statusCode?: number; /** diff --git a/src/types/web/fetch.ts b/src/types/web/fetch.ts index e5d03ab..b3f8eaf 100644 --- a/src/types/web/fetch.ts +++ b/src/types/web/fetch.ts @@ -22,7 +22,7 @@ export interface FetchResponseData { metadata?: Record; /** * HTTP status of the page the content came from. Absent when the browser - * received no response, and on results cached before this field existed. + * received no response. */ statusCode?: number; /** diff --git a/tests/unit/public-types-contract.test.ts b/tests/unit/public-types-contract.test.ts index b36275a..d846b85 100644 --- a/tests/unit/public-types-contract.test.ts +++ b/tests/unit/public-types-contract.test.ts @@ -167,7 +167,7 @@ describe("public type compatibility", () => { }); test("exposes the HTTP status and final URL of fetched pages as optional fields", () => { - const cachedBeforeTheFieldsExisted: FetchResponseData = { markdown: "# Title" }; + const withoutStatusFields: FetchResponseData = { markdown: "# Title" }; const blockedPage: PageData = { url: "https://example.com/old", status: "completed", @@ -175,7 +175,7 @@ describe("public type compatibility", () => { finalUrl: "https://example.com/blocked", }; - expect(cachedBeforeTheFieldsExisted.statusCode).toBeUndefined(); + expect(withoutStatusFields.statusCode).toBeUndefined(); expect(blockedPage.statusCode).toBe(403); expectTypeOf().toEqualTypeOf(); expectTypeOf().toEqualTypeOf();