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
| Target | Base URL | Key |
|---|---|---|
| The mock, on your machine | http://127.0.0.1:4010 | Any key of the right shape, e.g. pnk_test_ and 36 As |
| Production | https://api.patternode.com | Your 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
- curl
- Python
- TypeScript
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
examples/python/first_call.py
"""Your first call: who am I, then the demonstration series. Works with a test key.
PATTERNODE_API_KEY=pnk_test_... python examples/python/first_call.py
"""
from patternode_client import Patternode
pn = Patternode()
me = pn.get("/v1/whoami")
print(f"key {me['id']} ({me['kind']}) on account {me['account']}, tier {me['tier']}")
result = pn.post("/v1/segmentations", {"demo": "walk"})
print(f"{result['bars']} bars, {result['depth']} levels, {len(result['segments'])} segments")
for seg in result["segments"][:3]:
edge = " (provisional)" if seg["provisional"] else ""
print(f" {seg['id']}: level {seg['height']}, {seg['bars']} bars, {seg['open']} -> {seg['close']}{edge}")
examples/typescript/src/first-call.ts
// Your first call: who am I, then the demonstration series. Works with a test key.
// PATTERNODE_API_KEY=pnk_test_... node src/first-call.ts
import { Patternode } from "./client.ts";
const pn = new Patternode();
const me = await pn.get("/v1/whoami");
console.log(`key ${me.id} (${me.kind}) on account ${me.account}, tier ${me.tier}`);
const result = await pn.post("/v1/segmentations", { demo: "walk" });
console.log(`${result.bars} bars, ${result.depth} levels, ${result.segments.length} segments`);
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
- Getting your API keys, before you need a live key.
- Integration patterns, to choose how your system calls Delve.
- The onboarding playbook, to plan the whole route.