Aliceblue ANT APIs

How can I use Aliceblue ANT APIs for placing trades and managing my portfolio?

Aliceblue ANT APIs are a powerful tool for automating your trading activities and managing your portfolio. They provide a REST-based platform that allows you to place orders, view your order book, monitor positions, and view funds and balances. Here’s a step-by-step guide on how you can use these APIs for trading and portfolio management.

1. Authentication:

Before you can start using the APIs, you need to authenticate yourself. Aliceblue ANT APIs use a SHA-256 encrypted key for authentication. Here’s how you can generate this key:

  • Log in to the Aliceblue ANT web application.
  • Navigate to APPS → API key.
  • Accept the ‘Terms and Conditions’.
  • The generated API key will be sent to your registered email.

This API key is used for authentication and authorization workflow. You will need to use this key to generate a User Session ID, which is used in the authorization header for all further API calls.

2. Placing Orders:

Once you are authenticated, you can start placing orders. The API call for placing an order would look something like this:

POST /orders/placeOrder

{

“variety”: “regular”,

“tradingsymbol”: “RELIANCE”,

“symboltoken”: “2885”,

“transactiontype”: “BUY”,

“exchange”: “NSE”,

“ordertype”: “LIMIT”,

“producttype”: “INTRADAY”,

“duration”: “DAY”,

“price”: “2200”,

“squareoff”: “0”,

“stoploss”: “0”,

“quantity”: “1”

}

In this example, we are placing a limit order to buy 1 share of Reliance at a price of 2200.

3. Viewing Order Book:

You can view your order book using the following API call:

GET /orders/getOrderBook

This will return a list of all your orders with their current status.

4. Monitoring Positions:

To monitor your positions, you can use the following API call:

GET /orders/getPositions

This will return a list of all your open positions.

5. Viewing Funds and Balances:

Finally, you can view your funds and balances using the following API call:

GET /user/getUserBalance

This will return your available balance and margin used.

Remember, all these API calls need to be made with the authorization header containing your User Session ID. If you encounter any issues, such as unauthorized access or invalid session, you can re-generate the session ID using the same process described above.

Using Aliceblue ANT APIs can significantly streamline your trading process and make it more efficient. However, it’s important to understand that trading involves risks and you should only trade with money you can afford to lose. Always test your API calls in a safe environment before using them in live trading.

Kindly follow the below links.

Kindly use the new ANT version and try not to use the old version of ANT and API.

Kindly log in here and go to APPs and API_KEY and generate your API_KEY.

https://ant.aliceblueonline.com/

OR

Please refer to the below link for documentation and POSTMAN collection
https://v2api.aliceblueonline.com/vendors

Kindly follow the given below link for video reference.

Kindly find our GitHub library in the given below link.

Kindly find our youtube tutorial in the given link below