ApiUtility#

class qiskit_calculquebec.API.api_utility.ApiUtility#

Bases: object

Static helper methods for building Thunderhead API payloads.

basic_auth(username, password)

Build a Basic Authentication header value.

convert_circuit(circuit)

Convert a QuantumCircuit to the Thunderhead circuit dictionary format.

convert_instruction(instruction)

Convert a Qiskit gate to a Thunderhead operation dictionary.

headers(username, password, realm)

Build the HTTP request headers required by the Thunderhead API.

job_body(circuit, circuit_name, project_id, ...)

Build the request body for the POST /jobs endpoint.

static basic_auth(username: str, password: str) str#

Build a Basic Authentication header value.

Parameters:
  • username (str) – Thunderhead username.

  • password (str) – Thunderhead access token.

Returns:

"Basic <base64-encoded credentials>" header value.

Return type:

str

static convert_circuit(circuit: QuantumCircuit) dict#

Convert a QuantumCircuit to the Thunderhead circuit dictionary format.

Parameters:

circuit (QuantumCircuit) – Circuit to convert. All instructions must be in the supported gate set.

Returns:

Thunderhead circuit dict with type, bitCount,

qubitCount, and operations fields.

Return type:

dict

static convert_instruction(instruction: Gate) dict#

Convert a Qiskit gate to a Thunderhead operation dictionary.

Parameters:

instruction (Gate) – A Qiskit gate instance with qubits, clbits, and params attributes populated (as found in QuantumCircuit.data).

Returns:

Thunderhead operation dict with type, qubits, and

optionally bits or parameters fields.

Return type:

dict

Raises:

ValueError – If the instruction name is not in the supported gate set.

static headers(username: str, password: str, realm: str) dict[str, str]#

Build the HTTP request headers required by the Thunderhead API.

Parameters:
  • username (str) – Thunderhead username.

  • password (str) – Thunderhead access token.

  • realm (str) – Organizational realm identifier.

Returns:

Headers dict containing Authorization,

Content-Type, and X-Realm.

Return type:

dict[str, str]

static job_body(circuit: dict, circuit_name: str, project_id: str, machine_name: str, shots: int) dict#

Build the request body for the POST /jobs endpoint.

Parameters:
  • circuit (dict) – Circuit in Thunderhead dictionary format.

  • circuit_name (str) – Human-readable label for the circuit.

  • project_id (str) – ID of the project under which the job will be billed.

  • machine_name (str) – Target machine name (e.g. "yukon").

  • shots (int) – Number of shots to execute.

Returns:

JSON-serializable body for the job creation request.

Return type:

dict