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

2050 Materials Benchmark Generator Logo
Data & Research May 20

Leveraging the Python library AECData for Embodied Carbon Benchmarks

By leveraging the aecdata library and 2050 Materials’ API, architects and contractors can significantly improve their sustainability practices, making informed decisions based on reliable, science-based data.

Read more
Green Community Concept
Data & Research May 13

In order to measure biodiversity value and foster a future that is nature positive, Ramboll launches Met­ric

The Americas Biodiversity Metric 1.0 is a free biodiversity quantification tool that assists businesses and organizations in achieving their sustainability objectives, which include no net loss of biodiversity, net gain of biodiversity, and transitioning to a more nature-positive state.

Read more
Visualizing Data - Plotting Graphs and Deriving Statistics
Data & Research May 06

AECData Python Library Step 3— Visualizations & Statistical Analysis

Using the open-source Python package aecdata to do statistical analysis and plot graphs.

Read more