Skip to content
Table of contents

LegosTracker

LegosTracker is an AlgoÉTS data project that looks at LEGO sets as a market: the Rebrickable catalog says which sets, parts and themes exist, and a BrickEconomy scraper adds the prices sets fetch over time. It is meant for collectors and data science readers who want to explore the catalog or test simple price models on one set. The article Economics of LEGO Sets with Data Science tells the story with charts.

Notebooks and data
PythonJupyterPlaywrightPydanticpandasscikit-learnMatplotlibBeautifulSoup
  • Updated

1. Overview

brickeconomy.py reads set numbers from set_list.txt and drives a visible Chromium window with Playwright. For each set it searches BrickEconomy, opens the matching page and extracts the chart rows embedded in the page script: the value history goes to <set>_history.csv and, when present, the four-band price series to <set>_new.csv. It then reads the details, pricing, quick buy, predictions, facts and subtheme panels into Pydantic models and appends them to lego_sets.csv. brickeconomy.ipynb holds the same code with the install commands.

general.ipynb loads the Rebrickable tables in datasets/ (colors, inventories, parts, sets, themes and their links) and plots grouped counts. analyse.ipynb cleans the scraped data/lego_sets.csv and the data/001-1_*.csv files for the 1965 set 001-1, fits linear and gradient boosting regressions on the price history, projects them to 2030, runs a Monte Carlo simulation on log returns and charts yearly gains and the four price bands. price.ipynb takes a personal mycollection.csv, looks up retail and current values on BrickEconomy with requests and BeautifulSoup, and writes updated_mycollection.csv.

2. Use cases

Notebooks and a Playwright scraper to study LEGO sets with Rebrickable data and BrickEconomy price history.

Use-case diagram for LegosTracker: Scrape set prices; Explore the LEGO catalog; Model a set's price history; Compare scraped set prices; Update collection valuesLegosTrackerScrape set pricesExplore the LEGO catalogModel a set's price historyCompare scraped set pricesUpdate collection valuesLEGO collector«system»BrickEconomy website«system»Rebrickable exports
People on the left, external systems on the right; each oval is a use case backed by the files cited below.
Scrape set prices
LEGO collectorBrickEconomy website

brickeconomy.py reads set_list.txt, opens each set on BrickEconomy with Playwright Chromium, writes <set>_history.csv and <set>_new.csv from the page charts and appends details and pricing to lego_sets.csv.

Explore the LEGO catalog
LEGO collectorRebrickable exports

general.ipynb loads the Rebrickable CSV tables in datasets/ (colors, inventories, parts, sets, themes) and plots counts such as transparent versus opaque colors.

Model a set's price history
LEGO collector

analyse.ipynb cleans data/001-1_history.csv, fits linear and gradient boosting regressions on dates, projects to 2030, runs a Monte Carlo on log returns and plots the price bands in data/001-1_new.csv.

Compare scraped set prices
LEGO collector

analyse.ipynb loads data/lego_sets.csv, strips currency symbols and reports the lowest and highest Quick Buy price and the average Pricing value.

Update collection values
LEGO collectorBrickEconomy website

price.ipynb reads mycollection.csv, looks up each set on BrickEconomy search with requests and BeautifulSoup for retail and current values, and writes updated_mycollection.csv.

2.1. Scenario: Track the price of set 001-1

  1. Install playwright, pydantic and aiohttp and run playwright install, as in brickeconomy.ipynb.
  2. List set numbers such as 001-1 in set_list.txt, one per line.
  3. Run python brickeconomy.py; a visible Chromium window searches BrickEconomy and opens each set page.
  4. Move the generated 001-1_history.csv, 001-1_new.csv and lego_sets.csv into data/, where analyse.ipynb reads them.
  5. Run analyse.ipynb to plot the history, fit the regressions and simulate future prices.

Files readREADME.mdbrickeconomy.pybrickeconomy.ipynbanalyse.ipynbgeneral.ipynbprice.ipynbset_list.txtmycollection.csvdata/lego_sets.csvdata/001-1_history.csvdata/001-1_new.csv

