Skip to content
Skip to Content
DalalOSdocs

Recipe

Screener app

Let a user set conditions on the market, see which companies meet them, and ask why one company is in or out. What you may do with the data is set by the terms.

What you will build

A form that builds conditions, a result table, and an explanation of why one company meets each condition or does not.

Before you start

  • An API key on a plan that includes the REST API. Create one on the keys page of your dashboard and set it as DALALOS_API_KEY.
  • Credits: each call costs credits from your plan. The limits say how many calls a run makes. Plans and credits are on Plans, credits and errors.
  • A screen query, for example a condition on return on capital employed.
  • One company from the result to explain.

Step 1: Metric registry

Read the list of metrics a screen can filter and sort on. Each entry in metrics has an id, a label, a unit and whether it is filterable and sortable. Build the form's fields from it, so a new metric shows up with no change to your code.

GET /ratios has the parameters, the errors and a box to send the call.

Metric registry
curl -H "Authorization: Bearer $DALALOS_API_KEY" "https://mcp.dalalos.in/v1/ratios"
{
  "status": "success",
  "data": {
    "registry_version": 1,
    "metrics": [
      {
        "id": "market_cap",
        "label": "Market cap",
        "description": "Latest close price multiplied by derived shares outstanding, in absolute rupees.",
        "value_type": "number",
        "unit": "currency_total",
        "filterable": true,
        "sortable": true,
        "engineering_status": "LIVE",
        "valid_company_types": [
          "general",
          "bank"
        ],
        "history_semantics": "raw_market",
        "aggregation_policy": "none",
        "formula_version": 1,
        "dependencies": [],
        "calculation_family": "market",
        "gallery_group": "price_market",
        "most_used_rank": 1,
        "short_label": "Mkt cap",
        "header_label": "Mkt cap (₹ Cr)",
        "plain_description": "The market value of all the company's shares: share price times the number of shares in issue.",
        "basis_text": "Latest closing share price multiplied by the number of shares in issue, in rupees. Held in rupees; the company page shows crore (1 crore = 10,000,000 rupees)…",
        "applies_to": [
          "general",
          "bank"
        ],
        "not_meaningful_when": null,
        "screener": {
          "primary_name": "Market Capitalization",
          "aliases": [],
          "negated_aliases": [],
          "status": "EXACT",
          "note": null,
          "surface_unit": "currency_crore",
          "storage_to_surface_factor": 1e-7
        }
      },
      {
        "id": "price",
        "label": "Current price",
        "description": "Latest end-of-day close price per share.",
        "value_type": "number",
        "unit": "currency_per_share",
        "filterable": true,
        "sortable": true,
        "engineering_status": "LIVE",
        "valid_company_types": [
          "general",
          "bank"
        ],
        "history_semantics": "raw_market",
        "aggregation_policy": "none",
        "formula_version": 1,
        "dependencies": [],
        "calculation_family": "market",
        "gallery_group": "price_market",
        "most_used_rank": 2,
        "short_label": "Price",
        "header_label": "Price (₹)",
        "plain_description": "The latest end-of-day closing price of one share.",
        "basis_text": "The last closing price recorded by the exchange, in rupees per share. It updates once a day after the close. Inputs: closing price. Unit: rupees per share. P…",
        "applies_to": [
          "general",
          "bank"
        ],
        "not_meaningful_when": null,
        "screener": {
          "primary_name": "Current price",
          "aliases": [],
          "negated_aliases": [],
          "status": "EXACT",
          "note": null,
          "surface_unit": "currency_per_share",
          "storage_to_surface_factor": 1
        }
      }
    ]
  },
  "cached_at": null,
  "source": "indian-stock-mcp",
  "stale": false,
  "error": null,
  "reason_code": null
}

Saved answer. Run on 2026-11-27, answered 200. Lists show their first item in full; the other items and long text are shortened. A call you make now gets the current answer.

Feeds the next step: The metric id and label your form offers.

Step 2: Screen with a free-form query

Run a screen from a query written as text. The rows are in results, and pagination says how many matched (total_matches) and which snapshot the screen ran against: the nightly set of screener figures. Keep snapshot_id, so a follow-up call reads the same figures.

POST /screen/query has the parameters, the errors and a box to send the call.

