Initialization

To initialize the SDK,create an instance of NfigClient with your API key. This connects your application to Nfig and allows interaction with the platform. During initialization, you can also specify the preferred browser mode (LOCAL or REMOTE) and enable debug mode to assist with troubleshooting.


ParameterTypeDescription
apiKeystringrequired. Your API key from the Nfig Portal.
browserMode”LOCAL” | “REMOTE”optional. Specifies the browser mode. Defaults to REMOTE.
debugbooleanoptional. Enables debug logging if set to true.

Session Management

Note: A managed session in Nfig is active for 5 minutes in remote mode.


Creating a session

Use the createSession method to initialize a session.

REMOTE Mode: Automate actions in a remote browser environment.Returns a preview URL for live monitoring.

LOCAL Mode: Automate actions in a locally installed browser instance. Only supports Playwright for now.Allows passing the Page context initially, making it available throughout the session, or you can pass it with each method call.


Usage Example: REMOTE Mode


Usage Example: LOCAL Mode


Create Session Options

ParameterTypeDescription
currentPagePageoptional (LOCAL mode only). The Playwright Page instance to be used for the session.
proxybooleanoptional (REMOTE mode only). Enables proxy while creating session.
authOptionsAuthOptionsoptional (REMOTE mode only). Enabled authentication while creating a session.

Auth Options in CreateSession

The AuthOptions provides configuration for authentication-related settings when creating a session using the createSession method. It allows specifying the authentication app and other parameters for customizing authentication behavior.

The AuthOptions includes the following fields:

ParameterTypeDescription
authAppenumThe authentication app is to be used during the session. Must be one of the allowed auth apps.

Supported Authentications and Enums

The following table lists the standard integrations that are currently supported:

NameauthApp field enum🚧
Amazonamazon
Deltadelta
DoorDashdoordash
Facebookfacebook
Githubgithub
Instacartinstacart
Instagraminstagram
LinkedInlinkedin
Nextdoornextdoor🧪 experimental
OpenTableopentable
Twitter / Xtwitter
Resyresy
Uberuber
UberEatsuber_eats🧪 experimental
Unitedunited_airlines

Usage Example: REMOTE Mode with authentication and proxy


Ending a Session


EndSessionResponse

FieldTypeDescription
successbooleanIndicates if the session was ended successfully.
messagestringInformational message about the session termination.

Note: Ending a session is a necessary action to avoid unexpected billing.

Exporting Session Video


ExportVideoResponse

FieldTypeDescription
successbooleanIndicates if the session was ended successfully.

Note: You will an email with the link to exported video.

Prompting

LOCAL mode can only take 1 precious action at a time.
Below is an example showing an Airbnb workflow using both modes.

Usage example: LOCAL mode

Usage example: REMOTE mode

SDK Methods


Act method

act method performs specific actions on a webpage.


Basic usage


Fallback Method

In LOCAL mode, act supports fallback method to try an action manually and use agent as a fallback method.


Parameters

ParameterTypeDescription
goalstringrequired. A descriptive goal for the action to be performed.
optionsObjectoptional. Additional options to customize the action.

Options

PropertyTypeDescription
currentPagePage(playwright)optional (LOCAL mode only). The Playwright Page instance.
executebooleanoptional. If set to false, the action will not be executed locally. Defaults to true.
action”click” | “type” | “navigate” | “wait”optional. Action is supported only on LOCAL mode. If the perfoming action is failed, it will be switched to agent mode.
selectorstringoptional (For click and type action only). CSS selector of the element to type into.
iterCountnumberoptional (For click action only). Number of times to perform the click action.
inputTextstringoptional (for type action only). CSS selector of the element to type into.
enterbooleanoptional (for type action only). If set to true, simulates pressing the Enter key after typing.
urlstringoptional. URL to navigate to.
timestringoptional. Time to wait in milliseconds.

Ask method

ask method helps you retrieve information from a page in a structured way using Zod schemas.


Parameters

ParameterTypeDescription
goalstringrequired. A descriptive goal for the action to be performed.
optionsObjectoptional. Additional options to customize the ask action.

AskOptions

PropertyTypeDescription
currentPagePageoptional (LOCAL mode only). The Playwright Page instance.
schemaZodSchemaoptional. Zod schema to validate the extracted data against.
pageMode”fullPage”
or
“viewPort”
optional (LOCAL mode only).

Choose between scraping the entire page or just the visible viewport.