Using Investfly API v{{mainData.version}}

Investfly API is a REST based web service that provides access to all of the services provided by investfly.com.

For using Investfly API, you'll need to have Investfly account and special Investfly app token.

You need to provide "investfly-app-token" in headers everytime you make API request.

Example to get stock quote of Apple

Request
GET  https://api.investfly.com/stockmarket/quote?symbol=AAPL&market=US&securityType=STOCK&realtime=true
    Headers:
        "Accept":"application/json"
        "Content-Type":"application/json"
        "investfly-app-token":"YOUR-TOKEN-HERE"
                
Response
{
  "assetClass": "EQUITY",
  "symbol": "AAPL",
  "market": "US",
  "exchange": "US",
  "date": 1467057600000,
  "lastPrice": 92.04
}
                    

You can download investfly SDK from here.

Download SDK

Please see API Tutorials to learn more about Investfly SDK.

Operations

This document describes all API calls, their request methods and response structures. Investfly API can consume data in JSON format only. The examples below show JSON request and response.


User Operations

This section describes all user related API


Login

Investfly supports HTTP BASIC Authentication scheme. Once you are authenticated, Investfly will return your

  • "clientId"
  • "clientToken"
  • "expirationTime"
  • "username"
  • for your session in response headers. Every subsequent request after that MUST include "Investfly-client-id", "Investfly-client-token" and "Investfly-app-token" in request headers. The token will expire after "expirationTime" if there is no activity with the session. However, as long as you are making request before the expiration time, the expiration time gets automatically renewed.

    Let us assume your username is demouser and password is demopass.

    Request
    POST https://api.investfly.com/user/login 
    Headers:
    "Accept":"application/json"
    "Content-Type":"application/json"
    "Authorization" = "Basic ZGVtb3VzZXI6ZGVtb3Bhc3M="
                        

    Note: Authorization used above is a sample for demo username and password given above. You can generate authorization for your own username and password using following methods:

    1. In javascript, use btoa function as btoa("your_username:your_password" .
    2. In bash: You can also generate it in your terminal with command: printf "your_username:your_password" | base64 .
    3. In python you can use base64 module to generate the result.
      >>> import base64
      >>> base64.b64encode("your_username:your_password")
                                      
    Above steps will return "ZGVtb3VzZXI6ZGVtb3Bhc3M=" the above mentioned "demouser" username and "demopass" password. Now append "Basic " before this result and you will get the authorization as:
    Basic ZGVtb3VzZXI6ZGVtb3Bhc3M=

    Response
    HTTP/1.1 200 OK
    
    {
      "clientId": "username-ku2p868f",
      "clientToken": "3a81f9e6-ce5c-4824-af4b-bd33716a2553",
      "expirationTime": "Sun Dec 29 09:32:13 EST 2013",
      "username": "username"
    }
                        

    Log Out

    Logout and end your current session.

    Request
    POST "https://api.investfly.com/user/logout"
    Headers:
    "Accept":"application/json"
    "Content-Type":"application/json"
    "investfly-client-id": user1-j307ajgm
    "investfly-client-token": 69d0952c-b156-4758-9ee6-fc095122ec67
    
            
    Response
    HTTP/1.1 200 OK 
    {
      "message": "You are now logged out",
      "type": "INFO"
    }
                        


    {{api.name}}

    {{api.description}}


    {{method.summary}}

    Request
    {{method.verb[0]}}  https://api.investfly.com{{method.path[0]}}?{{queryparam.name}}=[{{queryparam.name}}]&
                                    
    Headers:

    "Accept":"application/json" "Content-Type":"application/json" "investfly-client-id": user1-j307ajgm "investfly-client-token": 69d0952c-b156-4758-9ee6-fc095122ec67
    Request Body:

    {{getRequest('Investfly_API',api.name,method.summary,method.path[0],method.verb[0]) | json }}

    Response
    {{getResponse('Investfly_API',api.name,method.summary,method.path[0],method.verb[0]) | json}}
                                

    {{stockapi.name}}


    {{stockmethod.summary}}

    {{stockmethod.description}}

    Request
    {{stockmethod.verb[0]}}  https://api.investfly.com/stockmarket{{stockmethod.path[0]}}?{{queryparam.name}}=[{{queryparam.name}}]&
                            
    Headers:

    "Accept":"application/json" "Content-Type":"application/json" "investfly-client-id": user1-j307ajgm "investfly-client-token": 69d0952c-b156-4758-9ee6-fc095122ec67
    Request body:

    {{getRequest('StockMarket_API',stockapi.name,stockmethod.summary,stockmethod.path[0],stockmethod.verb[0]) | json}}

    Response
    {{getResponse('StockMarket_API',stockapi.name,stockmethod.summary,stockmethod.path[0],stockmethod.verb[0]) | json}}