Screen with a free-form query
curl -X POST -H "Content-Type: application/json" -d '{"query":"Return on capital employed > 22% AND Market Capitalization > 500","dialect":"screener","sort_by":"market_cap","order":"desc","limit":10,"include_condition_counts":true}' -H "Authorization: Bearer $DALALOS_API_KEY" "https://mcp.dalalos.in/v1/screen/query"
{
  "status": "success",
  "data": {
    "query": "Return on capital employed > 22% AND Market Capitalization > 500",
    "dialect": "screener",
    "sort_by": "market_cap",
    "order": "desc",
    "columns": [],
    "referenced_metrics": [
      "roce"
    ],
    "definitions": [],
    "scope": {},
    "latest_results": {
      "applied": false,
      "period_end": null,
      "companies_reported": null
    },
    "implausible_rule": {
      "version": 1,
      "bounds": {
        "deliv_pct": {
          "min": 0,
          "max": 100
        },
        "promoter_pct": {
          "min": 0,
          "max": 100
        },
        "pledged_pct": {
          "min": 0,
          "max": 100
        },
        "piotroski_f_score": {
          "min": 0,
          "max": 9
        },
        "return_1y": {
          "min": -1,
          "max": 50
        },
        "revenue_growth": {
          "min": -1,
          "max": 50
        },
        "net_income_growth": {
          "min": -100,
          "max": 100
        },
        "roe": {
          "min": -10,
          "max": 10
        },
        "roa": {
          "min": -10,
          "max": 10
        },
        "roce": {
          "min": -10,
          "max": 10
        },
        "net_margin": {
          "min": -10,
          "max": 10
        },
        "operating_margin": {
          "min": -10,
          "max": 10
        },
        "ebitda_margin": {
          "min": -10,
          "max": 10
        },
        "earnings_yield": {
          "min": -10,
          "max": 1
        },
        "fcf_yield": {
          "min": -10,
          "max": 1
        },
        "debt_to_equity": {
          "min": -100,
          "max": 100
        },
        "interest_coverage": {
          "min": -100000,
          "max": 100000
        },
        "ev_to_ebitda": {
          "min": -1000,
          "max": 1000
        },
        "ev_to_ebit": {
          "min": -1000,
          "max": 1000
        },
        "price_to_sales": {
          "min": 0,
          "max": 1000
        }
      }
    },
    "results": [
      {
        "isin": "INE397D01024",
        "nse_symbol": "BHARTIARTL",
        "name": "Bharti Airtel Limited",
        "sector": "Telecommunication",
        "industry": "Telecom - Cellular & Fixed line services",
        "company_type": "general",
        "price": 2067.9,
        "market_cap": 13120653476500,
        "pe": 40.7461,
        "pb": 8.3021,
        "deliv_pct": 62.26,
        "week52_high": 2172.9,
        "week52_low": 1726.3,
        "turnover": 7511679538.8,
        "num_trades": 143700,
        "roe": 0.2361,
        "roa": 0.0721,
        "roce": 0.2779,
        "net_margin": 0.1657,
        "operating_margin": 0.3189,
        "ebitda_margin": 0.5767,
        "debt_to_equity": 0.7664,
        "interest_coverage": 3.2334,
        "ev": 14257481476500,
        "ev_to_ebitda": 10.9727,
        "ev_to_ebit": 19.2615,
        "earnings_yield": 0.0519,
        "fcf_yield": 0.0587,
        "price_to_sales": 5.6519,
        "revenue_growth": 0.2247,
        "net_income_growth": -0.0976,
        "return_1y": -0.0114,
        "promoter_pct": 50.07,
        "pledged_pct": 0,
        "piotroski_f_score": 6,
        "equity_latest": 1580470000000,
        "profit_after_tax_ttm": 384722000000,
        "dividend_yield": 0.0116059770782,
        "pct_off_52w_low": 0.197879858657
      }
    ],
    "pagination": {
      "limit": 10,
      "offset": 0,
      "returned": 10,
      "total_matches": 491,
      "has_more": true,
      "snapshot_id": 100
    },
    "snapshot": {
      "id": 100,
      "computed_at": "2026-11-26 16:20:31",
      "row_count": 6031,
      "registry_version": 1
    },
    "compatibility": {
      "dialect": "screener",
      "diagnostics": []
    },
    "condition_counts": {
      "available": true,
      "universe": 6063,
      "conditions": [
        {
          "index": 0,
          "text": "Return on capital employed > 22%",
          "metric_ids": [
            "roce"
          ],
          "before": 6063,
          "after": 715,
          "alone": 715,
          "fail_only": 1560,
          "removed": {
            "failed": 2883,
            "missing": 1921,
            "not_applicable": 544
          },
          "unknown_alone": {
            "missing": 1921,
            "not_applicable": 544
          },
          "nearest": {
            "direction": "highest",
            "operator": ">",
            "threshold": 0.22,
            "value": 0.22,
            "unit": "percentage",
            "surface_scale": 100,
            "candidates": 2883,
            "company": {
              "isin": "INE288B01029",
              "nse_symbol": "DEEPAKNTR",
              "name": "Deepak Nitrite Limited"
            }
          }
        }
      ],
      "most_removed_index": 0,
      "most_restrictive_index": 0,
      "emptied_at_index": null
    }
  },
  "cached_at": "2026-11-27T14:48:27+00:00",
  "source": "indian-stock-mcp",
  "stale": false,
  "error": null,
  "reason_code": null,
  "data_age_seconds": 3866.426,
  "as_of": "2026-11-26",
  "freshness": {
    "version": 1,
    "stale": true,
    "price": {
      "basis": "end_of_day",
      "session": "2026-11-26",
      "market_latest_session": "2026-11-27",
      "status": "behind_latest_session"
    },
    "metrics": {
      "computed_at": "2026-11-26T16:20:31+00:00",
      "results_season_period_end": "2026-09-30"
    },
    "reason_codes": [
      "end_of_day_price"
    ],
    "reason_text": "Prices are closing prices for Thursday 26 Nov 2026, not live."
  }
}

