Skip to main content
Simulate payment for a 402-protected resource without executing actual payment. Returns payment requirements and cost estimation without spending funds. Useful for previewing payment details before committing.

Signature

client.simulate_invoice(api_method: str, api_url: str, api_payload: Optional = None, api_params: Optional = None, api_headers: Optional = None, network: Optional = None)

Parameters

  • api_method: HTTP method (GET, POST, PUT, DELETE, etc.).
  • api_url: Target API URL to simulate access.
  • api_payload: JSON payload for POST/PUT requests.
  • api_params: Query parameters to include.
  • api_headers: Custom headers to send with the request.
  • network: Network override for relay mode simulation.

Returns

Response containing payment requirements and simulation details.

Raises

  • ValueError: If network is incompatible with wallet type or not supported.

Examples

>>> client = HTTPayerClient()
>>> sim = client.simulate_invoice("GET", "https://api.example.com/data")
>>> print(f"Cost: {sim.json()['relayFeeBreakdown']['totalAmount']}")