How to activate the API in Alice Blue for Automated Trading​

Getting Started with Alice Blue API

Alice Blue API is a set of rest APIs that provide data required to build a complete investment and trading platform. Execute orders in real-time, manage user portfolios, stream live market data (using Websocket), and more, with the easy-to-understand API collection.

AliceBlue India’s API’s Python Wrapper created and maintained by Krishna Velu, a member of our community.
Unofficed  is strategic partner of Aliceblue. We are responsible for this git as well as our to create an ecosystem of Algo trading on the client base of AliceBlue India. You can checkout the details of the ecosystem here.

The AliceBlue App

To be able to use AliceBlue APIs you need to create an App in the Developer Console and generate your apiKey and apiSecret. You can use a redirect URL which will be called after the login flow.

It is highly recommended that you do not include the apiSecret in your code while sharing in public places like GitHub. It will make your app vulnerable to threats and potential issues. 

In this article, We shall discuss How to create an app in the Developer Console. Once the app is created, Your API is called “activated”.

Steps for Getting the API Key

Step 1: Head over to the Developer Console. Use Your credentials to login there.

Aliceblue credentials is made of three things – Username, Password, Birth Year.
Once, You log in, If this is your first time, You will get a “Authorize” button like this –

Step 2: Click on “Authorize” and authorize it.  So, this app is authorized to trade and perform other tasks on your behalf [Read the permissions listed above].

Step 3: Once You authorize, it will ask you to create Mpin. Its a 4 digit pin of extra security (or, You can call extra headache). Now, the main dashboard will appear –

Note that – It allows us to create multiple apps. You can use multiple apps to structure your different strategies and other plans.

Step 4: Click “Create New App”.

Step 5: As You can see in the image below there are several fields. You can put anything in the Vendor Name and other fields except Redirect URL and Post Back URL unless You’re a developer yourself who knows how the OAuth Authorization System works (You can google this term. This is the name of the mechanism which is being discussed here).


Enter the Redirect URL and Post Back URL as https://ant.aliceblueonline.com/plugin/callback.

 

Step 6: Click “Save”.

You will see the old dashboard page again with our newly created app.

Step 7: Click on “Edit”.

Step 8: Copy the ‘App Code’ and ‘Secret Key’.

If You have accidentally leaked your ‘App Secret’ in public like me, You can just regenerate them or delete and re-create the app.

API Secret and Secret Key is the same thing! Anyways, Congratulations, Your Trading API is now activated.

Join The Conversation?