Saved answer. Run on 2026-11-27, answered 200. The API marked it stale ("stale": true): it answered from its last stored copy because a newer one was not available. Lists show their first item in full; the other items and long text are shortened. A call you make now gets the current answer.

Feeds the next step: A list of companies, and the snapshot_id.

Step 3: Why one company is in or out of a screen

Pick one company from the result and ask why it is in or out. Send the same query, the company, and the snapshot_id from step 2. in_screen says whether it is in, and each entry in checks gives the label, the value_text and whether the company meets that condition.

POST /screen/explain has the parameters, the errors and a box to send the call.

Why one company is in or out of a screen
curl -X POST -H "Content-Type: application/json" -d '{"query":"Return on capital employed > 22% AND Market Capitalization > 500","company":"RELIANCE","dialect":"screener"}' -H "Authorization: Bearer $DALALOS_API_KEY" "https://mcp.dalalos.in/v1/screen/explain"
{
  "status": "success",
  "data": {
    "dialect": "screener",
    "query": "Return on capital employed > 22% AND Market Capitalization > 500",
    "company": {
      "isin": "INE002A01018",
      "symbol": "RELIANCE",
      "name": "Reliance Industries Limited",
      "company_type": "general"
    },
    "in_universe": true,
    "in_screen": false,
    "checks": [
      {
        "id": "c-5fa03033",
        "kind": "range",
        "text": "Return on capital employed > 22%",
        "indexes": [
          0
        ],
        "meets": false,
        "metric_id": "roce",
        "label": "Return on capital employed",
        "value": 12.65,
        "value_text": "12.65%",
        "unit": "percentage",
        "unit_kind": "percent",
        "surface_scale": 100,
        "missing": null,
        "value_flags": [],
        "as_of": "Sep 2026 results, filed 30 Oct",
        "as_of_detail": {
          "basis": "quarterly_filing",
          "period_end": "2026-09-30",
          "filed_on": "2026-10-30"
        },
        "inputs": [
          {
            "metric_id": "roce",
            "label": "Return on capital employed",
            "value": 12.65,
            "value_text": "12.65%",
            "unit": "percentage",
            "unit_kind": "percent",
            "surface_scale": 100,
            "missing": null,
            "value_flags": [],
            "as_of": "Sep 2026 results, filed 30 Oct",
            "as_of_detail": {
              "basis": "quarterly_filing",
              "period_end": "2026-09-30",
              "filed_on": "2026-10-30"
            }
          }
        ]
      },
      {
        "id": "c-713a6e7f",
        "kind": "range",
        "text": "Market Capitalization > 500",
        "indexes": [
          1
        ],
        "meets": true,
        "metric_id": "market_cap",
        "label": "Market cap",
        "value": 1889413.05637,
        "value_text": "₹18,89,413 cr",
        "unit": "currency_crore",
        "unit_kind": "crore",
        "surface_scale": 1e-7,
        "missing": null,
        "value_flags": [],
        "as_of": "Prices as of 27 Nov 2026",
        "as_of_detail": {
          "basis": "quote",
          "period_end": null,
          "filed_on": null
        },
        "inputs": [
          {
            "metric_id": "market_cap",
            "label": "Market cap",
            "value": 1889413.05637,
            "value_text": "₹18,89,413 cr",
            "unit": "currency_crore",
            "unit_kind": "crore",
            "surface_scale": 1e-7,
            "missing": null,
            "value_flags": [],
            "as_of": "Prices as of 27 Nov 2026",
            "as_of_detail": {
              "basis": "quote",
              "period_end": null,
              "filed_on": null
            }
          }
        ]
      }
    ],
    "snapshot": {
      "id": 100,
      "computed_at": "2026-11-26 16:20:31"
    },
    "listing_note": "Listed on NSE and BSE. Prices are from NSE."
  },
  "cached_at": null,
  "source": "indian-stock-mcp",
  "stale": false,
  "error": null,
  "reason_code": null
}

