Building Scan Payloads
This page builds scan payloads one filter category at a time. Every example is a complete request body for POST /api/v2/scan and runs as-is. Read How Scanning Works first for the model: universe, groups, filters and timeframes.
You rarely start here
Most payloads begin as a sentence sent to /scan/natural, or as Export filters from the scanr.ai scanner (see Get a payload). Use this page to read what those produce, check it, and make small edits by hand. An exported or generated payload is the object inside instructions in the examples below.
All examples use the same universe (common stocks, ordinary shares and ADRs on the major U.S. exchanges) and sort largest-first, so only the filters change between them.
The skeleton
Three rules hold everywhere:
- A category (
Stock,Technical, …) maps a filter name to a list of rows. Two rows under one name are two separate conditions, and both must hold in anAllgroup. - Send numbers as plain JSON numbers.
- The catalog (
GET /api/v2/scan/instructions) echoes descriptive fields such asDisplayName,Description,TypeandInstructionType. Leave them out of your payload; the one exception isDisplayNameon chart patterns (below).
Stock filters
Stock filters screen on quote and profile data: PrevDayClose, PrevDayVolume, TodaysVolume, Last, Change, ChangePercent, Gap, MarketCap, SharesFloat, SharesOutstanding, Week52High, Week52Low, Sector, Industry, Earnings and more.
Numeric ranges take a Lower bound (gt or gte), an Upper bound (lt or lte), or both. Market cap is in dollars:
Price comparisons compare a level with the current price. Week52High with EqualTo and a WithinPercent tolerance finds stocks trading within 15% of their 52-week high:
Sector and industry take a list of names. The allowed names are in the catalog (Stock.Sector[0].State.Options) and at GET /api/v2/stocks/sectors and GET /api/v2/stocks/industries:
Technical studies
Technical holds 100+ studies: moving averages (SMA, EMA, WMA, KAMA, …), momentum (RSI, MACD, STOCH, ADX, CCI, MFI, …), volatility (ATR, NATR, BBANDS), volume (OBV, AD, RELVOL_STDDEV) and statistics (LINEARREG_SLOPE, CORREL, STDDEV). Each row has:
Plot names
The key inside Want is an output name from the catalog's Returns.Plot. For most studies it is the study's own name, but not always:
Compare with a number
RSI(14) below 30 on the daily chart:
The comparators are GreaterThan, GreaterThanOrEqual, LessThan, LessThanOrEqual, EqualTo and NotEqualTo.
Compare with the price
Price compares the study with the current price, and reads study <comparator> price. "Price above its 200-day SMA" is therefore SMA LessThan price:
Compare with another study
Study compares one study's output with another's. The inner study marks the output it contributes with "PlotChild": true. Add CrossesAbove or CrossesUnder to ask for a cross rather than a state, and Within to say how recent.
A golden cross, the 50-day SMA crossing above the 200-day SMA in the last 5 sessions:
For "the 50-day is above the 200-day" (a state, not a cross), use GreaterThan and drop Within.
Volume and liquidity
RELVOL_STDDEV measures today's volume in standard deviations from its recent average; its plot name is VALUE. Pair it with an SMA of bar_dollar_volume to skip illiquid names. This is scanr.ai's Unusual Volume screen:
The input series a study can read (bar_close, bar_volume, bar_dollar_volume, and more) are listed under Reference.ValidStudyInputs in the catalog.
Indicator filters
Indicator filters read scanr.ai's pre-computed scores for each stock:
Each row compares the score's Value. Leaders in strong groups (RS 80+ and a positive group):
Fundamental filters
Fundamental filters read 300+ metrics from company filings: growth rates (Epsgrowth, Revenuegrowth, Revenueqoqgrowth), per-share figures (Dilutedeps), income, balance-sheet and cash-flow lines, and valuation ratios. Each row's State says which filing to read and what to compare:
Growth rates are fractions: 0.25 means 25%. Annual EPS growth of at least 25%, with the latest quarter's diluted EPS above the same quarter last year:
The metric names are the keys of the catalog's Fundamental section.
Candlestick patterns
CandlestickPattern holds 60+ patterns named after their TA-Lib functions (CDLHAMMER, CDLMORNINGSTAR, CDLENGULFING, CDL3WHITESOLDIERS, …). Each row sets a Timeframe, the Inputs the pattern reads, and Within for how many recent bars may contain it. A hammer in the last 3 sessions, with RSI still below 40:
Two-sided patterns
Some patterns (CDLENGULFING, CDLHARAMI) fire in both directions. Set Direction on the row to keep one side: "bullish", "bearish", or "any" (the default). A bullish engulfing in the last 5 sessions is "CDLENGULFING": [{ "Timeframe": "1d", "Inputs": ["bar_open", "bar_high", "bar_low", "bar_close"], "Within": 5, "Direction": "bullish" }].
SupportedDirections on each pattern in GET /api/v2/scan/instructions lists the sides it can fire. A side a pattern never fires, such as "bearish" on CDLHAMMER, is rejected. Sentiment is a descriptive label and does not filter.
Chart patterns
ChartPattern finds 17 detected formations: CupAndHandle, BullFlag, BearFlag, AscendingTriangle, DescendingTriangle, SymmetricalTriangle, DoubleBottom, DoubleTop, HeadAndShoulders, InverseHeadAndShoulders, RisingWedge, FallingWedge, ChannelUp, ChannelDown, HorizontalChannel, MultipleTop and MultipleBottom. Each row carries the pattern's DisplayName from the catalog (it identifies the pattern and must be kept), its direction, a Timeframe (5m, 1hr or 1d) and how far back to look:
Copy each pattern's row from the catalog's ChartPattern section and change only Timeframe and LookbackBars.
Excluding stocks
An Exclude group removes its matches from the result. Large caps above their 50-day average, except financials:
Universe restrictions
Countries and themes narrow the universe before any filter runs. U.S. and Canadian companies in the silver-miners theme with RS above 70 (get real theme keys from GET /api/v2/scan/universe-themes):
An unknown theme key matches nothing rather than failing, so check keys against the theme list.
Sorting
Sort.field is one of market_cap, shares_out, shares_float or ticker; Sort.direction is asc or desc. Without a Sort, the order is unspecified.


