https://github.com/techwithty/phantombuster
A production-ready, asynchronous Python SDK for the PhantomBuster API (v1 & v2). Features include comprehensive endpoint coverage, Pydantic models, robust error handling, and a singleton client.
https://github.com/techwithty/phantombuster
api-client asyncio automation ci-cd httpx phantombuster production-ready pydantic python-sdk web-scraping
Last synced: about 1 month ago
JSON representation
A production-ready, asynchronous Python SDK for the PhantomBuster API (v1 & v2). Features include comprehensive endpoint coverage, Pydantic models, robust error handling, and a singleton client.
- Host: GitHub
- URL: https://github.com/techwithty/phantombuster
- Owner: TechWithTy
- Created: 2025-08-15T05:13:26.000Z (about 2 months ago)
- Default Branch: master
- Last Pushed: 2025-08-15T05:13:36.000Z (about 2 months ago)
- Last Synced: 2025-08-15T07:08:05.795Z (about 2 months ago)
- Topics: api-client, asyncio, automation, ci-cd, httpx, phantombuster, production-ready, pydantic, python-sdk, web-scraping
- Language: Python
- Homepage: https://www.cybershoptech.com
- Size: 14.6 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# PhantomBuster Python SDK
## Overview
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.
## Features
- **Asynchronous:** Built with `asyncio` and `httpx` for 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.## Installation
```bash
pip install -e . # Assuming you are in the root of the project
```## Configuration
Create a `PhantombusterConfig` object and initialize the client with it:
```python
from phantombuster.client import PhantombusterClient
from phantombuster.config import PhantombusterConfigconfig = PhantombusterConfig(api_key="YOUR_API_KEY")
client = PhantombusterClient.get_instance(config)
```## Usage Examples
### Fetching All Agents (v2)
```python
import asyncioasync def main():
agents = await client.agents.fetch_all()
print(agents)asyncio.run(main())
```### Launching an Agent (v2)
```python
from phantombuster.__global_models__ import LaunchAgentRequestasync def main():
request = LaunchAgentRequest(id=12345)
response = await client.agents.launch(request)
print(response)asyncio.run(main())
```### Getting User Info (v1)
```python
async def main():
user_info = await client.v1.get_user()
print(user_info)asyncio.run(main())
```## Running Tests
To run the full test suite:
```bash
pytest backend/app/core/third_party_integrations/phantombuster/_tests/
```