Docs
Quickstart
Try it without a key, then get one and read the answer well enough to use it. The free plan needs no card.
Try it with no key
Past moments like Bitcoin right now, with what followed each. No account, no parameters, 50 answers a day — and ten moments is one answer. The record answers the same way: every CPI release since 2013, ranked by how much each looked like now. Larger counts, and every other call, need a key, which the next step takes a minute to get.
curlcurl 'https://priorcase.com/v1/search?asset=BTC' curl 'https://priorcase.com/v1/after/cpi?asset=BTC&alike=now'Get a key
Sign in and create a key in your account. It works straight away. We show the key once and never again, so copy it before you leave the page.
shellexport PRIORCASE_KEY="pc_live_…"Make your first call
This asks for the eight past moments most like Bitcoin right now. A model of ours picks them. Bitcoin and Ether are searched intraday; the macro series are read beside a moment rather than searched. See Coverage for the whole list.
curlcurl -H "Authorization: Bearer $PRIORCASE_KEY" \ 'https://priorcase.com/v1/search?asset=BTC&scale=15m&k=8'pythonimport os, requests key = os.environ["PRIORCASE_KEY"] r = requests.get( "https://priorcase.com/v1/search", headers={"Authorization": f"Bearer {key}"}, params={"asset": "BTC", "scale": "15m", "k": 8}, timeout=30, ) r.raise_for_status() answer = r.json() for m in answer["matches"]: moment = m["moment"] print(moment["time"], round(m["similarity"], 3), moment["after"]["ret_32h_pct"])Keep the quotes around the URL. Without them your shell reads
&as “run in the background” and sends only the first parameter.scalesets the window the returned paths are drawn at. It does not change which moments come back: ask the same question at any scale and the matches are the same. What followed is always the next 32 hours.Read the response
Response (trimmed){ "asset": "BTC", "query": { "time": "2026-10-22T03:10:00Z", "then": { "close": 82781.09, "ret_24h_pct": 0.12, "vol_ratio_24h_30d": 1.04, … }, "after": null, "events": [] }, "matches": [ { "rank": 1, "similarity": 0.872, "moment": { "time": "2020-03-20T21:00:00Z", "then": { "close": 6186.25, "ret_24h_pct": 1.84, … }, "after": { "ret_32h_pct": 5.62, "max_up_32h_pct": 8.29, "max_down_32h_pct": -1.69, "path_pct": [ 0.41, 1.02, 0.77, … ] } } } ], "quality": { "n": 8, "first_year": 2019, "last_year": 2026, "range_median_pct": 3.89, "baseline_range_median_pct": 4.61, "range_percentile": 25.1 }, "attestation": { "verified": true, … }, "disclaimer": "Past similarity does not guarantee future…" }Read
queryas the moment you asked about, andmatchesas the past moments that resemble it, ordered bysimilarity.Every moment comes in two parts.
thenis the market data as of that moment,afteris what happened in the 32 hours that followed, measured fromthen.close. We never combine the two, and the moment you asked about carriesafter: nullbecause it has not happened yet.Treat
similarityas a rank, nothing more: nearer one, more alike. A model of ours computes it from the shape of the price rather than its level, which is why a 0.87 match in March 2020 at $6,186 is a match on how the price moved, not on where it was. Readafter.ret_32h_pcton a match, never the two closes.Decide whether the answer is worth anything
Read
qualityfor how much weight the set carries. It never says up or down. Start withrange_percentile: where this answer's spread sits among 2,000 random sets of the same size, from 0 to 100, and low is tight. The 25.1 above means only a quarter of random sets held together more closely. Near 50 the outcomes are spread about as widely as moments picked at random. Above 50 they are spread wider, which says what followed these moments moved more than usual.pythonq = answer["quality"] if q is None or q["range_percentile"] is None: print("too few moments to judge") elif q["range_percentile"] > 50: print("spread like chance; read no direction into it") else: print(q["n"], "moments,", q["first_year"], "-", q["last_year"]) print("spread", round(q["range_median_pct"], 2), "against", round(q["baseline_range_median_pct"], 2), "usual")Small
kis noisy: measured on BTC at 15m, the median spread was 4.73pp atk=8, 1.28pp atk=20and 0.75pp atk=50. Every reply carriesX-Answers-CostandX-Answers-Remaining, so you never have to guess what a run has spent. See limits and errors.Ask about a past moment
Pass
atand we compute the whole answer as it would have been at that instant. We read nothing published or closed after it, and every matched moment's own 32 hours had already closed by then.attestation.verifiedsays the engine checked. It refuses rather than return a leak.curlcurl -H "Authorization: Bearer $PRIORCASE_KEY" \ 'https://priorcase.com/v1/search\ ?asset=BTC&at=2024-01-10T19:00:00Z&scale=15m&k=20'This is what makes a backtest honest: walk
atforward over your sample and no row can see its own future. Moments land on a five-minute grid, and a past one never changes, so cache the answer by(asset, at, scale, k)and never pay for it twice.Draw what followed
after.path_pctalready carries the shape: 64 points, one every 30 minutes, each in percent from the moment. To put several moments on one chart, including the window before each, send their times to/v1/paths.curlcurl -H "Authorization: Bearer $PRIORCASE_KEY" \ 'https://priorcase.com/v1/paths?asset=BTC&scale=15m\ &at=2020-03-20T21:00:00Z&at=2019-05-12T04:00:00Z'Every path comes back as percent from its own moment, so paths of different sizes lie on top of each other without scaling of your own. Read
offsetsas minutes from that moment: zero and below is the window, above zero is what followed.
When a call fails
| Code | Means | Do |
|---|---|---|
401 | The key is missing or not ours | Check the Authorization header. Authentication. |
429 | Out of answers, or too many at once | Sleep for Retry-After seconds and send it again. |
422 | The window has no market data | Move at to a moment the market was open. |
import time
def ask(params, tries=3):
for attempt in range(tries):
r = requests.get(URL, headers=HEAD, params=params,
timeout=30)
if r.status_code == 429:
# "rate" is a moment; "month" is the rest of the month.
if r.headers.get("X-Answers-Reason") == "month":
back = r.headers["X-Answers-Reset"]
raise RuntimeError(f"allowance gone until {back}")
time.sleep(int(r.headers.get("Retry-After", 5)))
continue
r.raise_for_status()
print(r.headers["X-Answers-Cost"], "spent,",
r.headers.get("X-Answers-Remaining"), "left")
return r.json()
raise RuntimeError("too many retries")Every error is JSON with a detail field that says what to do next. See limits and errors for the full list. A 503 costs you nothing: we count nothing when the engine does not answer.