APIs9 min read

Java Stock Market API for India: NSE and BSE Data in Spring Boot

By Deion DSouza
Spring Boot service receiving NSE and BSE company events through the Drishti Java SDK

If you need a Java stock market API for India that returns company events rather than price ticks, add the Drishti Java software development kit (SDK) from Maven Central and call it from a Spring Boot service. It returns filings, earnings results, concalls (earnings calls) and news for companies on the National Stock Exchange of India (NSE) and BSE Ltd (BSE) as Jackson JsonNode trees. This guide is for Java teams at brokers, portfolio management services (PMS), alternative investment fund (AIF) desks and fintechs running JVM (Java Virtual Machine) services.

Drishti is our product, so weigh that when you read this comparison. Every snippet below compiled with Java 22 against the published 1.0.0 artifact, and the reads ran against the live API on 21 October 2026.

Key takeaways

  • Add io.github.techmanasija:drishti-sdk:1.0.0 to Maven or Gradle. It needs Java 17+.
  • Create one DrishtiClient bean and inject it everywhere. The client is immutable and thread-safe.
  • Poll getEarnings and getAnnouncements from a @Scheduled job, then call getEarningsDetail for the extracted results table.
  • Use the managed WebSocket (persistent live connection) session for live events and submitBatchJobAndWait for end-of-day portfolio summaries.
  • For tick and OHLC (open, high, low, close) prices, pair Drishti with a price-feed vendor. For orders, use a broker API.

On this page

Choosing a Java stock market API for India

A results-alert service needs filings and earnings tables, a charting backend needs ticks and candles, and an execution service needs a broker.

If your build needsConsiderWhy it may fitCheck before choosing
Filings, earnings tables, concalls and news inside a JVM serviceDrishti Java SDKMaven artifact, JsonNode responses, built-in retries, managed WebSocket session and batch helpersSandbox has no WebSockets; check credits and requests per minute for your plan
Real-time tick and historical prices for NSE, BSE and MCX (Multi Commodity Exchange of India)TrueDataAuthorised real-time data vendor with WebSocket, TCP and REST (request-and-response) APIs that return JSONIts site lists official libraries for Python, JS/Node and C#/.NET; an official Java library is not listed. API pricing is not published
Real-time, delayed and historical prices with Java sample codeGlobal DatafeedsAuthorised vendor since 2010; WebSocket, REST, .NET, COM and FIX (Financial Information eXchange); sample code for Java and six other languagesPricing is on request; the Python wrapper is labelled beta
Company research in a browser, not an APITijori FinanceFilings and news timeline, 6,000+ operational metrics, screener and alerts; Free, ₹330/month or ₹3,500/yearPublic developer APIs are limited; enterprise access goes through support
Screeners, scores and Excel workflowsTrendlyneDVM scores, results dashboard, Excel Connect; serves brokerages with B2B (business-to-business) dataNo self-serve public API documentation found
Ready-made scans for results and announcementsStockScansScans for results, announcements, concalls and shareholding; market data from CMOTS; free entry tierNo public developer API listed

This is a product-fit comparison, not a ranking. We have not benchmarked these providers side by side. TrueData's licence covers the subscriber's own use, and redistribution needs exchange approval.

Drishti is an independent market-intelligence API built on official exchange-backed sources. It does not scrape NSE or BSE websites. Drishti does not provide tick-by-tick prices or submit orders: use TrueData or Global Datafeeds for prices, and if you need to place orders, use a broker API such as Kite Connect, Upstox or DhanHQ.

What the Spring Boot service will do

Every five minutes the service pulls new earnings filings and announcements for a watchlist, then fetches the results table for each new filing. A background WebSocket session pushes events between polls. After the close, a batch job writes an AI summary per client portfolio.

Spring Boot service polling Drishti REST endpoints and a WebSocket session, then writing earnings tables and portfolio summaries

Polling spends REST credits. Events delivered over the WebSocket stream do not.

Install the SDK with Maven or Gradle

The artifact is published on Maven Central. It targets Java 17+, uses the Java Development Kit's (JDK) java.net.http for HTTP and WebSockets, and depends only on Jackson Databind, which Spring Boot already ships.

Code
<dependency>
  <groupId>io.github.techmanasija</groupId>
  <artifactId>drishti-sdk</artifactId>
  <version>1.0.0</version>
</dependency>

For Gradle, add implementation("io.github.techmanasija:drishti-sdk:1.0.0"). Without a build tool, drishti-sdk-1.0.0-all.jar from the same folder bundles Jackson.

