May 02

AECData Python Library Step 2— Get filters and retrieve product data

TL;DR

We go step by step and explain how to start with the filtering and retrieval of data on aecdata (see code below).

Done with authentication, on with data retrivals

In our last article we talked about how to set up the first lines of code in your Python script, with information about where to store your token, and how to authenticate and initialize your project.

If you missed the last tutorial, make sure to include the following code at the beginning of your script or notebook:

In this article, we’ll be going through how to run your first commands to get filters and then apply those filters to the API to retrieve product data.

API Data Integration

Get the field descriptions and the available filters

There’s a lot of data in the 2050 Materials universe (>140,000 products with hundreds of fields each). This means that while using the API to build your application or dashboard, it’s wise to filter the data to what you are looking for.

Retrieve field descriptions

Hint

Retrieving field descriptions programmatically can allow you to show these in your own application without worrying about changes.
If you just want to see the descriptions to understand what exists, our docs may be a better place to look at.

Retrieve filters

Retrieving the available filters is a really nice way to create dynamic filters in your application.

Why filter the data at all…? For example, if you’re building a dashboard to plot insulation material emissions for products in Europe, you’ll want to apply the relevant filters for product_type, material_type and continent . This will avoid having to make unnecessary API calls and then filter the data, which will always be inherently slower and will hinder user performance.

Applying the filters and making your first data call

After getting the filters and their mappings, we can now create a filters dictionary which we can supply to the get_products function to retrieve the data.

For this example, we will be retrieving all ceramic tiles (product_types = Tiles, material_type_family=Ceramic)

To do that, we create the filter fictionary as below:

And then we provide the filters to the get_products function

Running a print() function will let you see the JSON object returned by the API. If you are working in a notebook and plan on doing anything related to visualizations, grouping and statistics, it may make sense to transform the data to a DataFrame .

Transform the data to a table or DataFrame

To do any sort of transformation, we developed the ProductData class.
This class is designed to manage and manipulate the data fetched from the 2050-materials API. It offers functionalities for converting data between different formats, scaling product data based on units and amounts, and generating plots for product contributions (more on that in our next tutorial, check it out here)

Done, for now!

You’re now set up with aecdata and have extracted a table of data (in the form of a DataFrame).

Have a look at our next article, where we will be diving into how to use that data to run analytics, statistics, plot informative graphs and generally use it to expand whatever you are building…

Stay tuned, and happy coding!

Previous AECData Python Library Step 1 — Authenticate and Initialize Your Project
Next AECData Python Library Step 3— Visualizations & Statistical Analysis

Related articles

Sustainable office design materials available on the 2050 Materials platform.
Data & Research Apr 07

The Most Interesting Low Carbon Products in Office Design

In this article and collection, we highlight 11 outstanding products that contribute to a lower carbon footprint in office design.

Read more
A selection of sustainable and innovative building boards featured on 2050 Materials, designed for sustainable construction and improved performance.
Data & Research Mar 31

Top Low Carbon Building Boards: Performance, Benefits, and Use Cases

The building boards highlighted in this article and collection showcase low-carbon innovation in modern construction.

Read more
Curated energy efficient building materials collection at 2050 Materials
Data & Research Mar 24

11 Interesting Energy Efficient Building Materials for Reduced Environmental Impact

Discover a collection of energy efficient building materials that not only reduce greenhouse gas emissions but also contribute to long-term durability.

Read more