#
Abstract Base Classes
These are the base classes used internally to build all task payloads. You typically don't instantiate them directly, but they are useful for understanding the type hierarchy and for building custom tasks via VanillaTaskPayload.
#
TaskPayload
class TaskPayload(BaseModel, ABC)
Abstract base model for all task payloads. Every task type inherits from this class.
#
Methods
#
to_request() -> dict[str, Any]
Abstract method. Converts the task instance into a dictionary suitable for the API request body.
#
ProxyPayload
class ProxyPayload(BaseModel)
Proxy configuration model. Used by tasks that support or require proxy settings.
#
Example
from capmonster_python import ProxyPayload
proxy = ProxyPayload(
proxyType="https",
proxyAddress="192.168.1.1",
proxyPort=8080,
proxyLogin="user",
proxyPassword="pass"
)
#
UserAgentPayload
class UserAgentPayload(BaseModel, ABC)
Mixin base class that adds an optional userAgent field to task payloads.
#
VanillaTaskPayload
class VanillaTaskPayload(TaskPayload, UserAgentPayload)
Forward-compatible base class for custom or newly introduced task types. Allows extra fields via Pydantic's model_config = {"extra": "allow"}.
Use this as a base to quickly integrate a new task format not yet supported by the SDK:
from capmonster_python import VanillaTaskPayload
class CustomCaptchaTask(VanillaTaskPayload):
type: str = "NewCustomTask"
custom_field: str