Export your key as DRISHTI_API_KEY and keep it on the server.

First call: NSE and BSE announcements in Java

DrishtiClient.fromEnvironment() reads DRISHTI_API_KEY and sends it as the X-API-Key header to https://developers.manasija.in. Filters are fluent parameter objects; unset filters are not sent.

Code
import com.fasterxml.jackson.databind.JsonNode;
import in.manasija.drishti.DrishtiClient;
import in.manasija.drishti.params.AnnouncementsParams;
import in.manasija.drishti.params.NewsParams;
import java.time.LocalDate;

public class FirstCall {
    public static void main(String[] args) {
        DrishtiClient client = DrishtiClient.fromEnvironment(); // reads DRISHTI_API_KEY

        JsonNode news = client.getNews(new NewsParams().symbols("RELIANCE", "TCS").limit(5));
        for (JsonNode item : news.path("data")) {
            System.out.println(item.path("symbol").asText() + " [" + item.path("sentiment").asText("-")
                    + "] " + item.path("title").asText());
        }

        JsonNode filings = client.getAnnouncements(new AnnouncementsParams()
                .symbols("RELIANCE", "TCS")
                .from(LocalDate.now().minusDays(7))
                .limit(5));
        for (JsonNode a : filings.path("data")) {
            System.out.println(a.path("symbol").asText() + " | " + a.path("category").asText()
                    + " | " + a.path("summary").asText());
        }
    }
}

On our run, the announcements call returned rows such as TCS | Acquisition | Tata Consultancy Services Limited has completed the acquisition of BBY Services India LLP.... Each row carries an id, symbol, category and AI-written summary, so you can route it without opening the source PDF.

Read fields with path() rather than get(): a missing field returns a missing node instead of null.

A Spring Boot stock market API job for earnings and filings

Register the client once: in a @Configuration class with @EnableScheduling, add @Bean DrishtiClient drishtiClient() { return DrishtiClient.fromEnvironment(); }. Imports (SDK params, DrishtiApiException, SLF4J, Spring) are omitted.

Code
@Service
public class WatchlistEventsJob {
    private static final Logger log = LoggerFactory.getLogger(WatchlistEventsJob.class);
    private static final List<String> WATCHLIST = List.of("TCS", "INFY", "HDFCBANK");
    private final Set<String> seen = ConcurrentHashMap.newKeySet();
    private final DrishtiClient drishti;

    public WatchlistEventsJob(DrishtiClient drishti) { this.drishti = drishti; }
    @Scheduled(fixedDelay = 5, timeUnit = TimeUnit.MINUTES)
    public void poll() {
        LocalDate since = LocalDate.now(ZoneId.of("Asia/Kolkata")).minusDays(2);
        try {
            JsonNode results = drishti.getEarnings(new EarningsParams().symbols(WATCHLIST).from(since).limit(20));
            for (JsonNode r : results.path("data")) {
                if (!seen.add(r.path("id").asText())) continue;
                JsonNode detail = drishti.getEarningsDetail(new DetailParams(r.path("quarter").asText())
                        .symbol(r.path("symbol").asText()).detailed(true));
                log.info("{} {} results: {}", r.path("symbol").asText(), r.path("quarter").asText(), detail.path("earnings_table"));
            }
            JsonNode filings = drishti.getAnnouncements(new AnnouncementsParams()
                    .symbols(WATCHLIST).from(since).limit(50));
            for (JsonNode a : filings.path("data")) {
                if (!seen.add(a.path("id").asText())) continue;
                log.info("{} [{}] {}", a.path("symbol").asText(), a.path("category").asText(), a.path("summary").asText());
            }
        } catch (DrishtiApiException e) {
            log.warn("Drishti returned {}: {}", e.getStatusCode(), e.getDetail()); // retries already ran
        }
    }
}

getEarnings returns a light list with id, symbol, quarter (such as q2_27), date and summary. getEarningsDetail returns the filing with earnings_table; when the API only sends earnings_table_extraction, the SDK copies it across, so your mapper reads one field.

On our run with a 14-day window, the TCS q2_27 table came back with period labels such as Q2FY27 and EPS (earnings per share) for the current quarter, previous quarter and previous year.

The seen set lives in memory, so a restart replays recent rows; back it with a table keyed on id. fixedDelay waits for each poll to finish, so runs never overlap on one node.

Java SDK methods by data area

Method names match the Python, TypeScript, PHP and C# SDKs. All five pass one shared conformance test suite, so retries, errors, pagination and WebSocket reconnects behave the same in every language.

