Skip to main content

Kotlin — raw HTTP

Call ZeqVM from Kotlin

Kotlin 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 java.net.http 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 — JDK stdlib only

java.net.http.HttpClient from the JDK (11+), no third-party dependencies. Compile-ready:

import java.net.URI
import java.net.http.HttpClient
import java.net.http.HttpRequest
import java.net.http.HttpResponse

fun main() {
val body = """
{ "operators": ["KO42", "NM19"],
"domain": "Newtonian Mechanics",
"inputs": { "mass": 5, "acceleration": 9.81 } }
""".trimIndent()

val req = HttpRequest.newBuilder()
.uri(URI.create("https://zeqsdk.com/api/zeq/compute"))
.header("Authorization", "Bearer " + System.getenv("ZEQ_API_KEY"))
.header("Content-Type", "application/json")
.POST(HttpRequest.BodyPublishers.ofString(body))
.build()

val res = HttpClient.newHttpClient().send(req, HttpResponse.BodyHandlers.ofString())

// Full envelope: value, unit, uncertainty, signed, compliance, zeqProof, explorer_url …
println(res.body())
}

Parse with kotlinx.serialization, Jackson, or Moshi — the envelope is plain JSON. On Android, the same call works with OkHttp. 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 Kotlin here

  • Android apps. Wrap the call in a suspend function — one coroutine per compute, no callback hell.
  • Server-side Ktor or Spring. Drop the call into your service handler; the same envelope shape SOC 2 expects flows straight through.
  • Multiplatform projects. The wire contract is plain JSON over HTTPS — the same calls compile for JVM, Android, iOS (Kotlin/Native), and JS with each platform's HTTP client.

Compose with

  • Java — the same JDK HttpClient call from any Java caller.
  • Hosted API reference — every route, body, response, error.
  • HTTP / curl — the full wire-format walkthrough (solve, multibody, attest).

Source