TypeScript SDK Reference (v0.7.1)
Usage reference for SDK endpoints and methods (v0.7.1)
You can get started with a full TypeScript example here.
Client: Get Session Status
Method client.getSessionStatus
| API Endpoint
Description
This method retrieves the status of a session associated with a specified account.
Usage
Client: Delete Session
Method client.deleteSession
| API Endpoint
Description
This method deletes a session associated with a specified account.
Usage
Execute Runtime Script
Function executeRuntimeScript
Description
Executes a runtime script within a browser context.
This function runs given Playwright scripts within a specified page or browser context. The page or browser context is supported with Anon’s session cookies and proxies. It ensures the setup and cleanup of browser resources after the script execution.
Usage
Setup Anon Browser With Context
Function setupAnonBrowserWithContext
Description
This function initializes a browser and its context, configured with proxy settings. The initialized browser context can be used to execute browser scripts. It supports managed (remote browser managed by Anon), remote (other remote url), and local launch options.
Usage
The third parameter is an object browserLaunchOptions
which takes a type
key with value "local" | "remote" | "managed"
and additional input parameters.
type
Options
type: "local"
Allows you to self-host Playwright sessions, on your own backend servers or developer machines.
The type for browserLaunchOptions
is { type: "local"; input: LocalBrowserLaunchInput }
.
input: LocalBrowserLaunchInput
extends Playwright’s LaunchOptions
and includes an optional proxy property:
Where:
LocalProxyConfig
allows you to specify your own proxy:
AnonProxyConfig
allows you to use Anon’s proxy or disable proxying:
By default, if the proxy
or isAnonProxyEnabled
property is omitted, then no proxies will be used.
type: "remote"
The type for browserLaunchOptions
is { type: "remote" | "self-hosted"; input: string }
.
input: string
is the remote url to connect to.
Allows you to host Playwright sessions on a remote provider, like Browserbase, or your own remote url.
type: "managed"
The type for browserLaunchOptions is { type: "managed"; input: ProxyConfig }
.
ProxyConfig has the following type:
This option allows you to configure your own proxy settings, or disable proxying.
Utilizing a managed browser runtime environment offers a user the ability to use Anon’s proxy servers, or configure their own proxy servers.
A developer can even configure their own proxy servers to the managed browser runtime environment.
Detailed Usage
Running this script will indicate your location as setupAnonBrowserWithContext
proxies your requests to nearby servers.
Initialize Anon Browser
Function initializeAnonBrowser
Description
This function is only for type: "local"
browser instances.
We recommend using setupAnonBrowserWithContext
for most use cases, since that function sets up both your browser and browser context.
Initializes an Anon browser instance based on the provided launch options. This function supports launching a local
browser, connecting to a remote
browser, or initializing a managed
browser environment hosted by Anon.
Detailed Usage
Setup Anon Browser Context
Function setupAnonBrowserContext
Description
This function is only for type: "local"
browser instances.
We recommend using setupAnonBrowserWithContext
for most use cases, since that function sets up both your browser and browser context.
Sets up a browser context with optional proxy settings and additional context options. This function initializes a new browser context within the given browser instance, configured with the provided proxy settings and context options.
contextOptions
is from Playwright’s BrowserContextOptions
.
Detailed Usage
Was this page helpful?