Skip to main content

Getting Started with API via Excel

Setup info Sheet

  1. In Excel create a new workbook and rename Sheet1 to set up

  2. Add 3 headers to the sheet starting with A1

    1. site

    2. apiKey

    3. Endpoint

  3. In the Ribbon Bar select Forums > Name Manager and select New

  4. Create 3 named ranges the cells under the headers we created in step 2 site is pictured below for examples and what you should have when you create the 3 names ranges.

  5. Fill in the cells with information so we can create the Query to pull the API. For this example well use the employee's endpoint

    1. site: app.innergy.com

    2. apiKey: <replace with your key>

    3. endPoint: employees

  6. Now that we have our setup done, we can jump into Power Query

Power Query

  1. In the Ribbon bar select Data > Get Data > Launch Power Query Editor

  2. Now that we are in Power Query, we need to create a function to get the values of the name ranges that we created in the setup sheet

  3. Click the Get data drop down and select Blank "Query".

  4. You will get the script editor for the blank query. We will turn this "Query" into a "Function". To do this you need to define a variable as something and pass that to the let that shows in line one.

    1. (rangeName as text ) => let

  5. The source of the information it needs to query our named ranges that we are passing in the first line.

  6. The full function would be like this:

    1. (rangeName as text) => let Source = Excel.CurrentWorkbook(){[Name=rangeName]}[Content]{0}[Column1] inSource

  7. Then click next at the bottom right of the window and will get a fx Query1

  8. We want to rename this to getValue

  9. Now we need to create a query to get the employee using the API

  10. Click and select Get data drop down and black query again to get the editor to open for a new query

  11. This time we want to leave the "let" alone and only change the Source. For this e need to tell the Source that it is getting a Json Document from the a Web Contents using a url and headers for our API Key. To do this use the string below:

    1. Source = Json.Document(Web.Contents("https://" & getValue("site") & "/api/" & getValue("endPoint"), [Headers=[#"Api-Key"=getValue("apiKey")]]))

    2. You will see in the url we constructed it with the getValue function to get the value of the site, endPoint, and apiKey named ranges.

    3. Select the next at the bottom right to move to the next step

  12. You will get a list return to you that each row shows [Record] we are going to expand that from here.

  13. Select the Column Header "List" and then right click for the context menu to select convert to table

    1. On the Convert to table popup just click ok as this step was done for us as its already a list of records from a Json Document from our Source

  14. You will now have a Table that shows each cell having a [Record] like the list did but now we have a new button next to the Column1 header title of opposing arrows. Select this button to get the expand record/list popup, make sure the check box is unchecked and then click OK

  15. Now we can see the Roles Column has a [List] in it. Select the opposing arrows in that column header to expand it.

  16. Rename the Query1 to say Employees by right clicking on the name and selecting Rename then Type Employees and hit Enter on your Keyboard.

  17. Last Step is to Close & Load this Query to its own sheet. At the Top left select the Close & Load button

SUCCESS!!!

You now have pulled all of the Employees from your tenant and have them displayed in an Excel Sheet!! If you make a change in INNERGY then just elect the Refresh button to get the new data from the API endpoint.

Did this answer your question?