Beta. STARCO Dev works with synthetic data only: do not send real personal or health data. Every feature shows its real status (Available Beta Beta · in development Coming).

Documentation menu

Example 05

Export a twin, check its fingerprint.

Download a twin as one JSON document and prove that the bytes you stored are the bytes the server sent.

time 2 minuses export · X-Content-SHA256 Betadata synthetic
Beta.The API this program calls is in beta and works with synthetic data only. The program is complete: with a project key in STARCO_KEY it runs as it is. The TypeScript and CLI tabs use the SDK and the command line, which are not published yet.

The idea#

GET /v1/twins/{twin}/export returns the twin, its layers, observations, measures and state as one document. The header X-Content-SHA256 is the SHA-256 of exactly those bytes: hash the file you saved, not a re-serialised copy.

The whole program#

export API="https://api.starco.dev/v1"
AUTH="Authorization: Bearer $STARCO_KEY"
JSON="Content-Type: application/json"
TWIN=$(curl -s "$API/twins?limit=1" -H "$AUTH" | jq -r '.data[0].id')     # one of the synthetic twins of the project
curl -s -D headers.txt -o twin.json "$API/twins/$TWIN/export" -H "$AUTH"
SENT=$(grep -i '^x-content-sha256:' headers.txt | tr -d '\r' | sed 's/^.*: //')
MINE=$(sha256sum twin.json | cut -d' ' -f1)
[ "$SENT" = "$MINE" ] && echo "fingerprint ok: $MINE" || { echo "fingerprint MISMATCH"; exit 1; }
jq -r '"\(.format) · \(.observations | length) observations"' twin.json
Output of the curl tabillustrative · synthetic
fingerprint ok: 6c1f…e2a9
starco-dev-export/v1 · 168 observations

The other tabs print the same facts in their own format. Ids, hashes and counts depend on your project.

What just happened

The hash of the file equals the header, so what is on disk is what STARCO sent. Keep the fingerprint with the file: the receipt of a later erasure of the twin carries the fingerprint of its last export.

Go further#