Apr 29

AECData Python Library Step 1 — Authenticate and Initialize Your Project

AECData Python Library Image

TL;DR

We go step by step and explain how to start with authentication and basic API use on aecdata (see code below).

Let’s go!

Demystifying the Initial Setup: Easy Authentication and Project Initialization with AECData

Getting started with a new tool doesn’t have to be a headache. For all you builders, designers, and data crunchers in the construction sector looking to harness the power of data, the AECData Python library will simplify your life significantly.

In this first installment of our series, we’ll walk through the crucial first steps:

Setting up authentication and initializing your project with aecdata

Whether you’re a seasoned coder or a curious novice, this short tutorial should help you going in 3–5 minutes at most.

Getting Your Hands on the API Token

Before you can start querying data and crunching numbers, you need access. Access in the world of APIs typically comes in the form of a token.

Think of an API token like your personal password for the aecdatalibrary.

  1. Sign up for Access: Head over to 2050 Materials and sign in or register a free account if you haven’t already.
  2. Generate your personal API Token: Once logged in, navigate to the account settings page and generate a new token (see a YouTube tutorial here).

By default, you will get an API token which gives you access to our open/free API endpoint (get_product_open_api). This integrates well with the aecdata library, and allows you to test prior to buying a subscription for the complete data endpoint (get_products)

Setting up your Environment

With your token in hand, it’s time to get your hands dirty with some code. First up, open a python script (e.g. in a Google Colab notebook).

Before you dive into fetching and manipulating data, make sure your environment is ready. This means having the right packages installed and your settings dialed in.

  1. Install aecdata: If you haven’t already installed the library, simply open your terminal and run: pip install aecdata
    This command fetches the latest version of aecdata from the Python Package Index and installs it on your machine.
  2. Import Necessary Modules: At the top of your script or notebook, make sure to import the modules you’ll be using. For now, it’s mostly about setting up, so keep it simple.
from aecdata import User

Then, set up your environment. This is where you can save your developer token (the one you got from your account page on the 2050 Materials platform).


        

Next, set up your user instance. This is where you tell aecdata who you are and how you’re authorized to use it.

user = User(developer_token=developer_token)

User attributes

Now it’s time to play with the functionality of the user attributes.

These allow you to do all the typical API processes around tokens and retrieving filters without having to build the API request from scratch.

For example:

  • Get your base url: user.base_api_url
    This is usually “https://app.2050-materials.com/”, unless you’re using a test environment of ours.
  • Refresh your API token: user.refresh_api_token()
  • Fetch filters for the get_products endpoint: user.filters
  • Fetch descriptions for the filters: user.field_descriptions

That’s it!

You’re now set up with aecdata and ready to start using the real functions, like making your first API calls to the 2050 Materials product data endpoints.

Have a look at our next article, we’ll dive into how to fetch and manipulate data, giving you the tools to make informed decisions right from the planning phase.

Stay tuned, and happy coding!

Previous aecdata — An Open Source Python Library to do more with Construction Data
Next AECData Python Library Step 2— Get filters and retrieve product data

Related articles

Curated collection of bricks with Environmental Product Declarations on the 2050 Materials platform
Data & Research Apr 29

The Most Interesting Brick Products with EPDs on the 2050 Materials Platform

This collection brings together a range of bricks with EPDs listed on the 2050 Materials Platform. They include earth-based bricks, handcrafted bricks, clay bricks, reclaimed bricks, reused clinker bricks, and other specialty brick products.

Read more
Climate tech map for construction products showing low-carbon materials and emerging technologies across categories
Data & Research Apr 27

A Climate Tech Map for Construction Products

118 technologies · 16 categories · One verified database. Where the innovation is, who is delivering it, and how close it is to your next specification.

Read more
Digital Product Passport (DPP) infographic showing how building material passports become standardized, traceable, and data-driven across the lifecycle
Data & Research Apr 06

How the Digital Product Passports Bring (Building) Material Passports Into Reality

The EU's Digital Product Passport regulation provides all three simultaneously. A legal mandate across 27 member states. Standardised, machine-readable data requirements defined in law. And a market consequence with real teeth: no compliant passport, no EU market access. The tool hasn't changed. The conditions around it have.

Read more