Skip to main content

Overview

Functions allow you to deploy your automations as edge functions, allowing you to run them on the edge of your network.
Notte Functions are serverless Python functions that host your web automations and can be triggered by an API endpoint.

Notte Function Management

Define your function handler as a regular python function.
my_scraping_function.py
from notte_sdk import NotteClient

notte = NotteClient()
# define your function variables as arguments
def run(url: str):
    with notte.Session() as session:
        session.execute(type="goto", url=url)
        return session.scrape()
Each handler function must be named run.
You can create, update and run deployed functions:
deploy_function.py
from notte_sdk import NotteClient
from pathlib import Path

code = """
from notte_sdk import NotteClient

notte = NotteClient()
# define your function variables as arguments
def run(url: str):
    with notte.Session() as session:
        session.execute(type="goto", url=url)
        return session.scrape()
"""

# create a local python file with your function code
with Path("my_scraping_function.py").open("w") as f:
    f.write(code)

notte = NotteClient()

# Use your local python file to deploy a new function
function = notte.Function(
    path="my_scraping_function.py",
    name="My Scraping Flow",
    description="A flow for scraping the web"
)
print(f"Function created with ID: {function.response.function_id}. You can reference it using `notte.Function(<function_id>)`")
Additionally, you can fork a public function into your own private function.
fork_function.py
from notte_sdk import NotteClient

notte = NotteClient()

function = notte.Function("<any-public-function-id>")
# creates a private copy of the function (only works for public functions)
function = function.fork()

Key points

  • You can deploy functions directly from a Python file.
  • Functions can be executed with custom variables
  • Each function can be triggered by an event or a schedule.
  • List all functions using notte.functions.list().