This folder contains comprehensive examples demonstrating all features of the Maxun SDKs.
-
Set up your environment:
export MAXUN_API_KEY="your_api_key_here" export MAXUN_BASE_URL="http://localhost:5001/api/sdk"
-
Install dependencies:
cd maxun-sdks npm install npm run build -
Make sure your backend server is running:
cd maxun-cloud-recording npm run dev
Extracts structured data from a single page:
npx tsx examples/basic-extraction.tsWhat it does:
- Creates a robot to extract specific fields using CSS selectors
- Executes the robot
- Displays the extracted data
- Demonstrates the simplest extraction workflow
The simplest possible page scraping - just URL and format:
npx tsx examples/simple-scrape.tsWhat it does:
- Creates a scrape robot with just a URL
- Specifies output format(s): markdown and/or HTML
- No workflow needed - metadata-only robot
- Automatically scrapes entire page content
Demonstrates form filling with automatic input type detection:
npx tsx examples/form-fill-screenshot.tsWhat it does:
- Navigates to a form page
- Fills various input fields (text, number, password, date)
- Automatically detects input types
- Values are securely encrypted during storage
- Takes screenshots (full-page and viewport)
Multi-page workflows with navigation:
npx tsx examples/chained-extract.tsWhat it does:
- Demonstrates complex workflows with multiple navigation steps
- Shows how to chain actions together
- Extracts data from different pages in sequence
Different pagination strategies for extracting lists:
npx tsx examples/list-pagination.tsWhat it does:
- Auto-detect pagination (recommended)
- Infinite scroll pagination
- Click "Next" button pagination
- Click "Load More" button pagination
- Limit extraction to specific number of items
Use natural language prompts to create extraction robots:
npx tsx examples/llm-extraction.tsWhat it does:
- Generate extraction workflows using natural language prompts
- LLM automatically determines what data to extract
- Support for multiple providers: Ollama (local), Anthropic, OpenAI
- Creates a reusable robot from the generated workflow
- No need to write selectors manually
List, get, update, and delete robots:
npx tsx examples/robot-management.tsWhat it does:
- Create multiple robots
- List all robots
- Get specific robot by ID
- Update robot metadata and workflow
- Get all runs and execution history
- Get specific run by ID
- Delete robots
Schedule robots for periodic execution:
npx tsx examples/scheduling.tsWhat it does:
- Schedule robots with simple intervals (every N minutes/hours/days/weeks/months)
- Schedule with detailed options (business hours, specific days, time ranges)
- Specify timezone for accurate scheduling
- Get current schedule information
- Update existing schedules
- Remove schedules
- Examples include: hourly, business hours only, weekly, monthly, and per-minute schedules
Set up webhooks for robot events:
npx tsx examples/webhooks.tsWhat it does:
- Add webhooks for run completion/failure events
- Configure custom headers
- List all webhooks
- Remove webhooks
Real-world use case combining multiple features:
npx tsx examples/complete-workflow.tsWhat it does:
- Creates comprehensive extraction robot
- Sets up pagination
- Configures webhooks
- Schedules periodic execution
- Demonstrates full production workflow
=== Basic Extraction Example ===
Creating robot...
✓ Robot created: robot_1234567890_abc123
Executing robot...
✓ Execution completed!
Results:
{
"title": "A Light in the Attic",
"price": "£51.77",
"availability": "In stock"
}
=== Robot Management Example ===
Creating robots...
✓ Created robot 1: robot_abc123
✓ Created robot 2: robot_xyz789
Fetching all extract robots...
✓ Found 2 extract robots:
1. Books Extractor (robot_abc123)
2. Product Details (robot_xyz789)
Running robot...
✓ Execution completed!
Status: success
Run ID: run_123
Items extracted: 20
=== Robot Scheduling Example ===
Scheduling robot to run every 6 hours...
✓ Robot scheduled successfully!
Current schedule:
Run every: 6 HOURS
Timezone: America/New_York
Updating schedule to run daily...
✓ Schedule updated!
- List extraction with pagination: Auto-detect or specify pagination type
- Input type detection: Automatic detection for form fields
- Secure encryption: Values automatically encrypted during storage
- Workflow building: Chain multiple actions (navigate, type, click, extract, screenshot)
- Field extraction: Extract specific fields using CSS selectors
- Simplest API: Just URL and format - no workflow needed
- Multiple formats: Get markdown, HTML, or both
- Quick scraping: Perfect for simple page content extraction
- Full CRUD operations: Create, read, update, delete robots
- Execution history: Get all runs, specific runs, latest run
- Metadata updates: Change robot names and configurations
- Flexible intervals: Minutes, hours, days, weeks, months
- Timezone support: Run in any timezone
- Easy management: Schedule, update, and unschedule
- Event notifications: Get notified on run completion/failure
- Custom headers: Add authentication and custom headers
- Multiple webhooks: Support for multiple webhook endpoints
Make sure you've set the MAXUN_API_KEY environment variable:
export MAXUN_API_KEY="your_api_key"Make sure:
- Your backend server is running on port 5001
- The SDK routes are loaded (
api/sdk.tsshould be registered)
Check the backend logs for detailed error information:
# In maxun-cloud-recording folder
npm run devMake sure:
- Backend is running:
npm run devin maxun-cloud-recording - Database is running and accessible
- Environment variables are set correctly
After running these examples, you can:
- Modify the selectors to extract different data
- Try different websites and extraction patterns
- Set up production schedules and webhooks
- Build custom workflows combining multiple features
- Integrate Maxun into your applications
Google Sheets and Airtable integrations require OAuth authentication which must be set up through the Maxun web platform. Once configured via the UI, your robots will automatically send results to the configured integrations. The SDK does not currently support setting up integrations programmatically.
To get your API key:
- Log into Maxun dashboard
- Go to Settings → API Keys
- Generate a new API key
- Copy and export it as shown above
For full SDK documentation, see: