API Reference

You can sync Layer data to Power BI via Layer's API. Take a look at the video above or follow along with the guide below.

1. Open Power BI

  • Create a new Power BI document, and click Get data from another source.
  • We will be using Web as the source. Select from the list or type it into the search bar to narrow down your options.
  • After selecting Web, click Connect.

2. Format API Request

  • A new window will appear titled From Web. Click Advanced and we will begin to fill out the text boxes. (See example below)
  • Under URL parts we will type in our base URL. All requests will start with the same base: https://api.layer.team
  • Next we'll add /projects/and our Project ID which you can copy and paste from your Layer project. (See our Introduction for more info about how to find your Project ID.)
  • For this example, we will be using our Elements endpoint to see information for all of our elements in our Layer project. See the rest of our API documentation for using the Projects and Categories endpoints.
  • To call the elements endpoint, type /elements after your Project ID.
  • We will narrow down our Layer data even further by referencing a specific category in our Layer project by typing in the next line ?categoryid= and pasting your category ID from your Layer project. This will show all the elements in this specific category.
  • Click Add part to add a third line, where we will type &format=simple to simplify the data coming back from the API to make it easier to work with.

3. Add Authorization

  • At the bottom, we will fill out under HTTP request header parameter (optional) our bearer tokens.
  • Type in the left box Authorization (case sensitive)
  • In the right box, type in Bearer [Your API Token] (There is a space between Bearer and your token)
  • Your API token can be found in your account settings in Layer under "Layer API Token" or click here. If you don't see your Layer API Token, reach out to us at [email protected] so we can give you access.
  • When you paste your API Token into Excel, don't worry if it looks cut off. This happens because of the length of the API token.
  • Note: Your API token can be used to access any project in your Layer account so be sure to keep this token safe and not use the token in any public facing code.
  • When you are done, hit OK and then Connect on the next window that appears.

4. Transform Data in Power Query Editor

  • You'll see that your data has been brought in to Power Query Editor where you can transform your data before bringing it into Power BI.

Note: Power BI automatically applies steps to transform your data that it thinks will be helpful. If you don't want to use these suggestions, go back to the Source step, and delete the rest of the automatically generated steps. Follow our guide to manually apply steps.

  • Start by clicking List next to the world elements to show a list of elements from that category.
  • Then click To Table and click OK in the next window that pops up. You do not need to edit any of the options.
  • In the column that was created, click expand to show all the data for each element in the category.
  • Leave all the columns selected, and press OK.
  • You will now see that you exposed the general properties for each element in your Layer category.
  • What we want to see is the data from all of the Layer fields in our projects. To do this, find the column called Column1.fields and click expand to select the different custom Layer fields that exist. Hit OK when done. This creates a new column for each of the fields selected.
  • For the columns that still show List, click expand and Extract Values to expose this information.
  • You can see that your Layer values are now exposed to be viewed.
  • Continue extracting values for any columns that you need. You will see these steps added under APPLIED STEPS to be saved for any new data that is updated.
  • You can also double click the Column names to rename them. These changes will be saved and do not affect the data that comes in through the API.
  • When you are done transforming your data, hit Close & Apply to close Power Query Editor.

5. Add a chart for your data

  • In this example, we'll build a simple donut chart to show the status of the items in my project.
  • We will select the donut chart, and add the Status field to the Legend and Values.
  • And your chart will update as you add the data sources.

6. Refresh Data with Updated Layer Information

  • After updating your Layer project, all you need to do to update your data in Power BI is to click Refresh under the Queries section.

Conclusion

With this method, you can efficiently sync Layer data to Power BI. Once set up, refreshing the data is just a click away, ensuring that your spreadsheet always has the most up-to-date information.