Quantum Simulation API Reference

Execute the current circuit DSL over HTTP and inspect exact state probabilities, seeded measurements and generated diagrams.

Documentation version: 2.1 · Compatible with: current AutomationGlance simulator · Last reviewed: 2026-10-17

Open API playground · Full DSL specification →

Endpoint and host

POST /api/runSimulation with Content-Type: application/json. On the live site, frontend/config/settings.js sets the API base to https://quantum-playground-flex-gag3cjd5aedvf6dz.southindia-01.azurewebsites.net. Append the endpoint to that host; the site's https://automationglance.com/api/ serves this documentation. Azure Functions local development normally uses port 7071; the repository integration fixture uses 7073.

Request fields

Simulation request object
FieldType / defaultContract
circuitstring, requiredNonempty supported DSL; configured default string limit 10,000 characters
shotsinteger, 10241–100,000 inclusive
seedinteger or null, omittedSigned 32-bit (−2147483648…2147483647); omitted/null derives a stable seed
sessionIdstring or nullRequired and nonblank when monetization is enabled; use the session identifier associated with your usage allocation. Ignored for quota purposes when disabled.

Field names are case-insensitive. Unknown fields, malformed JSON, comments and trailing commas are rejected by payload validation. Send each field once. No noise, backend, format, or gate-definition option is supported by this endpoint. No API key is required by this controller; deployment infrastructure may add restrictions.

{
  "circuit": "qubits 2\nH 0\nCX 0 1\nMEASURE 0\nMEASURE 1",
  "shots": 1024,
  "seed": 42,
  "sessionId": "documentation-local-session"
}

The example session is for the local fixture. Use your own existing session for a monetized deployment; examples do not bypass usage limits. Invalid DSL is parsed after the simulator quota guard, so an unsuccessful DSL execution can consume a run.

Successful response (HTTP 200)

Public JSON response fields
FieldType and meaning
successboolean, true on success
probabilitiesarray of {state: string, probability: number}; full computational-basis distribution, independent of shots
countsobject from measured bitstring to integer sampled count; only sampled keys appear; empty if no measurements
blochVectorsarray of {x,y,z} numbers, one reduced single-qubit Bloch vector per qubit
stateVectorarray of {state: string, real: number, imag: number}; full final pre-measurement amplitudes in increasing basis index
metadata{seed: integer, shots: integer, numQubits: integer, backendVersion: string}
errorsarray of {line: integer or null, message: string, type: string, code: string or null}; successful parses can contain warnings
circuit_image_base64string or null; raw base64 SVG payload
circuitDiagramstring or null; equivalent SVG data URL, ready for image display

For the Bell request, probabilities are 0.5 for 00 and 11 and zero for 01 and 10, up to floating-point roundoff. Each qubit's Bloch vector is (0,0,0). Counts sum to shots but need not split equally. Do not interpret the statevector as the result of physical hardware execution.

Full-state labels put q0 leftmost. Counts follow MEASURE statement order and may have a different width. All gates run before sampling; no mid-circuit feedback. See measurement ordering.

HTTP errors

Implemented controller and middleware statuses
StatusWhen
400Invalid JSON/shape/unknown fields, type deserialization failure, string too long, missing required monetized session
402Free and paid simulation runs exhausted when monetization is enabled
413Request body exceeds configured byte limit
422Missing/blank circuit, invalid shots, invalid DSL, width >8, or simulation validation failure
429Enabled per-client rate limit exceeded; Retry-After indicates wait seconds
500Unexpected parsing or simulation failure

Error objects include error and correlationId; detail or message may be present. DSL failure includes parse_errors; do not assume the success response's errors field. A width error also supplies requested and limit. A quota error supplies paymentEndpoint. Preserve the correlation ID when diagnosing failures.

Limits and reproducibility

Execution: 1–8 qubits and 1–100,000 shots. Checked-in security defaults: 1,048,576 request bytes, 10,000 characters per string, and 60 requests per 60-second window per client (normally IP). These security settings are deployment-configurable; they are not a guarantee of production quota. This controller has no separate gate-count limit; circuit text is bounded by request limits. Session usage limits are separate from rate limits.

Explicit seed controls only sampling. Otherwise 32-bit FNV-1a hashes UTF-8 bytes of the exact circuit + "|" + shots string. Editing whitespace or shots changes the derived seed. Metadata returns the seed and backend version; reproducibility assumes the same circuit, shots, seed and backend/runtime. Probabilities and amplitudes are deterministic ideal calculations independent of seed.

Executable client examples

These examples use the local fixture by default. Set AUTOMATIONGLANCE_API_BASE to your API host and AUTOMATIONGLANCE_SESSION_ID to your existing session for another deployment. Each checks HTTP failure before using results.

curl (bash and Python 3 for JSON encoding)

Download curl (bash and Python 3 for JSON encoding) example

