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

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