from notte_sdk import NotteClientclient = NotteClient()# Get function by IDfunction = client.Function(function_id="func_abc123")# Access function propertiesprint(f"Function ID: {function.function_id}")print(f"Name: {function.response.name}")print(f"Description: {function.response.description}")print(f"Latest Version: {function.response.latest_version}")print(f"Versions: {function.response.versions}")
from notte_sdk import NotteClientclient = NotteClient()function = client.Function(function_id="func_abc123")# Update with new codefunction.update(path="updated_function.py")print(f"Updated to version: {function.response.latest_version}")
from notte_sdk import NotteClientclient = NotteClient()function = client.Function(function_id="func_abc123")# Get all versionsprint(f"Available versions: {function.response.versions}")# Get latest versionprint(f"Latest: {function.response.latest_version}")
from notte_sdk import NotteClientclient = NotteClient()function = client.Function(function_id="func_abc123")# Run latest version (default)result = function.run(url="https://example.com")# Run specific versionresult = function.run(url="https://example.com", version="v2")
from notte_sdk import NotteClientclient = NotteClient()# Get only active runsactive_runs = client.functions.list_runs("function_abc123", only_active=True)print(f"Active runs: {len(active_runs.items)}")for run in active_runs.items: print(f"Run {run.workflow_run_id} - {run.status}")
from notte_sdk import NotteClientclient = NotteClient()function = client.Function(function_id="func_abc123")# Run the function firstresult = function.run(url="https://example.com")# Get replay for this run (uses the session from the last run)replay = function.replay()# Download the replayreplay.download("function_replay.mp4")
from notte_sdk import NotteClientclient = NotteClient()function = client.Function(function_id="func_abc123")# Run functionresult = function.run(url="https://example.com")# Get replay for this run (automatically uses the session from the run)replay = function.replay()# Download the videoreplay.download("execution_replay.mp4")
from notte_sdk import NotteClientclient = NotteClient()# Fork a function from marketplace or teammateoriginal = client.Function(function_id="func_abc123")forked_function = original.fork()print(f"Forked function ID: {forked_function.function_id}")print("Original ID: func_abc123")
from notte_sdk import NotteClientclient = NotteClient()# Fork functionoriginal = client.Function(function_id="shared_function_id")forked = original.fork()# Update your copyforked.update(path="my_modified_version.py")# Run your versionresult = forked.run(url="https://example.com")
from notte_sdk import NotteClientclient = NotteClient()function = client.Function( function_id="func_abc123", decryption_key="your-decryption-key", # Required for downloading)# Download function codecode = function.download()print(code) # Function source code# Or download directly to a filecode = function.download(path="downloaded_function.py")
Requirements:
Decryption key (available in Console) - passed when creating Function instance
Only works for Functions you own or have access to
from notte_sdk import NotteClientclient = NotteClient()function = client.Function(function_id="func_abc123")# Before major update, download current versioncurrent_code = function.download(decryption_key="key")# Save backupwith open(f"backups/function_v{function.response.latest_version}.py", "w") as f: f.write(current_code)# Update functionfunction.update(path="new_version.py")
from notte_sdk import NotteClientdef validate_before_production(): client = NotteClient() # Test locally first - decryption key needed for local execution function = client.Function(function_id="func_abc123", decryption_key="your-key") # Run with local=True for testing test_result = function.run(url="https://test-site.com", local=True) if test_result.status == "closed": print("Test passed, ready to update production") function.update(path="tested_function.py") else: print(f"Test failed: {test_result.result}")
from notte_sdk import NotteClientclient = NotteClient()function = client.Function(function_id="func_abc123")run = client.functions.get_run("func_abc123", "run_xyz789")if run.status == "failed": print(f"Error: {run.result}") # Run the function to get a replay result = function.run() replay = function.replay() replay.download("debug_replay.mp4")
import osdef run(): required_vars = ["API_KEY", "WEBHOOK_URL"] missing = [var for var in required_vars if not os.getenv(var)] if missing: return {"error": f"Missing environment variables: {', '.join(missing)}"} # Continue with automation
from notte_sdk import NotteClientclient = NotteClient()runs = client.functions.list_runs("function_abc123")failures = [r for r in runs.items if r.status == "failed"]print(f"Failed runs: {len(failures)}/{len(runs.items)}")# Analyze failure reasonsfor run in failures[:5]: # Last 5 failures print(f"Run {run.workflow_run_id}:") print(f" Error: {run.result}") print(f" Time: {run.created_at}")