APIs16 min read

How to Build n8n Market Automations with Indian Stock Market APIs

By Deion DSouza
Blue n8n workflow logo on a white card over a pale grid

You do not need to write a full market-monitoring service to turn Indian stock market data into useful alerts. n8n can handle the schedule, API call, filtering, delivery, storage, and failure notifications.

The basic pattern is:

Basic n8n market automation: schedule, call a market API, normalize, notify and log

This guide includes a tested REST workflow for setup checks, backfills, and recovery after downtime. It fetches important NSE/BSE announcements, prepares an alert message, and stores each event in an n8n Data Table.

This guide uses Drishti throughout. Its announcement endpoint returns structured Indian-market events over a normal REST API, so n8n can fetch and route them without scraping exchange pages.

Best practice: use the Drishti WebSocket for ongoing market-data tracking. New events are pushed to your subscriber as they become available. Use REST polling only for testing, backfilling a time range, or recovering events missed during downtime.

Download the tested n8n template

Download the Drishti NSE/BSE announcement monitor JSON.

The template is deliberately inactive when imported. Create a free Drishti account, save its API key in a Header Auth credential with the header name X-API-Key, and select it in Fetch Drishti announcements. Then create the Data Table described below and select it in Store new announcement. Keep Every 15 minutes on weekdays disabled unless you are running a short test or recovery job. No secret or account-specific table ID is stored in the JSON.

The workflow was validated by n8n before creation. A pinned API response then passed through normalization, processed-ID tracking, alert formatting, and a real Data Table insert. Replaying the same event ID produced no second insert.

What you are building

The tested workflow has seven nodes:

  1. Manual Trigger for setup tests
  2. Disabled Schedule Trigger for temporary testing or recovery
  3. HTTP Request to Drishti
  4. Code to normalize the response
  5. Processed-ID check for overlapping polling runs
  6. Set to build an alert-ready payload
  7. Data Table to store each new event

The workflow monitors information. It does not place trades, predict returns, or recommend what to buy or sell.

When to use Drishti

Use Drishti when the workflow needs Indian-market data that Drishti already provides. Use a broker API only when the workflow needs access to a brokerage account or needs to place an order.

What your workflow needsUseWhat it gives n8n
NSE/BSE announcements, earnings, news, concalls, block deals, or alertsDrishti REST APIDocumented endpoints that n8n can call with its HTTP Request node
Near-live announcements, earnings, news, concalls, block deals, or alertsDrishti WebSocketNew records pushed to your subscriber, which can forward them to an n8n Webhook
Price, relative-volume, unusual-volume, earnings, high-growth-concall, or 52-week high/low alert eventsDrishti Alerts REST APIA paginated alert feed that n8n can filter by symbol, type, date, or the important feed
Historical closing price and volume, standalone 52-week context, top movers, top-traded stocks, or deeper company and sector researchDrishti MCPDedicated MCP tools for these datasets; these are not public Drishti REST routes
Company name, logo, sector, market cap, scrip code, or ISINDrishti Symbols REST APIMetadata for a bounded list of symbols or scrip codes
A daily watchlist or internal market reportDrishti + n8nChoose Drishti REST for the documented event feeds, or Drishti MCP for the MCP-only datasets; n8n schedules and delivers the result
Orders, positions, holdings, or brokerage-account dataYour broker's APIAccount-specific trading and portfolio actions; Drishti does not place orders or manage brokerage accounts

If your job matches a Drishti row, create a free Drishti account. For announcements, start with the downloadable workflow below.

For this tutorial, create a Drishti API key in the platform console and keep it in n8n's credential store. Do not paste a real key into a Code node, expression, exported workflow, or screenshot.

How to build the workflow in seven steps

  1. Set the workflow timezone and schedule.
  2. Add the market API request.
  3. Normalize the API response.
  4. Prevent repeat alerts from overlapping runs.
  5. Build an alert-ready payload.
  6. Store each new event.
  7. Add retries, an error workflow, and a heartbeat.

1. Set the workflow timezone and temporary polling schedule

Open the workflow settings and set the timezone to Asia/Kolkata. This matters because n8n's Schedule Trigger uses the workflow timezone when one is set; otherwise it falls back to the instance timezone. A self-hosted instance can default to a different region.

