Codementor Events

Importing public web API to Excel (no coding required)

Published Mar 15, 2020
Importing public web API to Excel (no coding required)

In the world of Forex and Cryptocurrency Trading, Data Scraping or Web Scraping is often needed so the data you needed is always in your hands. Good thing Microsoft Excel has tools to help you extract data from web sources with or without coding.
In this example, I’m going to show you how you can extract data from a public web API to excel without coding VBA. First, we need a public web API, because cryptocurrencies popular these days, we’re going to use a cryptocurrency API as an example.
https://min-api.cryptocompare.com/data/histominute?fsym=BTC&tsym=USD&limit=288&aggregate=5

To import this on excel go to Data>Get Data>From other Sources> From Web or simply Data>From Web.
0.PNG

Paste the API URL on the prompt then click OK.
1.PNG

Then select Into Table on the Convert tab.
2.PNG

Select the Value of Data then right click>Drill Down.
3.PNG

On the resulting prompt choose Transform>To Table on the menu then click OK.
4.PNG

On the top of the column, click the button with left and right arrow, uncheck use Original name as prefix then click OK. Then finally, Click Close & Load on the Home menu.
5.PNG

And there you go; you’ve successfully imported the JSON data from a public web API.
6.PNG
You can click Refresh on the Query or Data Tab to get the latest data.

Though, for this Web API the time we retrieved is in a Unix timestamp. The next that we’re going to do is add a custom column and convert that to time and date format in Excel.

A quick Google Search would give us the formula =((([time] /60)/60)/24)+DATE(1970,1,1).
1.png

To edit our query, go to Query>Edit or Data>Get Data> Launch Query Editor…
3.PNG

On the query editor select Add Column>Custom Column then put out formula.
4.PNG

The query editor uses a different language call Power Query formula so will replace our formula with its equivalent.
2.png

Now we have a new column. Let’s convert the column to Date/Time format. To do that, select custom column and on the transform tab and select date/time on the Data Type drop down.
7.PNG

Now we’ll replace the original time column. Move the custom column to the Beginning and remove the time column.
8.1.PNG

Then rename the custom column to time and go to Home>Close & Load.
9.1.PNG

Now our time column is in Date/Time instead of Unix timestamp.
3.png

Now that the data is in Microsoft Excel you can now do you analysis and graphs to give you an edge to your Forex or Cryptocurrency trading.

See here for a demo video. Part1. Part2.

Discover and read more posts from Bennie Jay Guevarra
get started
post commentsBe the first to share your opinion
Gerhard Landauf
2 years ago

Hi,
cool tutorial. I have the following question and requesting help, please:
When I record the complete procedure with the Macro Recorder and try to assign the recorded code then to a button, I receive the error that the name of the database is already used.
What am I doing wrong ?

Brett Harnett, MS-IS
2 years ago

Who knew this function was available in Excel. Very cool but I’m trying to get financial data from treasury.gov and the downloadable data sets are current, but the api has very limited - time constrained - data such as ‘debt tp the penny’ displays for 1993. Is this a limitation of the fed site or is my Excel function truncating? Have you experienced this?

Chico Perello
3 years ago

Is there a way to regularly pull data from API? Every hour for example.

Show more replies