├── ExcelAPI.bas ├── KrakenAPICalls.xlsm └── README.md /ExcelAPI.bas: -------------------------------------------------------------------------------- 1 | Attribute VB_Name = "ExcelAPIModule" 2 | 'This subroutine will perform four subsequent API Calls. You need the JsonConverter module for this to work. This can be retrieved here: https://github.com/VBA-tools/VBA-JSON' 3 | 4 | 'Bitcoin API call' 5 | Public Sub APICallers() 6 | Dim http As Object, BTC As Object, btcvalue As String 7 | 8 | Set http = CreateObject("MSXML2.XMLHTTP") 9 | http.Open "GET", "https://api.kraken.com/0/public/Ticker?pair=xbteur", False 10 | http.Send 11 | 12 | Set BTC = JsonConverter.ParseJson(http.responsetext) 13 | 14 | btcvalue = BTC("result")("XXBTZEUR")("c")(1) 15 | 16 | Sheets(1).Cells(2, 2).Value = btcvalue 17 | 18 | 'Ethereum api call' 19 | Dim ethvalue As String, ETH As Object 20 | 21 | http.Open "GET", "https://api.kraken.com/0/public/Ticker?pair=etheur", False 22 | http.Send 23 | 24 | Set ETH = JsonConverter.ParseJson(http.responsetext) 25 | 26 | ethvalue = ETH("result")("XETHZEUR")("c")(1) 27 | 28 | Sheets(1).Cells(4, 2).Value = ethvalue 29 | 30 | 'Ethereum classic api call' 31 | Dim etcvalue As String, ETC As Object 32 | 33 | http.Open "GET", "https://api.kraken.com/0/public/Ticker?pair=etceur", False 34 | http.Send 35 | 36 | Set ETC = JsonConverter.ParseJson(http.responsetext) 37 | 38 | etcvalue = ETC("result")("XETCZEUR")("c")(1) 39 | 40 | Sheets(1).Cells(6, 2).Value = etcvalue 41 | 42 | 'Litecoin api call' 43 | Dim ltcvalue As String, LTC As Object 44 | 45 | http.Open "GET", "https://api.kraken.com/0/public/Ticker?pair=ltceur", False 46 | http.Send 47 | 48 | Set LTC = JsonConverter.ParseJson(http.responsetext) 49 | 50 | ltcvalue = LTC("result")("XLTCZEUR")("c")(1) 51 | 52 | Sheets(1).Cells(8, 2).Value = ltcvalue 53 | End Sub 54 | 55 | -------------------------------------------------------------------------------- /KrakenAPICalls.xlsm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ExtraGG/ExcelAPICaller/08ee107a68663adb71f76acebbc7292fc53e3092/KrakenAPICalls.xlsm -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## Description 2 | This subroutine will perform four API Calls to get the value in € of the last trade that occurred at Kraken of Bitcoin, Ethereum, Ethereum classic and Litecoin in Microsoft Excel. These values are then passed to several cells in the sheet 'Cryptocurrency values'. It is easily extendable to include other cryptocurrencies or API Calls to other websites. 3 | 4 | ## Installation 5 | Both options yield the same end result. 6 | 7 | #### Option 1: 8 | When using the .xlsm file: 9 | Accept all security prompts. Press Ctrl + L to refresh the values when inside your workbook. 10 | 11 | #### Option 2: 12 | If you do not wish to use the .xlsm file you can implement the code yourself from the ExcelAPI.bas file. You need the [developer tab](https://msdn.microsoft.com/nl-nl/library/bb608625.aspx) to access Microsoft Excel's Visual Basic functionality. 13 | - Download the .bas file and import it with file -> import file when inside Visual Basic. It will be added under modules. 14 | 15 | - [x] Enable Microsoft scripting Runtime reference. When inside a module in Visual Basic, click on Tools -> References, scroll down to select Microsoft Scripting Runtime and press 'OK'. 16 | 17 | - You also need to download and import the JsonConverter module. This can be retrieved [here](https://github.com/VBA-tools/VBA-JSON). 18 | 19 | You can link the macro to a shortcut if you want by adding a shortcut at Developer tab -> Macro's -> Edit. --------------------------------------------------------------------------------