priorcase
priorcase

Sign in

To make a key, and to see what yours have spent.

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.

  1. 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.

    curl
    curl 'https://priorcase.com/v1/search?asset=BTC'
    
    curl 'https://priorcase.com/v1/after/cpi?asset=BTC&alike=now'
  2. 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.

    shell
    export PRIORCASE_KEY="pc_live_…"
  3. 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.

    curl
    curl -H "Authorization: Bearer $PRIORCASE_KEY" \
      'https://priorcase.com/v1/search?asset=BTC&scale=15m&k=8'
    python
    import 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.

    scale sets 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.

  4. 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 query as the moment you asked about, and matches as the past moments that resemble it, ordered by similarity.

    Every moment comes in two parts. then is the market data as of that moment, after is what happened in the 32 hours that followed, measured from then.close. We never combine the two, and the moment you asked about carries after: null because it has not happened yet.

    Treat similarity as 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. Read after.ret_32h_pct on a match, never the two closes.

  5. Decide whether the answer is worth anything

    Read quality for how much weight the set carries. It never says up or down. Start with range_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.

    python
    q = 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 k is noisy: measured on BTC at 15m, the median spread was 4.73pp at k=8, 1.28pp at k=20 and 0.75pp at k=50. Every reply carries X-Answers-Cost and X-Answers-Remaining, so you never have to guess what a run has spent. See limits and errors.

  6. Ask about a past moment

    Pass at and 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.verified says the engine checked. It refuses rather than return a leak.

    curl
    curl -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 at forward 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.

  7. Draw what followed

    after.path_pct already 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.

    curl
    curl -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 offsets as minutes from that moment: zero and below is the window, above zero is what followed.

When a call fails

CodeMeansDo
401The key is missing or not oursCheck the Authorization header. Authentication.
429Out of answers, or too many at onceSleep for Retry-After seconds and send it again.
422The window has no market dataMove at to a moment the market was open.
python
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.

The full reference →