Writing a Function
Functions are Python scripts with arun() function that serves as the entry point.
Basic Function
The minimal Function structure:Function with Parameters
Accept input parameters:Browser Automation Function
Use Notte SDK for browser automation:Deploying Functions
Via SDK
Deploy from Python:Deployment Options
workflow_path(str, required): Path to your Python filename(str, optional): Function display namedescription(str, optional): What the function doesshared(bool, default=False): Whether function is publicly accessible
Function Requirements
The Handler
Must have arun() function:
Dependencies
Import Notte SDK and standard libraries:notte-sdk- Notte SDKrequests- HTTP clientpydantic- Data validation- Standard Python library
- Most common packages
Return Values
Return JSON-serializable data:Parameter Types
Supported Types
Type Validation
Use type hints for automatic validation:Complex Types
Use Pydantic for structured parameters:Environment Variables
Access secrets securely:Error Handling
Graceful Errors
Return error information in results:Raising Exceptions
Let Functions fail explicitly:Testing Locally
Test Before Deploying
Run your function locally:Mock API Calls
Test without deploying:Best Practices
1. Document Parameters
Use clear docstrings:2. Return Structured Data
Use consistent return formats:3. Add Logging
Log key steps for debugging:4. Set Timeouts
Prevent functions from hanging:5. Validate Inputs
Check parameters before processing:Examples
Simple Scraper
Form Submission
form_submission.py
Data Extraction
structured_extraction.py

