C# and .NET Stock Market API for India: NSE and BSE Data Guide

If you build in .NET and need Indian company events, you can install one NuGet package, Manasija.Drishti, and call a .NET stock market API for India with typed models, dependency injection (DI) and a managed WebSocket (a persistent two-way connection) session. The software development kit (SDK) covers National Stock Exchange of India (NSE) and BSE Ltd (BSE) filings, earnings, concall analysis, news and alerts on .NET 8+ and .NET Standard 2.0. Below: the install, a first C# NSE API call, ASP.NET Core registration and a worker that streams announcements.
Drishti is our product, so weigh that when you read this comparison.
Key takeaways
dotnet add package Manasija.Drishtigives you an async, thread-safe client with typed parameter records and response models.AddDrishtiClient(builder.Configuration)registers the client onIHttpClientFactoryand fails at startup when the API key is missing.- A
BackgroundServicecan run a WebSocket session that reconnects, resubscribes and detects stalled connections on its own. - The SDK retries 429 and 500, 502, 503 and 504 responses;
DrishtiApiException.RetryAftertells you how long to back off after that. - Drishti covers company events, not price feeds. Pair it with a market-data vendor for quotes and a broker API for orders.
On this page
- What a .NET team can build with NSE and BSE data
- Install the NuGet package for NSE and BSE data
- Make your first NSE API call in .NET
- Use the NSE API from ASP.NET Core with dependency injection
- Stream filings in a .NET worker service
- .NET stock market API features mapped to the SDK
- Which Indian market data provider fits a .NET project
- Frequently asked questions
- Start with the Sandbox and one worker
What a .NET team can build with NSE and BSE data
Most .NET work in Indian finance takes four shapes: ASP.NET Core APIs behind a web or mobile front end, worker services that react to filings, WPF or WinForms desk tools, and Excel add-ins for analysts.
Drishti fits the event side of all four. Its REST (request-and-response) API returns AI-summarised corporate announcements (short summary, long summary, category and extracted fields), earnings results and tables, concall analysis and transcripts, news with sentiment, alerts such as 52-week highs and volume spikes, block deals and symbol metadata. A WebSocket live feed pushes news, block_deals, announcements, earnings, concalls and alerts as they arrive.
Drishti is an independent market-intelligence API built on official exchange-backed sources. It does not scrape NSE or BSE websites. It also does not provide tick-by-tick prices or submit orders, so a trading screen still needs a price vendor and a broker connection beside it.
For desktop and Excel builds, keep the API key on a server, not inside an app you ship. Put the client in your ASP.NET Core backend and let WPF or the add-in call that.
Install the NuGet package for NSE and BSE data
The package on NuGet targets net8.0 and netstandard2.0. The second target covers .NET Framework 4.6.2 and later, which matters if your Excel add-in or older desktop tool still runs on the full framework.
dotnet add package Manasija.Drishti
Set your key as the DRISHTI_API_KEY environment variable. Every request sends it in the X-API-Key header to https://developers.manasija.in. The C# / .NET SDK guide lists every method and option.
Make your first NSE API call in .NET
This console program reads the key from the environment, fetches five news items for two NSE symbols and prints sentiment beside each headline. GetNewsAsync returns Paginated<NewsItem>, so Data holds the page and HasNext tells you whether to request Page + 1.
using Manasija.Drishti;
using Manasija.Drishti.Exceptions;
using Manasija.Drishti.Models;
using Manasija.Drishti.Params;
using var client = DrishtiClient.FromEnvironment(); // reads DRISHTI_API_KEY
try
{
Paginated<NewsItem>? page = await client.GetNewsAsync(new NewsParams
{
Symbols = ["RELIANCE", "TCS"],
Limit = 5,
});
foreach (NewsItem item in page?.Data ?? [])
{
Console.WriteLine($"{item.Symbol} [{item.Sentiment}] {item.Title}");
}
Console.WriteLine($"More pages: {page?.HasNext}");
}
catch (DrishtiApiException ex) when (ex.StatusCode == 429)
{
// The SDK already retried; wait as long as the API asks before the next run.
TimeSpan wait = ex.RetryAfter ?? TimeSpan.FromMinutes(1);
Console.Error.WriteLine($"Rate limited. Retry in {wait.TotalSeconds:N0}s.");
}
Parameter records only send what you set. NewsParams also takes ScripCodes, which turns the same call into a C# BSE API lookup. Response models read JSON on demand, so a missing or new field returns null instead of throwing.
Rate limits and the 429 catch
The client retries 408, 409, 425, 429, 500, 502, 503 and 504 responses twice by default, with backoff from 300 ms up to 5 s. A DrishtiApiException reaches your code only after those attempts, and RetryAfter reads the Retry-After header so you wait as long as the API asked. Sandbox allows 10 requests per minute, Starter 60 and Pro 180.
Use the NSE API from ASP.NET Core with dependency injection
In ASP.NET Core, register the client once and inject IDrishtiClient wherever you need it. AddDrishtiClient binds a Drishti section from configuration, validates it at startup and returns the IHttpClientBuilder, so you can add a proxy handler or Polly policy.
Your appsettings.json can hold settings such as "Drishti": { "Timeout": "00:00:30" }. Keep ApiKey out of the file: the worker below copies DRISHTI_API_KEY into Drishti:ApiKey before registering, and the same line works in a web project. A minimal endpoint then takes IDrishtiClient drishti as a parameter and returns (await drishti.GetNewsAsync(new NewsParams { Symbols = [symbol] }))?.Data.
The client is a singleton, but it asks IHttpClientFactory for a client per request, so pooled handlers rotate and DNS changes are picked up. If the key is missing, the host throws OptionsValidationException on start instead of failing on the first request.
Stream filings in a .NET worker service
The use case: a BackgroundService that holds a WebSocket session open and hands each announcement to a Channel<T>. The host's stoppingToken stops the session cleanly on shutdown.
using System.Threading.Channels;
using Manasija.Drishti;
using Manasija.Drishti.DependencyInjection;
using Manasija.Drishti.Models;
using Manasija.Drishti.WebSocket;
var builder = Host.CreateApplicationBuilder(args);
builder.Configuration["Drishti:ApiKey"] ??= Environment.GetEnvironmentVariable("DRISHTI_API_KEY");
builder.Services.AddDrishtiClient(builder.Configuration);
builder.Services.AddSingleton(Channel.CreateUnbounded<Announcement>());
builder.Services.AddHostedService<FilingFeed>();
builder.Build().Run();
sealed class FilingFeed(IDrishtiClient drishti, Channel<Announcement> queue, ILogger<FilingFeed> log)
: BackgroundService
{
protected override async Task ExecuteAsync(CancellationToken stoppingToken)
{
await using var session = drishti.CreateWebSocketSession();
session
.OnAnnouncements(a => queue.Writer.WriteAsync(a, stoppingToken).AsTask())
.OnError(e => { log.LogWarning("Drishti {Code}: {Message}", e.Code, e.Message); return Task.CompletedTask; });
await session.SubscribeAsync(new SubscribeOptions("announcements")
{
Symbols = ["RELIANCE", "TCS", "INFY"],
}, stoppingToken);
await session.RunAsync(stoppingToken);
}
}
A second hosted service can read queue.Reader.ReadAllAsync(stoppingToken) and write to SQL Server or push to SignalR. Keeping the handler to a channel write means a slow database never holds up the socket, and the SDK logs a handler that throws without killing the session.
What you get without writing it: reconnect with backoff from 1 s to 30 s, every subscription re-sent after a reconnect, and a reconnect when nothing arrives for 90 seconds. SubscribeOptions also takes Categories, such as Dividend. The WebSocket guide lists close codes and product rules.
Live streams need a paid plan: Starter (₹2,000/month) monitors 100 symbols and Pro (₹10,000/month) 1,000, per the pricing page. After downtime, backfill the gap with GetAnnouncementsAsync.
.NET stock market API features mapped to the SDK
| .NET feature | How the SDK supports it |
|---|---|
| Dependency injection | AddDrishtiClient(configuration) or AddDrishtiClient(options => ...) registers a singleton IDrishtiClient; options are validated on start |
IHttpClientFactory | The DI client uses a named client, Manasija.Drishti, and returns IHttpClientBuilder for handlers such as Polly or a proxy |
CancellationToken | Every method takes an optional token; RunAsync(stoppingToken) ends the WebSocket session when the host stops |
ILogger | Retries, redirects and WebSocket events log through ILoggerFactory when the client comes from DI |
IAsyncEnumerable | session.ReadEventsAsync(token) streams WebSocket events for await foreach instead of callbacks |
| Typed models | Records such as NewsParams and models such as Paginated<NewsItem> and Announcement; raw JSON stays on model.Json |
The Python, TypeScript, Java, PHP and .NET SDKs all pass one shared conformance suite, so retries, errors, pagination and WebSocket reconnects behave the same in every language. For the side-by-side view, see the Indian stock market API SDK comparison.
Which Indian market data provider fits a .NET project
This is a product-fit comparison, not a ranking. Rows reflect each provider's published pages; we have not benchmarked them.
| If your build needs | Consider | Why it may fit | Check before choosing |
|---|---|---|---|
| Filings, earnings, concalls, news and alerts in C# | Drishti | Official .NET SDK with DI, WebSocket session and typed models; AI-structured company events | No price feeds or orders; Sandbox has no WebSockets |
| Real-time tick and historical prices for NSE, BSE and MCX | TrueData | Authorised vendor with WebSocket, TCP and REST APIs; site lists a C#/.NET library via DLL or NuGet | API pricing is not published; licence covers the subscriber's own use |
| Price feeds into trading platforms, including legacy Windows stacks | Global Datafeeds | Authorised NSE and MCX vendor with .NET, COM, WebSocket, REST and FIX APIs; C# and VB.NET samples | Pricing is on request; confirm segments and feed mode |
| Company research in a ready-made interface | Tijori Finance | Filings timeline, results and 6,000+ operational metrics | Public developer APIs are limited; no self-serve SDK found |
| Screeners, scores and Excel Connect | Trendlyne | DVM scores, alerts, results dashboard; B2B data for brokerages | No self-serve public API documentation found |
| Ready-made scans for results and announcements | StockScans | Scans, Research AI and watchlists; data from CMOTS | No public developer API listed |
For a .NET trading tool, use TrueData or Global Datafeeds for quotes and candles, Drishti for company events, and a broker API if you need to place orders.
Frequently asked questions
Is there a C# API for NSE and BSE company announcements?
Yes. Drishti's .NET SDK exposes GetAnnouncementsAsync for REST queries by symbol, scrip code, category and date, and the announcements WebSocket product for live delivery. Both return the same typed Announcement model with summary and category, plus long summary and extracted fields when Detailed is set.
Can I use the SDK in .NET Framework or an Excel add-in?
The netstandard2.0 build runs on .NET Framework 4.6.2 and later. For an add-in other people use, call your own backend instead of shipping the key.
Can I get live NSE prices in C# from Drishti?
No. Drishti does not provide tick-by-tick prices or submit orders. Use a market-data vendor such as TrueData or Global Datafeeds for quotes, both of which publish .NET options.
Does the free Sandbox support WebSockets?
No. Sandbox gives 1,000 one-time trial credits, 10 requests per minute and 1,000 REST requests per day, with no WebSocket access. The worker above needs Starter or higher; the REST call works on Sandbox.
Start with the Sandbox and one worker
Create a free key at platform.manasija.in, set DRISHTI_API_KEY and run the console program against two symbols you follow. When the output looks right, move to a paid plan and drop the FilingFeed worker into your host. The C# / .NET SDK docs cover every endpoint, batch jobs and the full option list.
Product pages, package registries and documentation checked on 21 October 2026. Prices and features change, so confirm on each provider's site before you buy. This article is not investment advice.



