Java Library

Place and manage orders from your own Java code, on any supported broker, with one set of functions.

Runs on the JVMDirect connectionAbout 5 minutesBroker independent
In short

The Java library lets you place and manage orders from your own Java code. Add it through Gradle or Maven, create one AutoTrader instance with your API key, then call functions like placeRegularOrder. The same code works on any supported broker.

What it is

The Java library is a broker independent trading client for Indian stock exchanges. You write your strategy once in Java and run it against any broker that AutoTrader Web supports. The same function calls work everywhere, so changing broker does not mean rewriting your code.

It is a good fit if you build on the JVM, want full control over your logic, or run your strategy on a server.

How it connects

Java is a direct client. Your code calls AutoTrader Web over a secure web connection, and AutoTrader Web passes each instruction on to your broker. Nothing extra needs to run on your computer.

How your orders reach your brokerNothing else to install
DirectExcel · AmiBroker · MetaTrader · Python · Java · C# · HTTP REST
Your code or tool
on your PC or a server
secure web
AutoTrader Web
the platform
Your broker
any supported broker

Your code talks to the platform over the web. There is nothing to install on your machine beyond the library itself.

Before you begin

Have these ready first:

  • A Java project built with Gradle or Maven.
  • An AutoTrader Web account. Your strategy runs through it.
  • An API key. Generate it in your account settings, then keep it private.
  • At least one broker account added, so your orders have somewhere to go.

Install

Install the library in the way that matches your build system.

Gradle

  1. Add the repository to your build.gradle file.
repositories {
    // Use Maven Central for resolving dependencies.
    mavenCentral()

    maven {
        url "https://raw.githubusercontent.com/stocks-developer/autotrader-maven-repo/main"
    }
}
  1. Add the dependency.
dependencies {
    implementation 'com.dakshata:at-api:3.3.0'
}

Maven

  1. Add the repository to your pom.xml file.
<repositories>
    <repository>
        <id>stocks-developer</id>
        <url>https://raw.githubusercontent.com/stocks-developer/autotrader-maven-repo/main</url>
    </repository>
</repositories>
  1. Add the dependency.
<dependency>
    <groupId>com.dakshata</groupId>
    <artifactId>at-api</artifactId>
    <version>3.3.0</version>
</dependency>

Initialize

Create one AutoTrader instance and share it across your application. Pass your API key, which you can find in your account settings.

IAutoTrader autotrader = AutoTrader.createInstance("<your-api-key>");

You do not need to create it again and again. One instance is enough for the whole application.

A minimal working example

This places one regular order. Replace the placeholder values with your own account and instrument.

// Place a regular order
final IOperationResponse<String> response = autotrader.placeRegularOrder(
    "ACC_NICK_NAME", "<exchange>", "SBIN",
    TradeType.BUY, OrderType.MARKET, ProductType.INTRADAY,
    1, 0f, 0f);

The same instance also handles bracket and cover orders, modify, cancel, square-off, and reading orders, positions and margins. Each function is documented with examples in the API reference.

Shutdown

You can call shutdown() just before your application exits. This is optional but recommended.

autotrader.shutdown();

Write the code with AI

You can have an AI coding assistant (ChatGPT, Claude, Gemini or Copilot) write your Java code for you. Many programmers now start this way, and it is much faster than a blank page. It only works well if the AI reads our documentation first. Without it, the AI guesses function names that look right and then fail.

  1. Give it our Java file first: stocksdeveloper.in/ai/trading-api/java.txt. It has every API call with Java examples, and nothing from other languages to mix up. If your tool cannot open links, open the file yourself, save it, and attach it to the chat.
  2. Then send a prompt like this one. Replace the parts in CAPITALS.
Read this file first: https://stocksdeveloper.in/ai/trading-api/java.txt
It is the official reference for the AutoTrader Web Java library.
Use only the functions, parameters and values it defines.

Write a Java program that DESCRIBE WHAT YOU WANT IT TO DO HERE.
My account nickname is MY_ACCOUNT. Read the API key from an
environment variable, never from the code.

Then check your code line by line against the reference, and list
anything you were not sure about instead of guessing it.
  1. Test it before real money. Run it once with the smallest quantity, in one account only.

Never paste your API key into an AI chat. Ask the AI to read it from an environment variable instead, as the prompt above does. Anyone who has your key can place orders in your accounts.

Build with AI has more prompts, the mistakes these tools make, and what to check before you trade with the result.

Next steps

Was this page helpful?

Last updated 8 October 2026