Skip to content

prefactor_http.client module

HTTP client for Prefactor API.

Bases: object

Main HTTP client for interacting with the Prefactor API.

This client provides high-level methods for all API endpoints with built-in retry logic, error handling, and idempotency support.

Usage: : async with PrefactorHttpClient(config) as client: : instance = await client.agent_instances.register(…) span = await client.agent_spans.create(…)

Access the agent instance endpoint client.

Provides methods to interact with agent instances:

  • register: Create a new agent instance
  • start: Mark an instance as started
  • finish: Mark an instance as finished

instance = await client.agent_instances.register(agent_id, agent_version)

Access the agent span endpoint client.

Provides methods to interact with agent spans:

  • create: Create a new agent span
  • finish: Mark a span as finished

span = await client.agent_spans.create( : agent_instance_id, schema_name, payload

)

Access the bulk endpoint client.

Provides methods to execute multiple queries/actions in a single request:

  • execute: Execute bulk operations

response = await client.bulk.execute(bulk_request)

Close the HTTP session.

async request(method: str, path: str, , params: dict[str, Any] | None = None, json_data: dict[str, Any] | None = None, idempotency_key: str | None = None) → dict[str, Any]

Section titled “async request(method: str, path: str, , params: dict[str, Any] | None = None, json_data: dict[str, Any] | None = None, idempotency_key: str | None = None) → dict[str, Any]”

Make an HTTP request with retry logic.

This is the public request method that wraps the core request with retry handling.

  • Parameters:
    • method – HTTP method (GET, POST, PUT, DELETE).
    • path – API path.
    • params – Query parameters.
    • json_data – JSON body data.
    • idempotency_key – Optional idempotency key.
  • Returns: Parsed JSON response.
  • Raises: