API: extraction/apiIntercept
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#
| Property | Type | Defined in |
|---|---|---|
content_type | string | src/extraction/apiIntercept.ts:149 |
domain | string | src/extraction/apiIntercept.ts:146 |
endpoint_pattern | string | src/extraction/apiIntercept.ts:147 |
method | string | src/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; }
| Name | Type | Defined in |
|---|---|---|
method() | () => string | src/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#
| Property | Type | Description | Defined in |
|---|---|---|---|
contentType | string | The response content-type (e.g. application/json). | src/extraction/apiIntercept.ts:18 |
data | unknown | The parsed JSON body. | src/extraction/apiIntercept.ts:20 |
method | string | The HTTP method used to request it. | src/extraction/apiIntercept.ts:16 |
url | string | The 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#
| Property | Modifier | Type | Description | Defined in |
|---|---|---|---|---|
captured | readonly | readonly 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#
| Parameter | Type |
|---|---|
event | "response" |
listener | (response) => void |
Returns#
unknown
on()#
on(
event,listener):unknown
Defined in: src/extraction/apiIntercept.ts:25
Parameters#
| Parameter | Type |
|---|---|
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#
| Parameter | Type |
|---|---|
domain | string |
captured | readonly CapturedApiResponse[] |
Returns#
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#
| Parameter | Type | Description |
|---|---|---|
page | CapturePage | The Playwright page to observe. |
Returns#
A handle exposing the captured responses and a remove() that
detaches the listener.