Getting Started with Investfly API - A tutorial

In addition to the API, we have provided a Java SDK to make it easier for Java programmers. We are working to provide SDK for other languages too. This page provides tutorial on how to use the API with Java programming language. This tutorial assumes that you are a Java programmer and you are familiar with the Java programming language.

Step 1 - Download

Download the Investfly SDK Kit Unzip the file. You should have InvestflySDK folder after extraction.

Step 2 - Edit

Open ''. Double-click src, then com, then Investfly, then api, then samples. You will find '' here. Open the file with a source editor. Replace the following with your username and password that you use to access

private static final String USER_NAME = "replace_with_your_username";

private static final String PASSWORD = "replace_with_your_password;

You must have an account with us to use the API. If you do not, you can sign up at This is the top level file that will run your strategies.

Step 3 - Strategies definitions

Two Strategies are implemented in and respectively. These files are in the examples folder. These are basic strategies used for illustration only. Open these files and look over the strategies.

Step 4 - Compile

Go to the extracted InvestflySDK folder, double click either (linux) or compile.bat (windows) to compile. You must have javac compiler in your path for the script to work. If they are installed but not in your path, edit the and supply full path to javac commands.

Step 5 - Execute

Run your strategies by double-clicking (linux) or run.bat (windows) inside the InvestflySDK folder. You must have Java installed in your path to run this command. You should see portfolio messages getting printed in console window. That's it! Now, login to to see which stock(s) your portfolio bought.

Executing these strategies requires Java to make HTTP web connection to Investfly. If you get SocketConnection Exception or similar exception, make sure that you are not behind corporate firewall. If you use proxy to access outside network, edit or run.bat and put in your proxy settings as JVM parameters after java -Dhttp.proxyHost= -Dhttp.proxyPort=8800.

Step 6 - Automate (Optional but highly recommended)

You should run your strategies at regular intervals (daily, weekly, monthly) depending on the logic behind your portfolio. If your portfolio is a long-term portfolio, you may run it every month, if it is a short-term, you may want to run it every day. You can run your strategies manually, but you are strongly advised to setup a scheduled task (windows) or cronjob (linux) for running your strategies at your desired interval so that you do not have to worry about it. You can monitor the results of your strategies by using the performance chart at

For setting up scheduled task in windows, see
For setting up cronjob in linux, see

Step 7 - Start writing your strategies

Once you have run the example strategies, you should start writing our own strategies. Please see API documentation for all REST API calls you can make.