List backends
examples/list_backends.py
The problem
Section titled “The problem”Every integration starts with the same two questions: which backends can this API key reach, and what does each of them accept? This example answers both in one screen — the backend catalogue with each entry’s type, qubit count and availability, followed by the marketplace offerings.
The walkthrough
Section titled “The walkthrough”from qubitra import QubitraClientQubitraClient reads QUBITRA_API_KEY and QUBITRA_API_URL from the environment, so
the example needs no configuration code of its own.
def main() -> None: with QubitraClient() as client: for backend in client.backends.list(): kind = backend.type.value if backend.type else "?" qubits = f"{backend.qubit_count}q" if backend.qubit_count else "" state = "available" if backend.available else "unavailable" print(f"{backend.id:32} {kind:10} {qubits:6} {state:12} {backend.name or ''}")client.backends.list() returns the whole catalogue this key can reach. The guards on
type and qubit_count matter: capability fields are absent until known, so a backend
whose metadata has yet to sync carries None there, and the example prints it as ?
or an empty column.
print() for offering in client.marketplace.offerings(): print(f"{offering.id:38} {offering.type.value:14} {offering.name or ''}")client.marketplace.offerings() lists the marketplace’s published offerings — the
applications, tools and backends available to acquire — with each one’s type and name.
Running it
Section titled “Running it”QUBITRA_API_KEY=qpk_... python examples/list_backends.pyThe output is one line per backend — id, type, qubit count, availability, display
name — then a blank line and one line per marketplace offering. The catalogue is the
deployment’s own, so the exact rows depend on where you point QUBITRA_API_URL; a dev
stack shows the seeded simulators, sim-statevector-26q among them.
Where to go next
Section titled “Where to go next”- Choosing a backend — how to pick from the catalogue this example prints.
- Circuit formats — what each backend’s
supported_formatsvalues mean.