Skip to main content

Quickstart

Two calls: who am I, then the demonstration series. They work with a test key, which costs nothing, and with no key at all against the mock.

1. Choose where to call​

TargetBase URLKey
The mock, on your machinehttp://127.0.0.1:4010Any key of the right shape, e.g. pnk_test_ and 36 As
Productionhttps://api.patternode.comYour test key, from the welcome email (Getting your API keys)

To run the mock, from the repository root (Python 3.10 or newer, nothing to install):

python mock/mock_patternode.py

2. Make the calls​

export PATTERNODE_BASE_URL=http://127.0.0.1:4010
export PATTERNODE_API_KEY=pnk_test_AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
examples/curl/quickstart.sh
#!/usr/bin/env bash
# The first calls, with curl. Works with a test key against production or the mock.
# PATTERNODE_API_KEY=pnk_test_... ./examples/curl/quickstart.sh
set -euo pipefail
BASE="${PATTERNODE_BASE_URL:-http://127.0.0.1:4010}"
: "${PATTERNODE_API_KEY:?set PATTERNODE_API_KEY from your secret store}"

# 1. Who am I. Reads need only the key.
curl -sS "$BASE/v1/whoami" -H "authorization: Bearer $PATTERNODE_API_KEY"
echo

# 2. The demonstration series. Every write sends the SHA-256 of its exact body bytes,
# and an Idempotency-Key so a retry cannot run it twice.
BODY='{"demo":"walk"}'
SHA=$(printf '%s' "$BODY" | sha256sum | cut -d' ' -f1)
curl -sS -X POST "$BASE/v1/segmentations" \
-H "authorization: Bearer $PATTERNODE_API_KEY" \
-H "content-type: application/json" \
-H "x-amz-content-sha256: $SHA" \
-H "idempotency-key: $(cat /proc/sys/kernel/random/uuid 2>/dev/null || uuidgen)" \
--data-raw "$BODY" | head -c 600
echo

These are the files in the repository, embedded at build time, and CI runs each of them against the mock. What you read here is what was tested.

3. Read the answer​

A segmentation is a list of segment boxes, parents before children. Each has a level (height), the bars it covers, and its open, high, low and close with their times. The open right edge at each level is provisional. Shards and bars explains them; the API reference has every field.

Next​