SDK Reference
Dive deeper into the Nfig SDK capabilities
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.
Parameter | Type | Description |
---|---|---|
apiKey | string | required. Your API key from the Nfig Portal. |
debug | boolean | optional. 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
Field | Type | Description |
---|---|---|
success | boolean | Indicates if the session was ended successfully. |
message | string | Informational 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
Parameter | Type | Description |
---|---|---|
goal | string | required. 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
Parameter | Type | Description |
---|---|---|
goal | string | required. A descriptive goal for the action to be performed. |
options | Object | optional. Additional options to customize the ask action. |
AskOptions
Property | Type | Description |
---|---|---|
schema | ZodSchema | optional. Zod schema to validate the extracted data against. |