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 session.execute() call. This dramatically reduces network round-trips and latency.
  • Graceful cleanup: Always use with client.create_session() block for sessions, ensuring they are gracefully shut down when your task completes or fails. This frees up the worker immediately and prevents unnecessary billing for idle time.

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 act when you need to interact with a page (like searching for something, filling a form, etc.).
    • Use extract when 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), pass your schema object in brackets [] inside the command. 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>"}.
  • Cost optimization for AI:
    • If you only need text data from a simple layout, consider setting vision=False in your extract parameters. It will rely purely on the text recognized by our OCR model (which is cheaper).
    • Use viewport_max to 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).

Sessions & Proxies

  • Stateful workflows: Reuse the same session for multi-step workflows. bro maintains 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_policy that still works for your target (e.g., extended instead of full). If a website protection is sever, switch back to full.