Skip to main content

Package-ready Python client for the Quantum API /v1 contract

Project description

Quantum API Python SDK

Package-ready sync Python client for the Quantum API /v1 contract.

This SDK targets scripts, CLIs, service integrations, and backend-side automation. It keeps a sync httpx client as the default public surface and supports context-manager usage.

Current Scope

  • Full current /v1 method surface
  • Mounted base URL normalization:
    • http://127.0.0.1:8000 -> http://127.0.0.1:8000/v1
    • https://example.com/public-facing/api/quantum -> https://example.com/public-facing/api/quantum/v1
    • https://example.com/public-facing/api/quantum/v1 stays unchanged
  • Auth support for:
    • X-API-Key runtime endpoints
    • bearer-token /keys* and /ibm/profiles* flows
    • per-call auth override
  • Structured QuantumApiError

Install

pip install quantum-api-sdk

For local development in this repo:

python3 -m pip install -e sdk/python

Basic Usage

from quantum_api_sdk import QuantumApiClient, QuantumApiError

with QuantumApiClient(
    base_url="http://127.0.0.1:8000",
    api_key="your-runtime-key",
    bearer_token="your-supabase-jwt",
) as client:
    try:
        health = client.health()
        gate = client.run_gate({"gate_type": "rotation", "rotation_angle_rad": 1.57079632679})
        print(health["status"], gate["measurement"])
    except QuantumApiError as exc:
        print(exc.status_code, exc.code, exc.request_id, exc.details)

Auth Modes

The client defaults to auto auth mode:

  • health and portfolio.json -> public
  • /keys* and /ibm/profiles* -> bearer token
  • all other /v1 routes -> API key

Per-call override examples:

client.health(auth="none")
client.echo_types(auth="api_key")
client.list_keys(auth="bearer")

Account Setup (Public Identerest Sign-In)

If you are using the hosted Quantum API account flow (not self-hosting), credentials come from signing in at https://davidjgrimsley.com/public-facing/api/quantum.

  1. Open https://davidjgrimsley.com/public-facing/api/quantum and sign in with an Identerest account.
  2. In the Api Keys panel, create a Quantum API key and copy it immediately (raw key is shown once).
  3. In the IBM Credentials panel, create an IBM profile (profile_name, IBM API token, IBM instance/CRN, channel), then verify it.
  4. Optionally set one IBM profile as default on that same public page.

How those values map into the SDK:

  • bearer token from that Identerest-backed sign-in session -> bearer_token (used for /keys* and /ibm/profiles*).
  • created Quantum API key -> api_key (used for protected runtime /v1 routes).
  • selected IBM profile name -> ibm_profile in IBM backend/transpile/job requests.

IBM Profiles (Per-User IBM Credentials)

This is the flow behind profile cards/actions like Verify, Set Default, Edit, and Delete.

The Python SDK exposes full profile lifecycle methods:

  • list_ibm_profiles()
  • create_ibm_profile(payload)
  • update_ibm_profile(profile_id, payload)
  • verify_ibm_profile(profile_id)
  • delete_ibm_profile(profile_id)

Profile routes use bearer auth, so pass the bearer token issued after signing in at https://davidjgrimsley.com/public-facing/api/quantum with Identerest.

from quantum_api_sdk import QuantumApiClient

with QuantumApiClient(
  base_url="https://davidjgrimsley.com/public-facing/api/quantum",
  bearer_token=user_access_token,
) as client:
  created = client.create_ibm_profile(
    {
      "profile_name": "Echo Text Adventure Godot Game",
      "token": "your-ibm-token",
      "instance": "crn:v1:bluemix:public:quantum-computing:us-east:a/1234567890abcdef::",
      "channel": "ibm_quantum_platform",
      "is_default": True,
    }
  )

  verify_result = client.verify_ibm_profile(created["profile_id"])
  profiles = client.list_ibm_profiles()

  client.update_ibm_profile(
    created["profile_id"],
    {
      "profile_name": "Echo Text Adventure Godot Game (Prod)",
      "is_default": True,
    },
  )

  # Later, if needed:
  # client.delete_ibm_profile(created["profile_id"])

