Manasija.Drishti
1.1.2
dotnet add package Manasija.Drishti --version 1.1.2
NuGet\Install-Package Manasija.Drishti -Version 1.1.2
<PackageReference Include="Manasija.Drishti" Version="1.1.2" />
<PackageVersion Include="Manasija.Drishti" Version="1.1.2" />
<PackageReference Include="Manasija.Drishti" />
paket add Manasija.Drishti --version 1.1.2
#r "nuget: Manasija.Drishti, 1.1.2"
#:package Manasija.Drishti@1.1.2
#addin nuget:?package=Manasija.Drishti&version=1.1.2
#tool nuget:?package=Manasija.Drishti&version=1.1.2
Drishti SDK (.NET)
Official .NET SDK for the Manasija Drishti API (/v1).
It behaves the same as the Python, JS, PHP and Java SDKs. All of them pass the shared conformance suite.
This SDK provides:
- An async, thread-safe client with a method for every endpoint, typed parameter records and typed response models
RequestAsyncfor custom calls- A managed WebSocket session (
/v1/ws) that reconnects, resubscribes and detects stalled connections - Batch job helpers that build JSONL input, submit it, poll and parse results
IServiceCollection.AddDrishtiClient(...)for ASP.NET Core and the generic host, built onIHttpClientFactory- Configurable retry and backoff for transient HTTP failures, and structured logging through
ILogger
Requirements
- .NET 8 or later, or any runtime that supports .NET Standard 2.0 (.NET Framework 4.6.2+, Unity, Xamarin)
- A valid Drishti API key (create one)
Installation
dotnet add package Manasija.Drishti
Quick start
using Manasija.Drishti;
using Manasija.Drishti.Params;
using var client = DrishtiClient.FromEnvironment(); // reads DRISHTI_API_KEY
var news = await client.GetNewsAsync(new NewsParams { Symbols = ["RELIANCE", "TCS"], Limit = 10 });
foreach (var item in news!.Data)
{
Console.WriteLine($"{item.Symbol}: {item.Title}");
}
Create one DrishtiClient and share it: it is thread-safe. Every request sends X-API-Key.
Keep your API key on the server. Don't embed it in front-end, desktop or mobile apps you ship to users.
Dependency injection
// appsettings.json: { "Drishti": { "ApiKey": "...", "Timeout": "00:00:30" } }
builder.Services.AddDrishtiClient(builder.Configuration);
app.MapGet("/news/{symbol}", async (string symbol, IDrishtiClient drishti) =>
(await drishti.GetNewsAsync(new NewsParams { Symbols = [symbol] }))?.Data);
Options are validated at startup (a missing ApiKey fails fast). AddDrishtiClient returns the
IHttpClientBuilder, so you can add handlers such as a proxy or Polly policies.
Response models
Each model is a typed view over the JSON the API returned:
- Properties are read on demand. A missing,
nullor mistyped value returnsnull, so new API fields never break you. model.Jsonis the fullJsonElement. Usemodel.Deserialize<MyType>()to map it onto your own class (snake_case names).- Free-form fields (
EarningsTable,ExtractedInformation,Metadata, …) areJsonElement?. Earnings.ResultsPageslists the 1-indexed PDF pages that hold the results statements (detailed rows only). Pass one toGetEarningsCitationPageAsync.- CSV, JSONL and HTML responses come back as
string; PDF citations asbyte[]. - An empty response (
204, or an empty body) comes back asnull.
Endpoints
Filters are records from Manasija.Drishti.Params; anything left unset is not sent.
| Area | Methods |
|---|---|
| News, block deals | GetNewsAsync, GetBlockDealsAsync |
| Symbols | GetSymbolsAsync (CSV), GetSymbolsJsonAsync, GetSymbolsMetadataAsync |
| Announcements | GetAnnouncementsAsync, GetAnnouncementsCategoriesAsync, GetAnnouncementsAttachmentsAsync, GetAnnouncementCitationPdfAsync |
| Earnings | GetEarningsAsync, GetEarningsIndexAsync, GetEarningsDetailAsync, GetEarningsAttachmentsAsync, GetEarningsCitationPdfAsync, GetEarningsCitationPageAsync, GetUpcomingEarningsAsync |
| Concalls | GetConcallsAsync, GetConcallsIndexAsync, GetConcallsDetailAsync, GetConcallsTranscriptAsync, PostConcallsTranscriptsAsync, GetConcallCitationPdfAsync, GetUpcomingConcallsAsync |
| Alerts | GetAlertsAsync |
| Daily summary | PostDailySummaryAsync |
| Account | GetAccountAsync, GetAccountLimitsAsync, GetAccountUsageAsync, GetAccountLedgerAsync |
| Batch jobs | PostBatchJobsAsync, GetBatchJobsAsync, GetBatchJobAsync, CancelBatchJobAsync, GetBatchJobResultsAsync, GetBatchJobResultsParsedAsync, WaitForBatchJobCompletionAsync, SubmitBatchJobAndWaitAsync |
| WebSocket | CreateWebSocketSession |
Every method takes an optional CancellationToken.
Daily summary
var summary = await client.PostDailySummaryAsync(
new DailySummaryRequest
{
Portfolio = [new PortfolioPosition("TCS") { Exposure = 0.6 }, new PortfolioPosition("INFY")],
Mode = "exposure",
},
ContentRetention.None); // ask the API not to retain the request
Console.WriteLine(summary!.Summary);
The body is sent as given: unset fields are omitted and the API applies its own defaults. Any
JSON-serializable object (or a JsonElement) also works as the body.
Batch jobs
using Manasija.Drishti.Batch;
var jsonl = BatchJsonl.BuildInput(
[
new DailySummaryLine("watchlist-1") { Symbols = ["TCS", "INFY"], Mode = "news_context" },
new DailySummaryLine("portfolio-1") { Portfolio = [new PortfolioPosition("RELIANCE") { Exposure = 1 }] },
]);
var job = await client.SubmitBatchJobAndWaitAsync(
new BatchJobRequest("nightly.jsonl", jsonl) { DisplayName = "Nightly run" },
pollInterval: TimeSpan.FromSeconds(5),
timeout: TimeSpan.FromMinutes(30));
if (job.Status == "succeeded" || job.Status == "partial")
{
foreach (var line in await client.GetBatchJobResultsParsedAsync(job.Id!))
{
Console.WriteLine($"{line.CustomId}: {line.Summary}");
}
}
Errors
| Exception | When |
|---|---|
DrishtiApiException |
The API returned 400 or above after retries. Exposes StatusCode, Detail (error.message, else detail, else the body), ErrorCode, BodyJson, BodyText, Headers and RetryAfter. |
DrishtiNetworkException |
No response after all retries (connection failure, DNS, timeout). |
DrishtiWebSocketException |
A subscribe was rejected or timed out, or the socket is not connected. Code carries the server code (forbidden, bad_request, …). |
DrishtiException |
Base class of the above; also invalid JSON on a success response and batch wait timeouts. |
ArgumentException |
Invalid input, such as a blank API key or an empty id list. |
try
{
await client.GetAccountAsync();
}
catch (DrishtiApiException ex) when (ex.StatusCode == 429)
{
await Task.Delay(ex.RetryAfter ?? TimeSpan.FromMinutes(1));
}
Retries and timeouts
| Option | Default |
|---|---|
MaxRetries |
2 (3 attempts in total) |
InitialRetryDelay, RetryMultiplier, MaxRetryDelay |
300 ms, 2, 5 s (no jitter) |
RetryOnStatuses |
408, 409, 425, 429, 500, 502, 503, 504, plus network errors and timeouts |
Timeout |
60 s per response |
Redirects are followed up to 5 hops. The API key and custom headers are dropped on cross-origin redirects (citation PDFs redirect to file storage), and HTTPS-to-HTTP redirects are refused.
WebSocket
using Manasija.Drishti.WebSocket;
await using var session = client.CreateWebSocketSession();
session
.OnAnnouncements(a => Console.WriteLine($"{a.Symbol}: {a.Summary}"))
.OnError(e => { Console.Error.WriteLine($"{e.Code}: {e.Message}"); return Task.CompletedTask; });
await session.SubscribeAsync(new SubscribeOptions("announcements")
{
Symbols = ["RELIANCE", "TCS"],
Categories = ["Dividend"],
});
await session.RunAsync(stoppingToken); // until cancelled
Or read events as a stream:
await session.StartAsync();
await foreach (var e in session.ReadEventsAsync(stoppingToken))
{
if (e is DataEvent data) Console.WriteLine($"{data.Channel}: {data.Data}");
}
Products: news, block_deals, announcements, earnings, concalls, alerts.
Session behaviour, shared with the other SDKs:
- Reconnects with backoff (1 s → 30 s, ×2, ±20% jitter) and re-sends every subscription.
- Reconnects when nothing arrives for 90 s (checked every 15 s).
- Waits 10 s for each subscribe acknowledgement and retries up to 10 times.
forbidden,bad_requestandunauthorizedfail at once. - Handlers run one at a time, off the receive loop. A handler that throws is logged and the session carries on.
Every setting is on DrishtiWebSocketOptions, passed through CreateWebSocketSession(o => ...).
Development
cd dotnet
dotnet test --filter "TestCategory!=Live" # conformance, unit and WebSocket session tests
DRISHTI_API_KEY=... dotnet test --filter "TestCategory=Live" # against the real API
dotnet pack src/Manasija.Drishti -c Release
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
| .NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
| .NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen40 was computed. tizen60 was computed. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- Microsoft.Bcl.AsyncInterfaces (>= 8.0.0)
- Microsoft.Extensions.Http (>= 8.0.1)
- Microsoft.Extensions.Logging.Abstractions (>= 8.0.2)
- Microsoft.Extensions.Options.ConfigurationExtensions (>= 8.0.0)
- Microsoft.Extensions.Options.DataAnnotations (>= 8.0.0)
- System.ComponentModel.Annotations (>= 5.0.0)
- System.Text.Json (>= 8.0.5)
- System.Threading.Channels (>= 8.0.0)
-
net8.0
- Microsoft.Extensions.Http (>= 8.0.1)
- Microsoft.Extensions.Logging.Abstractions (>= 8.0.2)
- Microsoft.Extensions.Options.ConfigurationExtensions (>= 8.0.0)
- Microsoft.Extensions.Options.DataAnnotations (>= 8.0.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.