#!/usr/bin/env bash
set -euo pipefail
# Point to your API host; the local integration fixture listens on port 7073.
: "${AUTOMATIONGLANCE_API_BASE:=http://127.0.0.1:7073}"
: "${AUTOMATIONGLANCE_SESSION_ID:=documentation-local-session}"
# Generate JSON safely; never interpolate arbitrary input into a JSON string.
python3 - <<'JSON' | curl --fail-with-body -sS "$AUTOMATIONGLANCE_API_BASE/api/runSimulation" -H 'Content-Type: application/json' --data-binary @-
import json, os
print(json.dumps({"circuit": "qubits 2\nH 0\nCX 0 1\nMEASURE 0\nMEASURE 1", "shots": 1024, "seed": 42,
                  "sessionId": os.environ.get("AUTOMATIONGLANCE_SESSION_ID", "documentation-local-session")}))
JSON

C# (.NET 10)

Download C# (.NET 10) example

#:property PublishAot=false
// .NET 10 file-based app: dotnet run --file csharp.cs
using System.Net.Http.Json;
using System.Text.Json;
var baseUrl = Environment.GetEnvironmentVariable("AUTOMATIONGLANCE_API_BASE") ?? "http://127.0.0.1:7073";
var payload = new {
    circuit = "qubits 2\nH 0\nCX 0 1\nMEASURE 0\nMEASURE 1", shots = 1024, seed = 42,
    sessionId = Environment.GetEnvironmentVariable("AUTOMATIONGLANCE_SESSION_ID") ?? "documentation-local-session"
};
using var client = new HttpClient();
using var response = await client.PostAsJsonAsync(baseUrl + "/api/runSimulation", payload);
var body = await response.Content.ReadAsStringAsync();
if (!response.IsSuccessStatusCode) throw new HttpRequestException($"{(int)response.StatusCode}: {body}");
using var result = JsonDocument.Parse(body);
Console.WriteLine(result.RootElement.GetRawText());

JavaScript (Node.js 18+)

Download JavaScript (Node.js 18+) example

// Node.js 18+; for browser code use window.API_BASE and your existing session ID.
const base = process.env.AUTOMATIONGLANCE_API_BASE || 'http://127.0.0.1:7073';
const payload = {
  circuit: 'qubits 2\nH 0\nCX 0 1\nMEASURE 0\nMEASURE 1', shots: 1024, seed: 42,
  sessionId: process.env.AUTOMATIONGLANCE_SESSION_ID || 'documentation-local-session'
};
const response = await fetch(`${base}/api/runSimulation`, {
  method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(payload)
});
if (!response.ok) throw new Error(`${response.status}: ${await response.text()}`);
console.log(JSON.stringify(await response.json()));

Python 3

Download Python 3 example

# Python 3 standard library.
import json, os, urllib.request, urllib.error
base = os.environ.get("AUTOMATIONGLANCE_API_BASE", "http://127.0.0.1:7073")
payload = {"circuit": "qubits 2\nH 0\nCX 0 1\nMEASURE 0\nMEASURE 1", "shots": 1024, "seed": 42,
           "sessionId": os.environ.get("AUTOMATIONGLANCE_SESSION_ID", "documentation-local-session")}
request = urllib.request.Request(base + "/api/runSimulation", data=json.dumps(payload).encode(),
                                 headers={"Content-Type": "application/json"}, method="POST")
try:
    with urllib.request.urlopen(request) as response:
        print(json.dumps(json.load(response)))
except urllib.error.HTTPError as error:
    raise RuntimeError(f"{error.code}: {error.read().decode()}") from error

Quantum Modeler endpoints and exports

POST /api/v1/quantum-model/maxcut, /api/v1/quantum-model/knapsack and /api/v1/quantum-model/qubo return executed, verified and projected results separately. Use the corresponding modeler pages; Custom QUBO also provides Copy API JSON.

Modeler downloads: DSL and OpenQASM 2.0; Custom QUBO additionally exports automationglance.qubo.v1 JSON with additive objective, variable-order and pair-convention metadata. Keep only coefficient fields when constructing a strict execution request. Simulator image downloads provide SVG and PNG after rendering a current circuit.

AutomationGlance displays x0…xN−1; modeler circuits map xi → q[i] → c[i]. Some tools display classical registers in reverse order c[N−1]…c[0]. Use the measurement mapping before comparing counts. This documents conventions, not tested external-QPU or SDK interoperability.

Optional signed 32-bit seed makes sampling reproducible; omission retains the simulator's circuit/shot-derived default. Modeler handoff preserves its explicit seed.

Validated domain model APIs

POST to the configured API host. Each endpoint supports qaoaDepth=1, shots (1–100,000; default 1,024), seed (signed 32-bit; default 42), and sessionId when quota enforcement is enabled. One execution including explanation uses one run. Unknown or duplicate fields are rejected. Optional target fields project resources for a separate size; only the small input executes. Invalid target fields are rejected before quota reservation. Leave every target field blank to use current-input resource counts.