When you submit IBM jobs, pass ibm_profile as the selected saved profile name. If omitted, the backend can use the default profile.

job = client.submit_circuit_job(
  {
    "provider": "ibm",
    "backend_name": "ibm_brisbane",
    "ibm_profile": created["profile_name"],
    "circuit": {
      "qubits": 1,
      "operations": [{"gate": "h", "target": 0}],
    },
    "shots": 1024,
  }
)

For shipped production clients, keep IBM tokens server-side and run profile create/update/delete through your backend proxy.

Production Recommendation

For distributed apps and games, prefer a backend-proxy flow so secrets are not embedded in shipped clients. Direct API-key usage is best kept for local, prototype, demo workflows, or game jams.

Method Surface

  • Core:
    • health
    • portfolio
    • echo_types
    • run_gate
    • run_circuit
    • transform_text
  • Runtime:
    • list_backends
    • transpile
    • import_qasm
    • export_qasm
    • run_qasm
  • Auth:
    • list_keys
    • create_key
    • revoke_key
    • rotate_key
    • delete_revoked_keys
    • delete_key
    • list_ibm_profiles
    • create_ibm_profile
    • update_ibm_profile
    • delete_ibm_profile
    • verify_ibm_profile
  • Jobs:
    • submit_circuit_job
    • submit_qasm_job
    • get_circuit_job
    • get_circuit_job_result
    • cancel_circuit_job
  • Domains:
    • grover_search
    • amplitude_estimation
    • phase_estimation
    • time_evolution
    • qaoa
    • vqe
    • maxcut
    • knapsack
    • tsp
    • state_tomography
    • randomized_benchmarking
    • quantum_volume
    • t1
    • t2_ramsey
    • portfolio_optimization
    • portfolio_diversification
    • kernel_classifier
    • vqc_classifier
    • qsvr_regressor
    • ground_state_energy
    • fermionic_mapping_preview

Verification

The broader repo environment may not have uv or test dependencies installed. If you are validating the SDK locally, install the package first and then run your preferred build/test flow.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

quantum_api_sdk-0.1.0.tar.gz (8.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

quantum_api_sdk-0.1.0-py3-none-any.whl (9.8 kB view details)

Uploaded Python 3

File details

Details for the file quantum_api_sdk-0.1.0.tar.gz.

File metadata

  • Download URL: quantum_api_sdk-0.1.0.tar.gz
  • Upload date:
  • Size: 8.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for quantum_api_sdk-0.1.0.tar.gz
Algorithm Hash digest
SHA256 66ef58a7e447f1ce3c5a75c1a5de8f110cbf9b0d6539cbc14385d9e763487562
MD5 e95701935946c0462c3742d76921d3a6
BLAKE2b-256 09c39d9c828bef3f9512b26074a7956d1737d6ef2ed3ec67ea998bda6c4b51b6

See more details on using hashes here.

Provenance

The following attestation bundles were made for quantum_api_sdk-0.1.0.tar.gz:

Publisher: publish-sdk.yml on DavidJGrimsley/quantum-api

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file quantum_api_sdk-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for quantum_api_sdk-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7003cd59433a0a4dd412b28f1353e285fc215f19e292b5b18ba19ebe07218bdc
MD5 7afb8ee7469b5517c1ed6269b2b0dc24
BLAKE2b-256 70792fb4defdc844c7210da90fdaa26b66ec876d7bbd42763b5c0c991bfc1278

See more details on using hashes here.

Provenance

The following attestation bundles were made for quantum_api_sdk-0.1.0-py3-none-any.whl:

Publisher: publish-sdk.yml on DavidJGrimsley/quantum-api

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page