SDK areaJava methodWhat you get
AnnouncementsgetAnnouncements (AnnouncementsParams)AI summary, category and extracted fields
EarningsgetEarnings, getEarningsDetail, getUpcomingEarningsResults list, earnings_table, upcoming dates
ConcallsgetConcallsDetail, getConcallsTranscriptCall analysis and transcript links
NewsgetNews (NewsParams)Headlines with sentiment
Alerts and dealsgetAlerts, getBlockDeals52-week high/low, price, volume, block deals
SymbolsgetSymbolsJson, getSymbolsMetadataSymbol lists and metadata
Portfolio summariespostDailySummary, submitBatchJobAndWaitOne summary, or many via a batch job
Live eventswebsocket(), subscribe, startPushed events on six channels

Live events and end-of-day summaries

For pushed events, build a session with drishti.websocket(), attach onAnnouncements and onEarnings handlers, call subscribe("earnings", WATCHLIST), then start(). It runs on a daemon thread, reconnects with backoff, resubscribes, and reconnects after 90 seconds of silence. Expose it as @Bean(destroyMethod = "close") so Spring stops it on shutdown, and keep handlers fast.

Streams need a paid plan: Starter covers 100 symbols, Pro 1,000. Our 10-second test acknowledged both channels.

For end-of-day portfolio summaries, use the batch helpers. Each JSONL (JSON Lines) row is one daily-summary request with a custom_id; submitBatchJobAndWait uploads, polls and returns the finished job. This method sits in a second @Service sharing the same client.

Code
@Scheduled(cron = "0 30 16 * * MON-FRI", zone = "Asia/Kolkata")
public void run() {
    String jsonl = Params.buildBatchInputJsonl(List.of(
            Map.of("custom_id", "client-001", "portfolio", List.of(
                    Map.of("symbol", "TCS", "exposure", 0.6), Map.of("symbol", "INFY", "exposure", 0.4))),
            Map.of("custom_id", "client-002", "symbols", List.of("HDFCBANK"), "mode", "news_context")));

    JsonNode job = drishti.submitBatchJobAndWait(
            new BatchJobRequest("eod.jsonl", jsonl).displayName("EOD summaries")
                    .contentRetention(ContentRetention.NONE),
            Duration.ofSeconds(10), Duration.ofMinutes(30));

    for (ObjectNode result : drishti.getBatchJobsJobIdResultsParsed(job.path("id").asText())) {
        System.out.println(result.path("custom_id").asText() + " " + result.path("status").asText());
    }
}

We compiled this but did not submit a job, since batches spend credits. ContentRetention.NONE asks the API not to retain the generated content.

Errors, retries and thread safety

SDK exceptions are unchecked and extend DrishtiException. DrishtiApiException means a 4xx or 5xx status after retries; read getStatusCode() and getDetail(). DrishtiNetworkException means no response arrived.

The client retries 408, 409, 425, 429, 500, 502, 503 and 504 twice by default, with backoff. Tune it with DrishtiClient.builder().maxRetries(3). With an invalid key, our job logged Drishti returned 401: Invalid API key.

Share one client bean across services and threads. It is immutable, and its default transport wraps one thread-safe JDK HttpClient.

Frequently asked questions

What should I use for an NSE API in Java?

For company events, the Drishti Java SDK on Maven Central is one option. For price feeds, Global Datafeeds publishes Java sample code; TrueData's official libraries are Python, JS/Node and .NET.

Can I get BSE data in Java with the same client?

Yes. Filter by symbols(...), or use scripCodes(...) when your master data uses BSE scrip codes.

Does the Java SDK work with Spring Boot 3?

Yes. It needs Java 17+, as Spring Boot 3 does, and depends only on Jackson Databind.

Which Maven artifact should I use for NSE and BSE company events?

Use io.github.techmanasija:drishti-sdk:1.0.0, or the -all.jar for classpath-only setups.

Can I stream prices with this SDK?

No. It streams company events (announcements, earnings, concalls, news, alerts, block deals). For ticks or candles, use a price-feed vendor.

Run it against the Sandbox

Create a free Sandbox account, export DRISHTI_API_KEY, and run the first-call class above. The Sandbox includes 1,000 one-time trial credits, 10 requests per minute and 1,000 REST requests per day but no WebSockets, so start with the polling job and move to Starter (₹2,000/month) for the stream. The Java SDK reference lists every method, the SDK comparison hub covers four other languages, and the pricing page has current limits.

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.

Keep exploring