Python SDK
Build sophisticated research workflows directly in your Python applications.
The BaseCollector Contract
All collectors must inherit from the BaseCollector abstract class. This defines the standard interface and automated workflow for every data source in Lens.
Framework Lifecycle
1. Initialization
Framework injects global config and credentials from the registry into the collector instance.
2. Execution
The run() method orchestrates the internal pipeline while managing retries and logging.
3. Normalization
Standardizes heterogeneous API responses into a unified ResearchItem object.
Working with the Result
The SDK provides structured access to all data retrieved during the research flow.
Async Support
Lens fully supports asyncio. For high-throughput applications, use await lens.aquery() to execute queries without blocking the event loop.
Error Handling
Always wrap your research tasks in a try-except block to handle rate limits and API failures gracefully.