bl-parts
v1.0.2
Published
BrickLink parts scraper - exports typed part & color data as an npm package
Downloads
428
Readme
bl-parts
Typed BrickLink parts & color data as an importable npm package.
Using the library
npm install bl-partsimport { parts } from "bl-parts";
import type { BrickLinkPart, PartColorData } from "bl-parts";
// All scraped parts
console.log(parts);
// Find a specific part by BrickLink ID
const tile = parts.find((p) => p.id === "98138");
// Iterate colors
tile?.colors.forEach((c: PartColorData) => {
console.log(c.colorName, c.avgPriceCurrent, c.priceClassification);
});Types
interface BrickLinkPart {
id: string;
name: string;
colors: PartColorData[];
}
interface PartColorData {
colorId: number;
colorName: string;
colorHex: string; // e.g. "#FF0000"
avgPriceCurrent: number; // PLN, from BrickLink "Current Items for Sale (New)"
totalQty: number; // total quantity currently for sale (new)
priceClassification: "low" | "high"; // low if avgPriceCurrent <= 0.25
popularityClassification: "low" | "high"; // low if totalQty < 100 000
}Maintaining the data
Scrape fresh data
Add part IDs (comma-separated) to parts.txt, then run:
npm run scrapeThis writes updated data to src/parts-data.json. The scraper uses Puppeteer with stealth to pull price and availability data from BrickLink's catalog pages.
Build
Compiles TypeScript sources (including the embedded JSON data) to dist/:
npm run buildPublish to npm
Bumping the version and publishing:
npm version patch # or minor / major
npm publishprepublishOnly runs npm run build automatically, so the published package always contains the latest compiled output.
Note: Puppeteer and ts-node are devDependencies — consumers of this package install no runtime dependencies.