The downloadable template includes a disabled Schedule Trigger with this custom cron expression:

Code
*/15 * * * 1-5

If enabled, it runs every 15 minutes from Monday to Friday. Use it only while testing the REST workflow or recovering a missed time range.

Do not leave this polling schedule running as your production market tracker. For ongoing tracking, connect the Drishti WebSocket to an n8n Webhook as shown later in this guide.

2. Add the market API request

Add an HTTP Request node named Fetch announcements. n8n's HTTP Request node can call any REST API and supports query parameters, headers, batching, pagination, response handling, and timeouts.

Configure it like this:

SettingValue
MethodGET
URLhttps://developers.manasija.in/v1/announcements
AuthenticationGeneric Credential Type -> Header Auth
Header nameX-API-Key
Header valueYour saved Drishti credential
Response formatJSON

Add these query parameters:

NameValue
symbolsRELIANCE,TCS
detailedfalse
from{{ $now.minus({ minutes: 20 }).toUTC().toISO() }}
to{{ $now.toUTC().toISO() }}
limit20

When the temporary schedule is enabled, it runs every 15 minutes while the request looks back 20 minutes. That five-minute overlap protects a test or recovery run from small scheduling delays. Drishti assigns unique event IDs, but overlapping request windows can return the same valid event in two consecutive runs. The template remembers processed IDs so n8n does not act on that event twice.

Start with two or three symbols. Drishti accepts up to 20 symbols on this endpoint, and its announcement list is billed per returned item. A tight watchlist and a narrow time window make the workflow cheaper and easier to inspect.

Run this node once. A successful response contains a data array and a has_next flag. Summary rows include fields such as id, symbol, company_name, date, summary, and category. List responses do not include attachment URLs.

3. Normalize the API response

Add a Code node named Normalize announcements. Leave it in Run Once for All Items mode and use this JavaScript:

Code
const response = $input.first().json;
const rows = Array.isArray(response.data) ? response.data : [];

return rows
  .filter((row) => row.id && row.date)
  .map((row) => ({
    json: {
      event_id: row.id,
      symbol: row.symbol ?? "UNKNOWN",
      company: row.company_name ?? row.symbol ?? "Unknown company",
      category: row.category ?? "Company update",
      summary: row.summary ?? "No summary available",
      published_at: row.date,
      source: "Drishti",
    },
  }));

This gives every downstream node the same small schema. Keeping the Drishti field mapping in one node also makes the rest of the workflow easier to maintain.

Do not let missing IDs continue. The event ID is the idempotency key that stops the workflow from sending the same announcement again.

4. Prevent repeat alerts from overlapping runs

Drishti does not return duplicate announcement records. Each announcement has a unique event ID.

The repeat can happen inside this workflow because it runs every 15 minutes but checks the previous 20 minutes. Those two time windows overlap by five minutes, so the same valid announcement can appear in two consecutive API responses.

Add n8n's Remove Duplicates node after normalization and configure it like this:

SettingValue
OperationRemove Items Processed in Previous Executions
Keep Items WhereValue Is New
Value to Dedupe Onevent_id
ScopeNode

This node remembers which event IDs n8n has already processed. It prevents a repeated alert caused by the overlapping schedule; it is not fixing Drishti data.

5. Build the alert-ready payload

Add an Edit Fields (Set) node named Build alert-ready payload. Keep the normalized fields and add alert_text plus stored_at.

A compact message is easier to scan:

Code
{{$json.company}} ({{$json.symbol}})
{{$json.category}}

{{$json.summary}}

Published: {{$json.published_at}}
Event ID: {{$json.event_id}}

The template stops at an alert-ready object instead of guessing your destination. Connect Slack, Telegram, email, or a webhook after this node if you want delivery. Keep deterministic filtering before any LLM step; use AI only for a narrow job such as shortening a long summary.

6. Store each new event

Create an n8n Data Table named drishti_announcement_monitor_events with these columns:

  • event_id (string)
  • symbol
  • company
  • category
  • summary
  • published_at (date)
  • alert_text
  • source
  • stored_at (date)

Add a Data Table node named Store new announcement, select that table, choose Insert, and map the fields with the same names. The downloadable JSON references the table by name so it does not contain an account-specific table ID.

