Skip to content

Commit de76605

Browse files
feat: [AI-1972] - Move fetch v2 handler into /v1/fetch
1 parent 97f1c02 commit de76605

4 files changed

Lines changed: 46 additions & 3 deletions

File tree

.stats.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
configured_endpoints: 21
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/browserbase/browserbase-1821faac6d1422fea15b3ba1f88c0f5f00c43464524e17d3fd1efd1ea148b7c4.yml
3-
openapi_spec_hash: 1e3fba074314f557dc6973cf97ea6a69
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/browserbase/browserbase-3032c74460ad9c1c4b0a1b2d9107c556f292974a8ce12d525660a9cf31f10bc1.yml
3+
openapi_spec_hash: 8ac1c673ce4e72b88bbbf30100b95e8f
44
config_hash: cf04ecfb8dad5fbd8b85be25d6e9ec55

src/browserbase/resources/fetch_api.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
from __future__ import annotations
44

5+
from typing import Dict
6+
from typing_extensions import Literal
7+
58
import httpx
69

710
from ..types import fetch_api_create_params
@@ -47,7 +50,9 @@ def create(
4750
url: str,
4851
allow_insecure_ssl: bool | Omit = omit,
4952
allow_redirects: bool | Omit = omit,
53+
format: Literal["raw", "json", "markdown"] | Omit = omit,
5054
proxies: bool | Omit = omit,
55+
schema: Dict[str, object] | Omit = omit,
5156
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
5257
# The extra values given here take precedence over values defined on the client or passed to this method.
5358
extra_headers: Headers | None = None,
@@ -65,8 +70,15 @@ def create(
6570
6671
allow_redirects: Whether to follow HTTP redirects
6772
73+
format: Output format for the response content. `raw` (default) returns the response
74+
body unchanged; `json` returns structured data (requires `schema`); `markdown`
75+
returns the page as markdown.
76+
6877
proxies: Whether to enable proxy support for the request
6978
79+
schema: JSON Schema describing the desired structure of the response. Only used when
80+
`format` is `json`.
81+
7082
extra_headers: Send extra headers
7183
7284
extra_query: Add additional query parameters to the request
@@ -82,7 +94,9 @@ def create(
8294
"url": url,
8395
"allow_insecure_ssl": allow_insecure_ssl,
8496
"allow_redirects": allow_redirects,
97+
"format": format,
8598
"proxies": proxies,
99+
"schema": schema,
86100
},
87101
fetch_api_create_params.FetchAPICreateParams,
88102
),
@@ -119,7 +133,9 @@ async def create(
119133
url: str,
120134
allow_insecure_ssl: bool | Omit = omit,
121135
allow_redirects: bool | Omit = omit,
136+
format: Literal["raw", "json", "markdown"] | Omit = omit,
122137
proxies: bool | Omit = omit,
138+
schema: Dict[str, object] | Omit = omit,
123139
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
124140
# The extra values given here take precedence over values defined on the client or passed to this method.
125141
extra_headers: Headers | None = None,
@@ -137,8 +153,15 @@ async def create(
137153
138154
allow_redirects: Whether to follow HTTP redirects
139155
156+
format: Output format for the response content. `raw` (default) returns the response
157+
body unchanged; `json` returns structured data (requires `schema`); `markdown`
158+
returns the page as markdown.
159+
140160
proxies: Whether to enable proxy support for the request
141161
162+
schema: JSON Schema describing the desired structure of the response. Only used when
163+
`format` is `json`.
164+
142165
extra_headers: Send extra headers
143166
144167
extra_query: Add additional query parameters to the request
@@ -154,7 +177,9 @@ async def create(
154177
"url": url,
155178
"allow_insecure_ssl": allow_insecure_ssl,
156179
"allow_redirects": allow_redirects,
180+
"format": format,
157181
"proxies": proxies,
182+
"schema": schema,
158183
},
159184
fetch_api_create_params.FetchAPICreateParams,
160185
),

src/browserbase/types/fetch_api_create_params.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22

33
from __future__ import annotations
44

5-
from typing_extensions import Required, Annotated, TypedDict
5+
from typing import Dict
6+
from typing_extensions import Literal, Required, Annotated, TypedDict
67

78
from .._utils import PropertyInfo
89

@@ -19,5 +20,18 @@ class FetchAPICreateParams(TypedDict, total=False):
1920
allow_redirects: Annotated[bool, PropertyInfo(alias="allowRedirects")]
2021
"""Whether to follow HTTP redirects"""
2122

23+
format: Literal["raw", "json", "markdown"]
24+
"""Output format for the response content.
25+
26+
`raw` (default) returns the response body unchanged; `json` returns structured
27+
data (requires `schema`); `markdown` returns the page as markdown.
28+
"""
29+
2230
proxies: bool
2331
"""Whether to enable proxy support for the request"""
32+
33+
schema: Dict[str, object]
34+
"""JSON Schema describing the desired structure of the response.
35+
36+
Only used when `format` is `json`.
37+
"""

tests/api_resources/test_fetch_api.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,9 @@ def test_method_create_with_all_params(self, client: Browserbase) -> None:
3030
url="https://example.com",
3131
allow_insecure_ssl=True,
3232
allow_redirects=True,
33+
format="raw",
3334
proxies=True,
35+
schema={"foo": "bar"},
3436
)
3537
assert_matches_type(FetchAPICreateResponse, fetch_api, path=["response"])
3638

@@ -77,7 +79,9 @@ async def test_method_create_with_all_params(self, async_client: AsyncBrowserbas
7779
url="https://example.com",
7880
allow_insecure_ssl=True,
7981
allow_redirects=True,
82+
format="raw",
8083
proxies=True,
84+
schema={"foo": "bar"},
8185
)
8286
assert_matches_type(FetchAPICreateResponse, fetch_api, path=["response"])
8387

0 commit comments

Comments
 (0)