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

IndiTherm Hemp Insulation Flexibatts available on 2050 Materials platform
Data & Research Nov 13

9 Progressive Hemp-Based Products for Construction and Insulation

This article examines 9 groundbreaking hemp-based products, detailing their sustainability credentials, unique advantages, and specific applications in construction.

Read more
Processed glass from Cardinal Glass Industries on 2050 Materials Platform
Data & Research Nov 07

The Most Innovative Products for External Walls & Facades in 2024

These products are designed to reduce carbon emissions, improve energy performance, and minimize the depletion of natural resources, all while maintaining high standards of durability and design.

Read more
Overview of sustainability regulations in the Architecture, Engineering, and Construction (AEC) industry
Data & Research Oct 30

Tracking Embodied Carbon Regulations in Construction (Updated Oct 2024)

This tracker is designed to map current embodied carbon regulations across various regions and countries, providing you with an overview of key facts and relevant supporting articles.

Read more