The table gives you an audit trail and a clean handoff point for a dashboard, daily digest, or notification channel.

If a user needs the source filing, resolve the PDF citation only when they open the event. The announcement list intentionally omits attachment URLs, so prefetching a document for every row adds calls and cost without helping most alerts.

7. Add retries, an error workflow, and a heartbeat

A workflow that runs in the editor is not yet reliable. Add three safeguards:

  1. Retry transient Drishti API failures. In the HTTP Request node settings, retry a small number of times with a delay. Do not retry authentication errors forever. A 401 or 403 needs a credential fix; a 429 means the workflow should slow down before calling Drishti again.
  2. Create an error workflow. Start a separate workflow with Error Trigger, send the workflow name, failed node, execution URL, and error message to an operations channel, then select it under the main workflow's Error Workflow setting. n8n's error-workflow guide shows the pattern.
  3. Add a daily heartbeat. “No new announcements” is a valid successful run, so the Error Trigger will not catch a workflow that simply stopped being scheduled. Send one daily health record or check the last successful execution from an external monitor.

Also set a sensible HTTP timeout and inspect the response before enabling pagination. The Drishti response exposes has_next; if your symbol set or time window can return more than 20 rows, either narrow the query or configure page-based pagination deliberately.

How this template was tested

The workflow passed n8n validation before it was created. We then ran a pinned API response through every downstream node.

The first execution normalized one announcement, recorded its event ID, created the alert text, and inserted row 1 in the Data Table. The second execution replayed the same event_id; the processed-ID check stopped n8n from inserting or alerting on that event again.

That proves the workflow logic and Data Table write. It does not prove your Drishti credential, watchlist, timezone, or chosen notification channel. After import, run these live checks:

  1. Select your saved X-API-Key Header Auth credential.
  2. Set the workflow timezone to Asia/Kolkata.
  3. Widen the time window temporarily and confirm at least one known announcement.
  4. Replay that event and confirm it does not create a second row.
  5. Restore the 20-minute window and run one more manual test. Keep the repeating schedule disabled for ongoing tracking.

Clear deduplication history only when you deliberately want old events to be eligible again.

If you want to run this exact monitor, download the template and test it manually before enabling the schedule.

Reuse the pattern for other market automations

Once this workflow is stable, the same shape covers several useful jobs.

Build a market-news digest

Replace the endpoint with GET /v1/news, filter by watchlist and time window, group the remaining items by symbol, and send one digest instead of one message per article. Keep the source link and original timestamp.

Monitor earnings and conference calls

Use Drishti's GET /v1/earnings or GET /v1/concalls endpoint, normalize around the returned filing or call ID, and route upcoming events to a calendar while routing published results or transcripts to a research channel.

Track block deals

Filter structured block-deal records by symbol or value, dedupe by record ID, and send them to a review queue. Do not turn a single print into an investment recommendation.

Build price alerts

For ongoing tracking of Drishti's price, relative-volume, unusual-volume, and 52-week signals, subscribe to the alerts product over the Drishti WebSocket. Use GET /v1/alerts only to test the logic, backfill a time range, or recover missed alerts. Store the last alert ID so n8n does not act on an event twice. For a custom calculation over historical closing price and volume, use Drishti MCP's get_price_and_volume_since tool in an MCP-capable agent workflow; that dataset is not exposed as a public Drishti REST route. Use your broker's API only if you also need account data or order execution.

Use Drishti WebSockets for ongoing market tracking

The Drishti WebSocket stream is the recommended production path for ongoing market-data tracking. Drishti pushes new announcements, earnings, news, concalls, block deals, and alerts to your subscriber as they become available. You do not need to keep asking the REST API whether anything changed.

Keep REST polling for three jobs: testing your workflow, backfilling a chosen time range, and recovering records missed during an outage.

Do not keep a long-running WebSocket connection inside a normal n8n execution. Run the Drishti SDK subscriber as a small server process, then send each event to an n8n Webhook trigger:

Drishti WebSocket events go to a small SDK subscriber process, then to an n8n Webhook that normalizes, removes duplicates, builds an alert, and stores or notifies

Here is the core TypeScript subscriber:

Code
import { DrishtiClient } from "drishti-sdk"

