Overview

Sessions are the heart of our ecosystem. They maintain browser states and provide a reliable foundation for executing web-based operations. Every operation in the Notte ecosystem is performed on behalf of a session (agent, scrape, vault, etc.)

Session Management

This shows how to manage your browser sessions using the Notte Python SDK

from notte_sdk import NotteClient

notte = NotteClient()

# The session is automatically stopped when the context manager is exited
with notte.Session(timeout_minutes=2) as session:
	status = session.status()
	print(status)

We strongly recommend using the API using a with statement to manage the session lifecycle and ensure it is stopped when the context manager is exited.

Key points

  • Timeouts: Use the timeout_minutes parameter to specify when a session should be stopped if no actions are performed on it (no activity). Note that by default, sessions are stopped after 3 minutes of inactivity.
  • Session IDs: Each session is uniquely identified, e.g. 5767be3c-aef5-47f8-bcb0-4f9f80fa66a3 and is tied to an API Key.
  • The agent/start endpoint takes an optional session_id parameter. If not provided, sessions are automatically created at the start of the request and closed when the agent run is completed.

Session Features

For more information on the additional features that are available for sessions, see the following guides:

Operations

Operations provide granular control on the browser session:

  • observe() To get the current state of a page and its available actions
  • step() To take an action you’ve previously observed on a page
  • scrape() To extract structured data from a page
from notte_sdk import NotteClient

with NotteClient().Session() as page:
    url="https://www.linkedin.com/"

    # observe page and take a step
    obs = page.observe(url=url, instructions="click 'jobs'")
    res = page.step(action=obs.space.first())
    print(res.message)

    # another one 
    obs = page.observe(instructions="dismiss the sign in check")
    res = page.step(action=obs.space.first())
    print(res.message)