models.py•13.4 kB
# generated by fastapi-codegen:
# filename: openapi.yaml
# timestamp: 2025-07-07T17:24:58+00:00
from __future__ import annotations
from datetime import datetime
from enum import Enum
from typing import Any, Dict, List, Optional
from pydantic import AnyUrl, BaseModel, Field, RootModel, conint, constr
class In(Enum):
header = 'header'
class Name(Enum):
X_BB_API_Key = 'X-BB-API-Key'
class Type(Enum):
apiKey = 'apiKey'
class BrowserbaseAuth(BaseModel):
in_: In = Field(..., alias='in', description='location of the API key')
name: Name = Field(..., description='name of the API key')
type: Type = Field(..., description='API key authentication')
class Type1(Enum):
browserbase = 'browserbase'
class CreateSessionConnectDetails(BaseModel):
connectUrl: AnyUrl = Field(
..., description='WebSocket URL to connect to the Session.'
)
seleniumRemoteUrl: AnyUrl = Field(
..., description='HTTP URL to connect to the Session.'
)
signingKey: str = Field(
..., description='Signing key to use when connecting to the Session via HTTP.'
)
class Error(BaseModel):
code: int
message: str
class Type2(Enum):
external = 'external'
class ExternalProxyConfig(BaseModel):
domainPattern: Optional[str] = Field(
None,
description='Domain pattern for which this proxy should be used. If omitted, defaults to all domains. Optional.',
)
password: Optional[str] = Field(
None, description='Password for external proxy authentication. Optional.'
)
server: str = Field(..., description='Server URL for external proxy. Required.')
type: Type2 = Field(
..., description="Type of proxy. Always 'external' for this config."
)
username: Optional[str] = Field(
None, description='Username for external proxy authentication. Optional.'
)
class Browser(Enum):
chrome = 'chrome'
edge = 'edge'
firefox = 'firefox'
safari = 'safari'
class Device(Enum):
desktop = 'desktop'
mobile = 'mobile'
class HttpVersion(Enum):
number_1 = 1
number_2 = 2
class OperatingSystem(Enum):
android = 'android'
ios = 'ios'
linux = 'linux'
macos = 'macos'
windows = 'windows'
class FingerprintScreen(BaseModel):
maxHeight: Optional[int] = None
maxWidth: Optional[int] = None
minHeight: Optional[int] = None
minWidth: Optional[int] = None
class GeolocationConfig(BaseModel):
city: Optional[str] = Field(
None,
description='Name of the city. Use spaces for multi-word city names. Optional.',
)
country: constr(min_length=2, max_length=2) = Field(
..., description='Country code in ISO 3166-1 alpha-2 format'
)
state: Optional[constr(min_length=2, max_length=2)] = Field(
None,
description='US state code (2 characters). Must also specify US as the country. Optional.',
)
class ProjectUsage(BaseModel):
browserMinutes: conint(ge=0)
proxyBytes: conint(ge=0)
class Region(Enum):
us_west_2 = 'us-west-2'
us_east_1 = 'us-east-1'
eu_central_1 = 'eu-central-1'
ap_southeast_1 = 'ap-southeast-1'
class SessionBrowserSettingsViewport(BaseModel):
height: Optional[int] = None
width: Optional[int] = None
class Page(BaseModel):
debuggerFullscreenUrl: AnyUrl
debuggerUrl: AnyUrl
faviconUrl: AnyUrl
id: str
title: str
url: AnyUrl
class SessionLiveUrls(BaseModel):
debuggerFullscreenUrl: AnyUrl
debuggerUrl: AnyUrl
pages: List[Page]
wsUrl: AnyUrl
class SessionLogRequestBody(BaseModel):
params: Dict[str, Any]
rawBody: str
timestamp: int = Field(
..., description='milliseconds that have elapsed since the UNIX epoch'
)
class SessionLogResponseBody(BaseModel):
rawBody: str
result: Dict[str, Any]
timestamp: int = Field(
..., description='milliseconds that have elapsed since the UNIX epoch'
)
class SessionRecording(BaseModel):
data: Dict[str, Any] = Field(
...,
description='See [rrweb documentation](https://github.com/rrweb-io/rrweb/blob/master/docs/recipes/dive-into-event.md).',
)
id: str
sessionId: str
timestamp: int = Field(
..., description='milliseconds that have elapsed since the UNIX epoch'
)
type: int
class SessionStatus(Enum):
RUNNING = 'RUNNING'
ERROR = 'ERROR'
TIMED_OUT = 'TIMED_OUT'
COMPLETED = 'COMPLETED'
class Status(Enum):
REQUEST_RELEASE = 'REQUEST_RELEASE'
class Versions(Enum):
v1 = 'v1'
class Uuid(RootModel[str]):
root: str
class V1ExtensionsPostRequest(BaseModel):
file: bytes
class V1SessionsPostResponse(BaseModel):
avgCpuUsage: Optional[int] = Field(None, description='CPU used by the Session')
connectUrl: AnyUrl = Field(
..., description='WebSocket URL to connect to the Session.'
)
contextId: Optional[Uuid] = Field(
None, description='Optional. The Context linked to the Session.'
)
createdAt: datetime
endedAt: Optional[datetime] = None
expiresAt: datetime
id: Uuid
keepAlive: bool = Field(
...,
description='Indicates if the Session was created to be kept alive upon disconnections',
)
memoryUsage: Optional[int] = Field(None, description='Memory used by the Session')
projectId: Uuid = Field(..., description='The Project ID linked to the Session.')
proxyBytes: int = Field(
...,
description='Bytes used via the [Proxy](/features/stealth-mode#proxies-and-residential-ips)',
)
region: Region = Field(..., description='The region where the Session is running.')
seleniumRemoteUrl: AnyUrl = Field(
..., description='HTTP URL to connect to the Session.'
)
signingKey: str = Field(
..., description='Signing key to use when connecting to the Session via HTTP.'
)
startedAt: datetime
status: SessionStatus
updatedAt: datetime
class V1SessionsIdRecordingGetResponse(RootModel[List[SessionRecording]]):
root: List[SessionRecording]
class V1SessionsIdUploadsPostRequest(BaseModel):
file: bytes
class V1SessionsIdUploadsPostResponse(BaseModel):
message: str
class BrowserbaseProxyConfig(BaseModel):
domainPattern: Optional[str] = Field(
None,
description='Domain pattern for which this proxy should be used. If omitted, defaults to all domains. Optional.',
)
geolocation: Optional[GeolocationConfig] = Field(
None, description='Geographic location for the proxy. Optional.'
)
type: Type1 = Field(
...,
description="Type of proxy. Always use 'browserbase' for the Browserbase managed proxy network.",
)
class Context(BaseModel):
createdAt: datetime
id: Uuid
projectId: Uuid = Field(
..., description='The Project ID linked to the uploaded Context.'
)
updatedAt: datetime
class ContextSetting(BaseModel):
id: Uuid = Field(..., description='The Context ID.')
persist: Optional[bool] = Field(
None,
description='Whether or not to persist the context after browsing. Defaults to `false`.',
)
class CreateContext(BaseModel):
projectId: Uuid = Field(
...,
description='The Project ID. Can be found in [Settings](https://www.browserbase.com/settings).',
)
class CreateContextResponse(BaseModel):
cipherAlgorithm: str = Field(
...,
description='The cipher algorithm used to encrypt the user-data-directory. AES-256-CBC is currently the only supported algorithm.',
)
id: Uuid
initializationVectorSize: int = Field(
...,
description='The initialization vector size used to encrypt the user-data-directory. [Read more about how to use it](/features/contexts).',
)
publicKey: str = Field(
..., description='The public key to encrypt the user-data-directory.'
)
uploadUrl: constr(min_length=1) = Field(
..., description='An upload URL to upload a custom user-data-directory.'
)
class Entity(BaseModel):
createdAt: datetime
id: Uuid
updatedAt: datetime
class Extension(BaseModel):
createdAt: datetime
fileName: constr(min_length=1)
id: Uuid
projectId: Uuid = Field(
..., description='The Project ID linked to the uploaded Extension.'
)
updatedAt: datetime
class Fingerprint(BaseModel):
browsers: Optional[List[Browser]] = None
devices: Optional[List[Device]] = None
httpVersion: Optional[HttpVersion] = None
locales: Optional[List[str]] = Field(
None,
description='Full list of locales is available [here](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Accept-Language).',
)
operatingSystems: Optional[List[OperatingSystem]] = Field(
None,
description='Note: `operatingSystems` set to `ios` or `android` requires `devices` to include `"mobile"`.',
)
screen: Optional[FingerprintScreen] = None
class Project(BaseModel):
createdAt: datetime
defaultTimeout: conint(ge=60, le=21600)
id: Uuid
name: constr(min_length=1)
ownerId: str
updatedAt: datetime
class Session(BaseModel):
avgCpuUsage: Optional[int] = Field(None, description='CPU used by the Session')
contextId: Optional[Uuid] = Field(
None, description='Optional. The Context linked to the Session.'
)
createdAt: datetime
endedAt: Optional[datetime] = None
expiresAt: datetime
id: Uuid
keepAlive: bool = Field(
...,
description='Indicates if the Session was created to be kept alive upon disconnections',
)
memoryUsage: Optional[int] = Field(None, description='Memory used by the Session')
projectId: Uuid = Field(..., description='The Project ID linked to the Session.')
proxyBytes: int = Field(
...,
description='Bytes used via the [Proxy](/features/stealth-mode#proxies-and-residential-ips)',
)
region: Region = Field(..., description='The region where the Session is running.')
startedAt: datetime
status: SessionStatus
updatedAt: datetime
class SessionBrowserSettings(BaseModel):
blockAds: Optional[bool] = Field(
None,
description='Enable or disable ad blocking in the browser. Defaults to `false`.',
)
context: Optional[ContextSetting] = None
extensionId: Optional[Uuid] = Field(
None,
description='The uploaded Extension ID. See [Upload Extension](/reference/api/upload-an-extension).',
)
fingerprint: Optional[Fingerprint] = Field(
None,
description='See usage examples [in the Stealth Mode page](/features/stealth-mode#fingerprinting).',
)
logSession: Optional[bool] = Field(
None, description='Enable or disable session logging. Defaults to `true`.'
)
recordSession: Optional[bool] = Field(
None, description='Enable or disable session recording. Defaults to `true`.'
)
solveCaptchas: Optional[bool] = Field(
None,
description='Enable or disable captcha solving in the browser. Defaults to `true`.',
)
viewport: Optional[SessionBrowserSettingsViewport] = None
class SessionLog(BaseModel):
eventId: str
frameId: Optional[str] = None
loaderId: Optional[str] = None
method: str
pageId: int
request: Optional[SessionLogRequestBody] = None
response: Optional[SessionLogResponseBody] = None
sessionId: str
timestamp: int = Field(
..., description='milliseconds that have elapsed since the UNIX epoch'
)
class SessionUpdate(BaseModel):
projectId: Uuid = Field(
...,
description='The Project ID. Can be found in [Settings](https://www.browserbase.com/settings).',
)
status: Status = Field(
...,
description="Set to `REQUEST_RELEASE` to request that the session complete. Use before session's timeout to avoid additional charges.",
)
class V1ProjectsGetResponse(RootModel[List[Project]]):
root: List[Project]
class V1SessionsGetResponse(RootModel[List[Session]]):
root: List[Session]
class V1SessionsIdLogsGetResponse(RootModel[List[SessionLog]]):
root: List[SessionLog]
class CreateSession(BaseModel):
browserSettings: Optional[SessionBrowserSettings] = None
extensionId: Optional[Uuid] = Field(
None,
description='The uploaded Extension ID. See [Upload Extension](/reference/api/upload-an-extension).',
)
keepAlive: Optional[bool] = Field(
None,
description='Set to true to keep the session alive even after disconnections. This is available on the Startup plan only.',
)
projectId: Uuid = Field(
...,
description='The Project ID. Can be found in [Settings](https://www.browserbase.com/settings).',
)
proxies: Optional[Any] = Field(
None,
description='Proxy configuration. Can be true for default proxy, or an array of proxy configurations.',
)
region: Optional[Region] = Field(
None, description='The region where the Session should run.'
)
timeout: Optional[conint(ge=60, le=21600)] = Field(
None,
description="Duration in seconds after which the session will automatically end. Defaults to the Project's `defaultTimeout`.",
)