const client = new DrishtiClient({
  apiKey: process.env.DRISHTI_API_KEY!,
})

const ws = client.websocket({
  onAnnouncements: async (announcement) => {
    const response = await fetch(process.env.N8N_WEBHOOK_URL!, {
      method: "POST",
      headers: { "content-type": "application/json" },
      body: JSON.stringify({
        channel: "announcements",
        data: announcement,
      }),
    })

    if (!response.ok) {
      throw new Error(`n8n webhook returned ${response.status}`)
    }
  },
})

await ws.subscribe({
  product: "announcements",
  symbols: ["RELIANCE", "TCS"],
  detailed: true,
})

In n8n, replace the Schedule Trigger and HTTP Request nodes with a Webhook trigger. Protect the production webhook with n8n authentication, and update the normalization node to read the announcement from body.data.

The managed Drishti SDK reconnects and restores subscriptions after a dropped connection. Keep the REST workflow as a recovery job: after a restart or outage, fetch the missed time window and pass those records through the same event-ID deduplication step. Drishti WebSockets require a paid plan; see the WebSocket setup guide for authentication and plan details.

Use n8n MCP and Drishti MCP to build more workflows

The downloadable workflow is one starting point. If your coding agent supports both connectors, you can use Drishti MCP to inspect the current market-data tools and documentation, then use n8n MCP to create or update the workflow on your n8n instance.

The split is useful:

  • Drishti MCP helps the agent find the right Indian-market data, parameters, and response fields.
  • n8n MCP helps the agent choose n8n nodes, validate the graph, and create the workflow.
  • The saved n8n workflow calls Drishti's REST API on schedule. It does not need an agent running in the background.

For example:

Code
Use Drishti MCP to find the documented API and fields for upcoming concalls.
Then use n8n MCP to build a weekday workflow that fetches the records,
deduplicates them by stable ID, formats a Telegram-ready alert, and stores each
new item. Keep credentials out of the workflow and leave the schedule disabled
until the manual test passes.

The same approach works for earnings calendars, news digests, block-deal review queues, and announcement-category monitors. Keep each first version small enough to test with one known event.

Common problems

The workflow runs at the wrong time

Set Asia/Kolkata at the workflow level and test a published scheduled run. Do not assume the server timezone is IST.

The Drishti request works in curl but fails in n8n

Check the method, URL, query-parameter types, and header name. The HTTP Request node can import a curl command, but n8n imports parameter values as strings; review booleans and numbers after importing.

Some announcements are missing

Check the symbol list, category filter, time window, timezone, page limit, and has_next. Also confirm that the event was not already present in deduplication history.

The workflow burns through API credits

For ongoing tracking, replace polling with Drishti's WebSocket stream and send each event to an n8n Webhook. When testing or backfilling over REST, keep the symbol list and time window narrow, avoid unnecessary detail, and fetch attachments only when a user asks for them.

Frequently asked questions

Does n8n need a dedicated Indian stock market node?

No. The HTTP Request node can call a documented REST API directly. A dedicated node can make authentication and field selection easier, but it is not required.

Can I use a broker API in this workflow?

Yes, if the broker supports the data or account action you need and its terms permit your use. Broker authentication, order rules, market-data display, and redistribution rights are separate concerns. Confirm each one.

How often should the workflow run?

Do not use continuous polling for ongoing market tracking. Use the Drishti WebSocket stream. Run REST requests manually or on a temporary schedule only when testing, backfilling a time range, or recovering after downtime.

Can n8n place trades automatically?

n8n can call APIs, including broker APIs, but unattended order execution is a different risk and compliance problem from monitoring data. Use the broker's documented controls, required approvals, manual review where applicable, position limits, kill switches, audit logs, and specialist legal or compliance advice before considering it.

Is this investment advice?

No. This workflow moves and filters data. It does not assess whether a security is suitable or predict market performance.

Start with one event, then widen the workflow

The smallest useful market automation is not an AI trading agent. It is a dependable pipe that fetches one kind of event, gives it a stable schema, sends it once, and tells you when it breaks.

Start with the tested REST template to verify your credentials, field mapping, and storage. Then connect the Drishti WebSocket to an n8n Webhook for ongoing tracking. Keep the REST workflow available for backfills and recovery.

Sources

Keep exploring