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 enable debug mode to assist with troubleshooting.


ParameterTypeDescription
apiKeystringrequired. Your API key from the Nfig Portal.
debugbooleanoptional. Enables debug logging if set to true.

Session Management

Note: A managed session in Nfig is active for 15 minutes.


Creating a session

Use the createSession method to initialize a session.

Usage Example:


Ending a Session

Use the endSession method to end 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.

SDK Methods

Act method

act method performs specific actions on a webpage.

Basic usage


Parameters

ParameterTypeDescription
goalstringrequired. A descriptive goal for the action to be performed.

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
schemaZodSchemaoptional. Zod schema to validate the extracted data against.