API: extraction/apiIntercept

better-web-search-mcp


better-web-search-mcp / extraction/apiIntercept

extraction/apiIntercept#

Interfaces#

ApiPatternRow#

Defined in: src/extraction/apiIntercept.ts:145

An api_patterns table row (without the auto-increment id/timestamp).

Properties#

PropertyTypeDefined in
content_typestringsrc/extraction/apiIntercept.ts:149
domainstringsrc/extraction/apiIntercept.ts:146
endpoint_patternstringsrc/extraction/apiIntercept.ts:147
methodstringsrc/extraction/apiIntercept.ts:148

ApiResponse#

Defined in: src/extraction/apiIntercept.ts:30

The minimal Playwright Response surface this module depends on.

Methods#

headers()#

headers(): Record<string, string>

Defined in: src/extraction/apiIntercept.ts:33

Returns#

Record<string, string>

json()#

json(): Promise<unknown>

Defined in: src/extraction/apiIntercept.ts:34

Returns#

Promise<unknown>

request()#

request(): { method: string; }

Defined in: src/extraction/apiIntercept.ts:32

Returns#

{ method: string; }

NameTypeDefined in
method()() => stringsrc/extraction/apiIntercept.ts:32
url()#

url(): string

Defined in: src/extraction/apiIntercept.ts:31

Returns#

string


CapturedApiResponse#

Defined in: src/extraction/apiIntercept.ts:12

A single captured JSON API response.

Properties#

PropertyTypeDescriptionDefined in
contentTypestringThe response content-type (e.g. application/json).src/extraction/apiIntercept.ts:18
dataunknownThe parsed JSON body.src/extraction/apiIntercept.ts:20
methodstringThe HTTP method used to request it.src/extraction/apiIntercept.ts:16
urlstringThe absolute URL of the API endpoint.src/extraction/apiIntercept.ts:14

CapturedApiResponses#

Defined in: src/extraction/apiIntercept.ts:98

A handle over the responses captured by installApiCapture.

Properties#

PropertyModifierTypeDescriptionDefined in
capturedreadonlyreadonly CapturedApiResponse[]The responses captured so far, in arrival order.src/extraction/apiIntercept.ts:100

Methods#

remove()#

remove(): void

Defined in: src/extraction/apiIntercept.ts:102

Detach the capture listener from the page.

Returns#

void


CapturePage#

Defined in: src/extraction/apiIntercept.ts:24

The minimal Playwright Page surface this module depends on.

Methods#

off()#

off(event, listener): unknown

Defined in: src/extraction/apiIntercept.ts:26

Parameters#
ParameterType
event"response"
listener(response) => void
Returns#

unknown

on()#

on(event, listener): unknown

Defined in: src/extraction/apiIntercept.ts:25

Parameters#
ParameterType
event"response"
listener(response) => void
Returns#

unknown

Functions#

discoverApiPatterns()#

discoverApiPatterns(domain, captured): ApiPatternRow[]

Defined in: src/extraction/apiIntercept.ts:113

Normalize a captured API URL into an api_patterns row.

The endpoint pattern replaces numeric path segments with * so that /api/products/123 becomes /api/products/*. The domain is the URL’s hostname. content_type is normalized to the bare media type (e.g. application/json).

Parameters#

ParameterType
domainstring
capturedreadonly CapturedApiResponse[]

Returns#

ApiPatternRow[]


installApiCapture()#

installApiCapture(page): CapturedApiResponses

Defined in: src/extraction/apiIntercept.ts:63

Install a JSON API capture listener on a page.

Registers a response handler that, for every response whose content-type is application/json, reads the body and appends {url, method, contentType, data} to the returned array. The listener is removed when CapturedApiResponses.remove is called, so a page can be reused without leaking handlers.

Parameters#

ParameterTypeDescription
pageCapturePageThe Playwright page to observe.

Returns#

CapturedApiResponses

A handle exposing the captured responses and a remove() that detaches the listener.