A production-ready, asynchronous Python SDK for the PhantomBuster API. This library provides a convenient and robust way to interact with both v1 and v2 of the PhantomBuster API, with built-in support for retries, rate limiting, and data validation using Pydantic.
- Asynchronous: Built with
asyncioandhttpxfor high-performance, non-blocking I/O. - Comprehensive Endpoint Coverage: Implements a wide range of v1 and v2 API endpoints.
- Pydantic Models: Includes Pydantic models for request and response validation.
- Singleton Client: Uses a singleton pattern for efficient client management.
- Robust Error Handling: Provides clear, specific exceptions for different API errors.
pip install -e . # Assuming you are in the root of the projectCreate a PhantombusterConfig object and initialize the client with it:
from phantombuster.client import PhantombusterClient
from phantombuster.config import PhantombusterConfig
config = PhantombusterConfig(api_key="YOUR_API_KEY")
client = PhantombusterClient.get_instance(config)import asyncio
async def main():
agents = await client.agents.fetch_all()
print(agents)
asyncio.run(main())from phantombuster.__global_models__ import LaunchAgentRequest
async def main():
request = LaunchAgentRequest(id=12345)
response = await client.agents.launch(request)
print(response)
asyncio.run(main())async def main():
user_info = await client.v1.get_user()
print(user_info)
asyncio.run(main())To run the full test suite:
pytest backend/app/core/third_party_integrations/phantombuster/_tests/