Integration Recommendations & Best Practices
To get the most out of bro, we recommend following these guidelines and tips to optimize for performance, reliability and cost.
Performance & Reliability
- Batch related commands: Group sequential actions into a single
POST /executecall. This dramatically reduces network round-trips and latency. - Graceful cleanup: Always shut down sessions explicitly when your task completes or fails (by using a
finallyblock in python3, for ex). This frees up the worker immediately and prevents unnecessary billing for idle time. - Set client-side timeouts: Although
brouses smart long-polling, always set explicit client-side timeouts to prevent your integration from hanging indefinitely in case of network drops.
AI Features (act & extract)
- Choosing the right tool:
- Use manual commands when you know the exact action sequence and page layout. It's the fastest and cheapest approach.
- Use
actwhen you need to interact with a page (like searching for something, filling a form, etc.). - Use
extractwhen you are already on the target page and just need to scrape structured JSON data.
- Designing JSON Schemas:
- Extracting lists: If you want to extract a list or array of objects (like search results or a table), wrap your schema object in brackets
[]. Example:[{"title": "...", "price": "..."}]. - Provide rich context: Don't just provide empty strings or generic keys. Give the AI more context about the values you expect by adding short descriptions, data types, allowed values or classification criteria right inside the schema values. Example:
{"status": "<'in_stock' or 'out_of_stock'>", "price": "<numeric float value without currency symbol>"}.
- Extracting lists: If you want to extract a list or array of objects (like search results or a table), wrap your schema object in brackets
- Cost optimization for AI:
- If you only need text data from a simple layout, consider setting
vision: falsein yourextractparameters. It will rely purely on the text recognized by our OCR model (which is cheaper). - Use
viewport_maxto restrict the AI's attention if the data you need is always at the top of the page (ignoring massive footers or unrelated content below).
- If you only need text data from a simple layout, consider setting
Sessions & Proxies
- Stateful workflows: Reuse the same session for multi-step workflows.
bromaintains cookies, local storage and page state between commands. - Optimize proxy usage: Enable proxies only when encountering anti-bot protections. To save bandwidth costs, choose the most restrictive
proxy_policythat still works for your target (e.g.,html_onlyorextendedinstead offull). If a website protection is sever, switch back tofull. - Billing snapshots: Fetch the session object via
GET /sessions/{session_id}after expensive workflows to get the most up-to-date snapshot of your proxy and AI costs.