Portfolio Selection

POST /api/v1/quantum-model/portfolio

{"returns":[3,2,1],"covariance":[[1,0,0],[0,1,0],[0,0,1]],"riskWeight":1,"selectedCount":1,"shots":1024,"seed":42}

Exact objective −2 by selecting asset 0; three qubits. 1–8 assets; selectedCount is required and can be 0..N. Finite returns/covariance magnitudes and nonnegative riskWeight are limited to 1,000,000. Symmetry and positive semidefiniteness are validated within documented tolerances.

Set Cover

POST /api/v1/quantum-model/set-cover

{"universe":["A","B","C"],"sets":[{"elements":[0,1],"cost":2},{"elements":[1,2],"cost":2},{"elements":[0,1,2],"cost":5}],"shots":1024,"seed":42}

Exact cost 4 using sets 0 and 1; seven qubits including four slack bits. Universe and set arrays each have 1–8 entries. Labels are distinct, nonblank and at most 64 characters. Each set contains distinct zero-based universe indices and integer cost 1–1,000. Empty sets and uncovered elements are accepted.

Fixed-K Graph Coloring

POST /api/v1/quantum-model/graph-coloring

{"vertices":3,"colors":2,"edges":[[0,1],[1,2]],"shots":1024,"seed":42}

Feasible with colors 0,1,0; six qubits. Vertices and colors are integers 1–8 with product at most 8. Edges use distinct in-range zero-based endpoints with no duplicate undirected pairs; an empty edge list is allowed.

TSP

POST /api/v1/quantum-model/tsp

{"distances":[[0,2,3],[2,0,4],[3,4,0]],"targetCities":100,"shots":1024,"seed":42}

The three-city tour costs 9 and executes on four qubits. Distances must be finite, nonnegative, exactly symmetric and zero-diagonal, with entries at most 1,000,000. City 0 is the start and finish. Optional targetCities (2–1,000,000,000) projects (n−1)² qubits without constructing another distance matrix or tour.

Job Scheduling

POST /api/v1/quantum-model/job-scheduling

{"machineCount":1,"horizon":2,"jobs":[{"operations":[{"machine":0,"duration":1},{"machine":0,"duration":1}]}],"targetOperations":1000,"targetHorizon":100,"shots":1024,"seed":42}

The small instance is feasible with penalty zero and four qubits. Operation machines are zero-based; durations and horizon are positive integers, with duration at most horizon and horizon at most 2,048. Ordered job operations must obey precedence and machine non-overlap. Makespan is not optimized. Supply targetOperations (1–1,000,000,000) and targetHorizon (1–2,048) together. Optional targetDurationHistogram bins such as {"duration":3,"count":1000} give exact variable counts; without them, operations × horizon is an upper bound. At most 256 unique durations are allowed and counts must sum to targetOperations.

Vehicle Routing

POST /api/v1/quantum-model/vehicle-routing

{"distances":[[0,2,2,2],[2,0,2,2],[2,2,0,2],[2,2,2,0]],"demands":[1,1,1],"capacity":2,"vehicleCount":2,"targetCustomers":100,"targetVehicleCount":10,"targetCapacity":10,"targetMinimumDemand":1,"shots":1024,"seed":42}

The small instance has exact distance 10 and eight qubits: six complete candidate routes plus two fleet slack bits. Depot 0 is followed by customers in demands order. Positive integer demands and capacity are at most 1,000,000; the explicit input supports 1–10 customers and at most that many identical vehicles, subject to the eight-qubit execution limit. No route candidate is silently truncated.

Supply targetCustomers (1–1,000) and targetVehicleCount (1–targetCustomers) together. Optional targetCapacity and targetMinimumDemand (both 1–1,000,000) must be supplied together. The minimum demand is a lower bound for every target customer. These statistics bound the number of possible routes without generating any. Bounds above eight do not establish actual target ineligibility, and projections do not establish compile eligibility or a target solution.

All new-family projections report decimal counts as strings and symbolic statevector memory. Target fields are Modeler-only; native Compiler JSON uses the explicit domain input without projection or execution fields. See the formulations and projection assumptions.

Responses include problemType, sanitized problem, variableMapping, penalty, qubo, ising, execution, verification, quboVerification, projection, scaling, explanation, artifacts and claims. Domain verification reports instanceFeasible, exactObjective, exactAssignment, objectiveGap and exactOptimumObserved. Sampled best and gap are null without a feasible sampled state. Set-cover candidates distinguish feasibility from slack equality. All generated coefficients and the constant must be finite with magnitude at most 1,000,000.

Malformed JSON returns 400; domain errors return 422 with model-specific codes. Existing 413 size, 429 rate, 400 missing-session, 402 quota and 499 cancellation behavior applies. Invalid models consume no run. Read the encoding methodology.