3. Getting started

brickeconomy.ipynb installs the scraper dependencies:

pip install playwright asyncio pydantic aiohttp
playwright install
python brickeconomy.py

The script writes its CSV files in the current directory; analyse.ipynb reads them from data/. The notebooks need pandas, NumPy, Matplotlib, seaborn and scikit-learn (installed by the first cell of analyse.ipynb), plus requests and BeautifulSoup for price.ipynb:

pip install pandas matplotlib seaborn scikit-learn numpy
jupyter notebook

4. Repository guide

  • brickeconomy.py is the Playwright scraper for BrickEconomy set pages.
  • set_list.txt lists the set numbers to scrape (001-1 to 0016-1 and 002-1).
  • data/ holds scraped output: lego_sets.csv and one _history.csv per set, plus 001-1_new.csv.
  • datasets/ holds the Rebrickable exports as CSV and .csv.gz; the README documents their columns, and images/downloads_schema_v3.webp shows the schema.
  • general.ipynb explores the Rebrickable catalog.
  • analyse.ipynb cleans scraped prices and models the history of set 001-1.
  • price.ipynb updates the values of the sets in mycollection.csv.

5. Features

  • scrape BrickEconomy value history, price bands and set panels for a list of sets;
  • explore Rebrickable colors, inventories, parts, sets and themes;
  • compare scraped prices across sets (lowest, highest, average);
  • fit linear and gradient boosting regressions on a set’s price history and project them;
  • simulate future prices with a Monte Carlo model on log returns;
  • update the current value of a personal collection.

6. Limits

  • There is no requirements file; dependencies come from !pip install cells in the notebooks.
  • The scraper depends on BrickEconomy’s page structure and CSS selectors, runs a visible browser and stops with an error when a search returns no link.
  • Output files are written in the working directory, not in data/, so they must be moved before running analyse.ipynb.
  • The scraped data covers nine sets; the price models work on a single set (001-1) and are illustrations, not forecasts.
  • price.ipynb reads only the first table of the BrickEconomy search page and defines a TAX_RATE constant that it never uses.
  • The Rebrickable exports are a dated snapshot; the repository has no script to refresh them.

7. Sources

8. CI/CD pipeline

No CI/CD pipeline in the repository. The code is built and run by hand, as described above.

Generated from the source at commit c24d7e7.

9. Deployment diagram

Mermaid Deployment diagram
flowchart LR
  repo[("GitHub repository")]
  local["Local machine"]
  repo -->|"clone and run"| local

The repository has no Dockerfile, Compose file or hosting configuration, so the code runs on the machine that clones it.

10. External dependencies

The repository declares no external packages: it has no manifest such as pyproject.toml, requirements.txt, package.json or pom.xml.

11. Glossary

Repository

The versioned source files, configuration, and history of a project.

README

The repository’s entry document, usually covering its purpose and initial setup.

Dependency

A library, tool, or service that another component needs to build or run.

HTTP

A request-and-response protocol used by browsers and web services. A method, path, headers, and optional body describe a request.

Published port

A host port mapped to a service’s container port. Publishing a port can expose that service beyond its container network.

CLI

A text interface in which commands and arguments select operations. Exit codes let scripts detect success or failure.

12. References

  1. AlgoETS. (2026, November 5). LegosTracker. [Software repository] github.com.
  2. AlgoETS. (2026, November 5). README. [Source file or documentation] github.com.
  3. AlgoETS. (2026, November 5). brickeconomy.py. [Source file or documentation] github.com.
  4. AlgoETS. (2026, November 5). analyse.ipynb. [Source file or documentation] github.com.
  5. AlgoETS. (2026, November 5). general.ipynb. [Source file or documentation] github.com.
  6. AlgoETS. (2026, November 5). price.ipynb. [Source file or documentation] github.com.
  7. hevalhazalkurt. (2026, November 5). exploring_the_data_of_LEGO_history. [Software repository] github.com.

Sources without a publication date show the date they were last checked, November 5, 2026. File links retain the inspected revision where available.