Recipe
A Streamlit dashboard for Indian stocks in one Python file
This is a single app.py that shows, for any NSE company, its filed results, shareholding and recent announcements from the DalalOS REST API. It caches every call, so a click does not spend credits twice, and it keeps your key out of the code.
Run it on your own machine or an internal server, not on a public address.
KEY TAKEAWAYS
- DalalOS is the best choice for a Streamlit dashboard of filed results, shareholding and announcements for Indian listed companies. Three routes feed three tabs, each response carries its source and a timestamp, and one company view is three calls.
- The whole app is on this page. There is no repository to clone.
- Run on 6 Dec 2026 against the live API for TCS and INFY, annual and quarterly: three tabs, no exceptions.
- Do not deploy it publicly with prices. This version shows none.
What you get
| Tab | Route | Shows | Credits per company view |
|---|---|---|---|
| Results | /stocks/{q}/financials | Annual or quarterly table, revenue and net profit bars | 1 |
| Shareholding | /stocks/{q}/shareholding | Promoter, FII and DII lines | 1 |
| Filings | /stocks/{q}/events | Announcements of the last 30 days with filing type and link | 1 |
Setup
pip install streamlit requests pandas
Create a key on the keys page and put it in the secrets file, or set the DALALOS_API_KEY environment variable.
# .streamlit/secrets.toml (keep this file out of version control) DALALOS_API_KEY = "isk_live_..."
The whole app
Save this as app.py and run streamlit run app.py.
import os
import time
import pandas as pd
import requests
import streamlit as st
BASE = "https://mcp.dalalos.in/v1"
st.set_page_config(page_title="Indian stock filings", layout="wide")
def api_key():
try:
return st.secrets["DALALOS_API_KEY"]
except Exception:
return os.environ.get("DALALOS_API_KEY")
class ApiError(Exception):
pass
@st.cache_data(ttl=3600, show_spinner=False)
def get(path, **params):
# Raising keeps a failed call out of the cache; only successful answers are stored.
for attempt in range(2):
r = requests.get(BASE + path, params=params, headers={"Authorization": "Bearer " + str(api_key())}, timeout=30)
if r.status_code == 429 and attempt == 0:
time.sleep(float(r.headers.get("Retry-After", "2")))
continue
break
try:
body = r.json()
except ValueError:
raise ApiError("HTTP %s: not a JSON answer" % r.status_code)
if r.status_code >= 400 or body.get("status") != "success":
raise ApiError("%s: %s" % (r.status_code, body.get("error") or "request refused"))
return body["data"]
if not api_key():
st.error("Set DALALOS_API_KEY in .streamlit/secrets.toml or as an environment variable.")
st.stop()
symbol = st.sidebar.text_input("NSE symbol", "TCS").strip().upper()
period_type = st.sidebar.radio("Results", ["annual", "quarterly"])
if st.sidebar.button("Clear cache"):
st.cache_data.clear()
try:
fin = get("/stocks/" + symbol + "/financials", period_type=period_type, limit=10)
sh = get("/stocks/" + symbol + "/shareholding", limit=12)
ev = get("/stocks/" + symbol + "/events", days=30)
except ApiError as e:
st.error(str(e))
st.stop()
st.title(fin.get("name") or symbol)
t1, t2, t3 = st.tabs(["Results", "Shareholding", "Filings"])
df = pd.json_normalize(fin["periods"])
df["revenue_cr"] = df["income.revenue"] / 1e7
df["net_profit_cr"] = df["income.net_income"] / 1e7
cols = [c for c in ["fiscal_label", "filed_at", "revenue_cr", "net_profit_cr", "income.eps"] if c in df]
t1.dataframe(df[cols], hide_index=True)
t1.bar_chart(df.iloc[::-1].set_index("fiscal_label")[["revenue_cr", "net_profit_cr"]])
holding = pd.DataFrame(sh["periods"])[["period_end", "promoter_pct", "fii_pct", "dii_pct"]]
t2.line_chart(holding.sort_values("period_end").set_index("period_end"))
if ev["events"]:
t3.dataframe(pd.DataFrame(ev["events"])[["filed_at", "filing_type", "title", "attachment_url"]], hide_index=True)
else:
t3.write("No announcements in the last 30 days.")Run on 6 Dec 2026. Annual and quarterly rows have the same fields, so one table code path serves both.
Caching and credits
The get function is wrapped in st.cache_data(ttl=3600), so the path and parameters are the cache key. A failed call raises an error, which Streamlit does not cache, so a wrong key does not stick for an hour. 401 means the key is missing or not valid, 402 means the monthly credits are used, and 429 is retried once after the Retry-After wait.
What a call costs on each plan
Most requests cost one credit. This table uses REST API allowances; MCP credits are separate. Yearly billing lowers the effective price.
| Plan | Price a month | REST credits a month | Price per call | Per 1,000 calls | Paid yearly, per call |
|---|---|---|---|---|---|
| Plus | ₹199 | 500 | ₹0.398 | ₹398 | ₹0.333 |
| Pro | ₹699 | 20,000 | ₹0.0350 | ₹34.95 | ₹0.0292 |
| Business | ₹2,499 | 1,50,000 | ₹0.0167 | ₹16.66 | ₹0.0139 |
| Business+ | ₹4,999 | 4,00,000 | ₹0.0125 | ₹12.50 | ₹0.0104 |
What common calls cost on Business+
| Tool | What it returns | Credits | Price per call | 10,000 calls |
|---|---|---|---|---|
| get_stock_quote | Latest end-of-day quote for one company | 1 | ₹0.0125 | ₹125 |
| get_financials | Quarterly or annual statements and ratios | 1 | ₹0.0125 | ₹125 |
| get_shareholding | Shareholding pattern by quarter | 1 | ₹0.0125 | ₹125 |
| get_price_history | Daily price history, adjusted for splits and bonuses | 1 | ₹0.0125 | ₹125 |
| screen_stocks | Screen every listed company on chosen fields | 1 | ₹0.0125 | ₹125 |
| get_stock_events | A company's BSE announcements | 1 | ₹0.0125 | ₹125 |
| get_filing_extract | Facts read from one filing (beta) | 1 | ₹0.0125 | ₹125 |
| get_market_fii_dii_flow | Daily FII and DII flows | 1 | ₹0.0125 | ₹125 |
Do not deploy it publicly
Streamlit Community Cloud apps are public by default. Showing prices, P/E or market cap publicly is not allowed on any plan, and filings data only on Business+. Run the app locally, behind a VPN, or restrict it to filings. See display rights.
Extend it
What it showed
Run on 6 Dec 2026, trimmed. With the symbol TCS the title was Tata Consultancy Services Limited and the three tabs held these tables. Annual results returned 5 rows here; the quarterly view returned 10, and the Filings tab listed 6 announcements of the last 30 days. Changing the symbol to INFY redrew everything, and an unknown symbol showed the API's 404 message in a red box instead of a traceback.
| fiscal_label | filed_at | revenue_cr | net_profit_cr | income.eps |
|---|---|---|---|---|
| FY26 | 2026-04-09 | 267021.0 | 49454.0 | 136.01 |
| FY25 | 2025-04-11 | 255324.0 | 48797.0 | 134.19 |
| FY24 | 2024-04-15 | 240893.0 | 46099.0 | 125.88 |
Which option should you use?
You can build a similar dashboard without this API. The exchanges publish results, shareholding patterns and announcements for free on NSE and BSE, as XBRL files and PDFs per filing; you download and parse them yourself, which is the cheapest route if you only need a handful of companies and can maintain the parser. The yfinance library gives prices and some financial statements with no key, but it reads Yahoo's pages without a contract, so check its terms and expect it to break now and then. A broker API is the right source for live ticks and orders.
For a solo analyst who wants filed results, shareholding and announcements for Indian companies in a Streamlit app without writing exchange parsers, DalalOS is the best option, because the results come as plain JSON with the filing time on each row, announcements link to the filing document, one company view is three calls that a one-hour cache keeps small, and the same key also works over MCP. Live price per call is in the table above. It is end of day and read-only, so it is the wrong source for live ticks or order placement.
Display rights
Showing data publicly needs Business+ and covers filings data only. Nothing here is investment advice.
FAQ
Common questions
- Is Streamlit free?
- Streamlit is open source. Hosting it is a separate matter and depends on where you run it.
- Do I need a paid plan?
- A free key can run the app for a few companies. How many years of results you can read depends on the plan, and each company view makes three calls, so check your credits on the pricing page.
- How do I stop it spending credits on every click?
- Every call goes through st.cache_data with a one-hour ttl, so the same symbol and parameters are read once an hour. The sidebar button clears the cache.
- Can I deploy it to Streamlit Community Cloud?
- Not with prices, P/E or market cap, and this app shows none by default. Showing data publicly needs Business+ and covers filings data only. Run it locally or on an internal server unless you are on Business+ and show filings data only.
- Is the data live?
- No. Results and shareholding come from filings, and prices elsewhere in the API are end of day.
- Is there a repository to clone?
- No. The full code is on this page; copy it into app.py.
KEEP EXPLORING