Saved answer. Run on 2026-11-27, answered 200. A call you make now gets the current answer.

The full script

Python 3 with the requests package. It reads your key from DALALOS_API_KEY, waits once when the API asks it to slow down, stops with a plain message on 401, 402 and 403, and prints what it reads.

screener_app.py
import json
import os
import sys
import time

import requests

BASE = "https://mcp.dalalos.in/v1"
HEADERS = {"Authorization": "Bearer " + os.environ["DALALOS_API_KEY"]}


def call(method, path, **kwargs):
    """One request. Waits once on a 429. Stops with a plain message on 401, 402 and 403."""
    for attempt in range(2):
        response = requests.request(method, BASE + path, headers=HEADERS, timeout=30, **kwargs)
        if response.status_code == 429 and attempt == 0:
            time.sleep(float(response.headers.get("Retry-After", "2")))
            continue
        break
    if response.status_code == 401:
        sys.exit("401: the key is missing or not valid. Create one at https://dalalos.in/dashboard/keys")
    if response.status_code == 402:
        sys.exit("402: the monthly credits are used up.")
    if response.status_code == 403:
        sys.exit("403: this plan does not include the REST API.")
    response.raise_for_status()
    return response.json()


def show(title, answer, limit=1200):
    print("==", title)
    print(json.dumps(answer, indent=2)[:limit])


QUERY = "Return on capital employed > 22% AND Market Capitalization > 500"
COMPANY = "RELIANCE"  # one company from the result, chosen by your user

metrics = call("GET", "/ratios")["data"]["metrics"]
print("metrics a screen can use:", [m["id"] for m in metrics][:10], "...")

result = call("POST", "/screen/query", json={"query": QUERY, "dialect": "screener", "limit": 10})["data"]
page = result["pagination"]
print(page["total_matches"], "companies match; showing", page["returned"], "from snapshot", page["snapshot_id"])
show("first rows", result["results"][:2], limit=800)

body = {"query": QUERY, "dialect": "screener", "company": COMPANY, "snapshot_id": page["snapshot_id"]}  # the same figures the screen used
explain = call("POST", "/screen/explain", json=body)["data"]
print(COMPANY, "is in the screen:", explain["in_screen"])
for check in explain["checks"]:
    print("-", check["label"], check["value_text"], "meets" if check["meets"] else "does not meet", "the condition")

Limits

  • A run makes three calls, each charged in credits from your plan.
  • Both calls need the same query text and the same dialect. Metric ids are not the same in the two dialects: /ratios lists the ids and the labels.
  • A snapshot is replaced when the nightly refresh publishes new figures. A call that pins an old one answers 409 snapshot_expired: run the query again.
  • Before the first nightly refresh is published, screen calls answer 503 snapshot_unavailable.

Extend it

  • Add POST /screen/conditions to turn the query text into editable conditions and back.
  • Add GET /screen/field-stats for the range of each metric, to size a slider.
  • Add GET /screen/data-as-of for a "data as of" line, and GET /presets for ready-made starting screens.
  • More routes: Screen stocks.

KEEP EXPLORING