Skip to main content

Swift — raw HTTP

Call ZeqVM from Swift

Swift reaches ZeqVM through three surfaces: the terminal CLI (/cli/), raw HTTP (the wire format below — what every client wraps), and zeq.py (Python — a single file, fetched from any node). The Foundation URLSession snippet below wraps exactly this wire format.

Get the CLI (recommended first install)

Every node serves the terminal CLI with a sha256-pinned installer — the fastest way onto the framework:

curl -fsSL https://zeqstate.com/install.sh | sh # any node works as the origin
zeq tutorial # guided: account → machine → first compute → verify

Full install notes + the complete command reference: /cli/.

Compute over raw HTTP — Foundation only

URLSession + JSONSerialization, async/await, no third-party dependencies. Drop into a main.swift:

import Foundation

let url = URL(string: "https://zeqsdk.com/api/zeq/compute")!
var req = URLRequest(url: url)
req.httpMethod = "POST"
let key = ProcessInfo.processInfo.environment["ZEQ_API_KEY"] ?? ""
req.setValue("Bearer \(key)", forHTTPHeaderField: "Authorization")
req.setValue("application/json", forHTTPHeaderField: "Content-Type")
req.httpBody = try JSONSerialization.data(withJSONObject: [
"operators": ["KO42", "NM19"],
"domain": "Newtonian Mechanics",
"inputs": ["mass": 5, "acceleration": 9.81]
])

let (data, _) = try await URLSession.shared.data(for: req)
let out = try JSONSerialization.jsonObject(with: data) as! [String: Any]
print(out["value"] ?? "", out["unit"] ?? "", "±", out["uncertainty"] ?? "")
print("zeqProof:", out["zeqProof"] ?? "")
print("explorer:", out["explorer_url"] ?? "")

Prefer Codable structs for production parsing — the envelope is stable JSON. The public pulse needs no key: GET https://zeqsdk.com/api/zeq/pulse.

The response's compliance field is the ZeqCompliance v1 envelope — the 13-standard regulatory record returned on every call. Every result also carries signed — an Ed25519-signed claim (claim + signature + public_key) verifiable offline by anyone, or by POSTing the block to any node's public /api/attest. Or pipe the whole envelope to the CLI: … | zeq verify -.

Why Swift here

  • iOS apps. Drive a SwiftUI view from the envelope; observe the entangled state in real time on a phone.
  • Medical devices on iPad. HIPAA-aligned envelopes paired with on-device biometric attestation; the Embedded C observer agent sits next to the Swift app on a paired peripheral.
  • visionOS spatial workspaces. Compose physics simulations live in 3D with a compute call driving the timeline.

Compose with

Source