knowledge-base How to use VBA to call MarketXlS Api in Excel for stock data

Discussion in 'FAQ' started by marketxls, Sep 20, 2017.

How to use VBA to call MarketXlS Api in Excel for stock data

  1. marketxls

    marketxls Administrator
    Staff Member

    Joined:
    Dec 21, 2015
    Messages:
    1,119
    Likes Received:
    10
    Please use this code below to get Market data with MarketXLS API.

    Sub Test()

    Dim objRequest As Object
    Dim strResponse As String
    Dim blnAsync As Boolean

    Set objRequest = CreateObject("WinHttp.WinHttpRequest.5.1")
    blnAsync = True

    With objRequest
    .Open "GET", "https://api.marketxls.com/historical-prices/MSFT/2011-01-01/2017-01-01/daily/ohlcv", blnAsync
    .setRequestHeader "x-api-key", "Enter your Key here"
    .send
    .WaitForResponse
    strResponse = .responseText

    Debug.Print strResponse
    Debug.Print .Status
    End With

    MsgBox strResponse

    End Sub
     

Share This Page