Herd Python SDK
A powerful SDK for controlling your own browser and other devices through the Herd platform. Similar to Puppeteer but with support for multiple devices and real-time events, and no infrastructure to setup.
Learn more about Herd at https://herd.garden.
Features
- 🌐 Control multiple browsers and devices from a single client
- ⛏️ Extract data from web pages
- 🔍 Run automations and interact with webpages
- 🤖 Build AI web tools that can use your own browser and accounts
- 🚀 Familiar automation API similar to Puppeteer
- 🧩 Python type hints for better IDE support
Installation
pip install monitoro-herd
Usage
Here's a basic example of how to use the SDK:
import asyncio
from monitoro_herd import HerdClient
async def example():
# Create a client
client = HerdClient(
token='your-auth-token'
)
# Initialize the client (required before using)
await client.initialize()
try:
# List available devices
devices = await client.list_devices()
print('Available devices:', devices)
# Get a specific device
device = await client.get_device('device-id')
# Create a new page
page = await device.new_page()
# Navigate to a URL
await page.goto('https://example.com')
# Click an element
await page.click('#submit-button')
# Fill a form field
await page.fill('#username', 'testuser')
# Extract data
data = await page.extract({
'title': 'h1',
'description': '.description',
'items': {
'price': '.item-price',
'name': '.item-name'
}
})
print('Extracted data:', data)
# Subscribe to device events
def handle_event(event):
print('Device event:', event)
unsubscribe = device.on_event(handle_event)
# Cleanup
unsubscribe()
await page.close()
await device.close()
finally:
# Always close the client when done
await client.close()
# Run the example
asyncio.run(example())
Features
- Asynchronous API using
asyncio - Device management
- Browser automation
- Event subscription
- Data extraction
- Automatic reconnection handling
- Type hints for better IDE support
API Reference
Complete API reference is available at https://herd.garden/docs/reference.
HerdClient
The main client class for interacting with the Herd platform.
client = HerdClient(token: str)
Methods:
initialize()- Initialize the client and connect to NATSlist_devices()- Get a list of available devicesget_device(device_id: str)- Get a specific deviceregister_device(device_id: str, device_type: str, name: str = None)- Register a new deviceclose()- Close the client and cleanup resources
Device
Represents a device in the Herd platform.
Methods:
new_page()- Create a new pagelist_pages()- List all pagesget_page(page_id: int)- Get a specific pageon_event(callback)- Subscribe to device eventsclose()- Close the device and cleanup resources
Page
Represents a browser page/tab.
Methods:
goto(url: str)- Navigate to a URLclick(selector: str, options: Dict = None)- Click an elementfill(selector: str, value: str, options: Dict = None)- Fill a form fieldextract(selectors: Dict)- Extract data from the pageclose()- Close the page
Error Handling
The SDK uses exceptions to handle errors. Make sure to handle these appropriately in your code:
try:
await client.initialize()
except Exception as e:
print(f"Failed to initialize client: {e}")
Best Practices
- Always use
async/awaitwith the SDK functions - Initialize the client before using it
- Close resources when done using them
- Handle exceptions appropriately
- Use type hints for better code completion
- Subscribe to events when needed for real-time updates
Contact us
If you have any questions or feedback, please contact us at pypi@herd.garden.
License
EULA - see LICENSE
Metadata
Release files for monitoro-herd 0.1.5
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| monitoro_herd-0.1.5.tar.gz | 11.2 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| monitoro_herd-0.1.5-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 21.0 kB
Release files / monitoro_herd-0.1.5.tar.gz
| Download URL | monitoro_herd-0.1.5.tar.gz |
|---|---|
| Size | 11.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
1afe9f0ec0f859164fa15d7f2f69f1270b871bedfc7397ecc92868b779796fb3
|
|
BLAKE2b-256 checksum How to use checksums |
5c315545eee55db043c3c837a9bf3c4c9448b1201f27f805542424be9a7b5198
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.11.9
|
Release files / monitoro_herd-0.1.5-py3-none-any.whl
| Download URL | monitoro_herd-0.1.5-py3-none-any.whl |
|---|---|
| Size | 9.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
abb443416f671cb3110f1bfc09802b59fb2f2cbc8c632d764297e258ceb476dd
|
|
BLAKE2b-256 checksum How to use checksums |
ad77f40652320f05eed8dfbd2cd1c5121658d8a0b34aa639aca36684c0096f77
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.11.9
|