MyNixOS website logo
Description

Interface with the Brickset API for Getting Data About LEGO Sets.

Interface with the 'Brickset' API <https://brickset.com/article/52664/api-version-3-documentation> for getting data about LEGO sets. Data sets that can be used for teaching and learning without the need of a 'Brickset' account and API key are also included. Includes all LEGO since through the end of 2023.

brickset: An R Package to Interface with the Brickset API for Getting Data About LEGO sets

R-CMD-check CRANStatus

Author: Jason Bryer, Ph.D. [email protected]
Website:https://jbryer.github.io/brickset/

This package provides functions to access data about LEGO sets from the Brickset website. The package also contains a data.frame with all LEGO sets (n = 18,455) from 1970 through 2022. This data set was created using the getSets function and it is recommended that you use this data frame to reduce the number of API calls. See the build.R script for how the data frame was created. Information about the variables is included below.

Installation

You can download from CRAN using:

install.packages('brickset')

Or the latest development version using the remotes package:

remotes::install_github('jbryer/brickset')

Brickset API

To use the Brickset API, you must first create a Brickset account and request an API key. The full Brickset API documentation is available here: https://brickset.com/article/52664/api-version-3-documentation

Most of the functions require a Brickset username, password, and API key. You can pass these as parameters, or you can set these options:

options(brickset_key = 'YOUR_API_KEY',
        brickset_username = 'YOUR_USERNAME',
        brickset_password = 'YOUR_PASSWORD')

The checkKey function will verify that your API key is valid:

brickset::checkKey()
#> [1] TRUE

You can check your API usage with the getKeyUsageStats function.

brickset::getKeyUsageStats()
#>              dateStamp count
#> 1 2023-03-30T00:00:00Z     3
#> 2 2023-03-24T00:00:00Z     2
#> 3 2023-03-23T00:00:00Z     2
#> 4 2023-03-22T00:00:00Z    16
#> 5 2023-03-21T00:00:00Z     2

The getSets function returns all LEGO sets from the given year.

sets2021 <- brickset::getSets(2021)
head(sets2021, n = 3)
#>   setID                     name year theme   themeGroup
#> 1 31026           Police Station 2021 Icons Model making
#> 2 31754 Volkswagen T2 Camper Van 2021 Icons Model making
#> 3 31025           Flower Bouquet 2021 Icons Model making
#>                       subtheme category released pieces minifigs
#> 1 Modular Buildings Collection   Normal     TRUE   2923        5
#> 2                     Vehicles   Normal     TRUE   2207       NA
#> 3         Botanical Collection   Normal     TRUE    756       NA
#>                         bricksetURL rating reviewCount packagingType
#> 1 https://brickset.com/sets/10278-1    4.4           4           Box
#> 2 https://brickset.com/sets/10279-1    4.1           0           Box
#> 3 https://brickset.com/sets/10280-1    4.3           3           Box
#>     availability agerange_min US_retailPrice US_dateFirstAvailable
#> 1 LEGO exclusive           18         199.99  2021-01-02T00:00:00Z
#> 2 LEGO exclusive           18         179.99  2021-08-02T00:00:00Z
#> 3         Retail           18          59.99  2021-01-02T00:00:00Z
#>   US_dateLastAvailable UK_retailPrice UK_dateFirstAvailable
#> 1                 <NA>         169.99  2021-01-01T00:00:00Z
#> 2 2022-11-12T00:00:00Z         139.99  2021-08-01T00:00:00Z
#> 3                 <NA>          54.99  2021-01-01T00:00:00Z
#>   UK_dateLastAvailable CA_retailPrice CA_dateFirstAvailable
#> 1                 <NA>         269.99  2021-01-02T00:00:00Z
#> 2 2022-11-29T00:00:00Z         249.99  2021-08-03T00:00:00Z
#> 3                 <NA>          79.99  2021-01-02T00:00:00Z
#>   CA_dateLastAvailable DE_retailPrice DE_dateFirstAvailable
#> 1                 <NA>         199.99  2021-01-02T00:00:00Z
#> 2 2022-11-12T00:00:00Z         159.99  2021-08-02T00:00:00Z
#> 3                 <NA>          59.99  2021-01-02T00:00:00Z
#>   DE_dateLastAvailable height width depth weight
#> 1                 <NA>   47.6  57.7  11.8  4.012
#> 2 2022-11-30T00:00:00Z   37.4  57.8  11.2  2.945
#> 3                 <NA>   38.2  26.2   7.1  0.760
#>                                         thumbnailURL
#> 1 https://images.brickset.com/sets/small/10278-1.jpg
#> 2 https://images.brickset.com/sets/small/10279-1.jpg
#> 3 https://images.brickset.com/sets/small/10280-1.jpg
#>                                              imageURL
#> 1 https://images.brickset.com/sets/images/10278-1.jpg
#> 2 https://images.brickset.com/sets/images/10279-1.jpg
#> 3 https://images.brickset.com/sets/images/10280-1.jpg

The getReviews function will return all reviews for a given set.

reviews29830 <- brickset::getReviews(29830)
names(reviews29830)
#>  [1] "author"             "datePosted"         "title"             
#>  [4] "review"             "HTML"               "overall"           
#>  [7] "parts"              "buildingExperience" "playability"       
#> [10] "valueForMoney"

The getThemes and getSubthemes returns information about LEGO themes.

getThemes() |> head(n = 3)
#>             theme setCount subthemeCount yearFrom yearTo
#> 1    {Unknown IP}        5             0     2023   2023
#> 2       4 Juniors       24             5     2003   2004
#> 3 Action Wheelers        9             0     2000   2001
getSubthemes('Toy Story')
#>       theme          subtheme setCount yearFrom yearTo
#> 1 Toy Story Buildable Figures        2     2010   2010
#> 2 Toy Story     Original Film        2     2010   2010
#> 3 Toy Story       Toy Story 2        3     2010   2010
#> 4 Toy Story       Toy Story 3        8     2010   2010
getYears('Toy Story')
#>       theme year setCount
#> 1 Toy Story 2010       15

The getInstructions will return a table with the URLs to the building instructions.

instructions <- getInstructions(setID = 29830)
instructions
#>                                                                       URL
#> 1 https://www.lego.com/cdn/product-assets/product.bi.core.pdf/6313846.pdf
#> 2 https://www.lego.com/cdn/product-assets/product.bi.core.pdf/6313848.pdf
#> 3 https://www.lego.com/cdn/product-assets/product.bi.core.pdf/6313849.pdf
#> 4 https://www.lego.com/cdn/product-assets/product.bi.core.pdf/6313850.pdf
#>                             description
#> 1 BI 3103, 112+4/65+200G, 10270 V29 1/2
#> 2   BI 3103, 96+4/65+200G,10270 V29 2/2
#> 3   BI 3103, 112+4/65+200G, V39/142 1/2
#> 4    BI 3103, 96+4/65+200G, V39/142 2/2

legosets Dataset

The legosets data frame contains all LEGO sets (n = 18,455) from 1970 through 2022.

data("legosets", package = "brickset")
ggplot(legosets, aes(x = year)) + geom_bar() +
    ggtitle('Number of LEGO sets by year') +
    xlab('Year') + ylab('Number of LEGO Sets')
ggplot(legosets, aes(x = pieces, y = US_retailPrice)) + 
    geom_point() +
    ggtitle('Cost of LEGO sets by number of pieces') +
    xlab('Number of LEGO pieces') + ylab('US Retail Price (dollars)')

The variables in the legosets data frame are:

TypeUnique_Values
setIDinteger18455
namecharacter15372
yearinteger53
themecharacter154
themeGroupcharacter16
subthemecharacter901
categorycharacter7
releasedlogical2
piecesinteger1403
minifigsinteger34
bricksetURLcharacter18455
ratingnumeric31
reviewCountinteger64
packagingTypecharacter18
availabilitycharacter10
agerange_mininteger16
US_retailPricenumeric142
US_dateFirstAvailableDate881
US_dateLastAvailableDate2125
UK_retailPricenumeric210
UK_dateFirstAvailableDate825
UK_dateLastAvailableDate1984
CA_retailPricenumeric162
CA_dateFirstAvailableDate641
CA_dateLastAvailableDate1808
DE_retailPricenumeric155
DE_dateFirstAvailableDate428
DE_dateLastAvailableDate1176
heightnumeric241
widthnumeric286
depthnumeric279
weightnumeric1046
thumbnailURLcharacter17420
imageURLcharacter17420

Code of Conduct

Please note that the brickset project is released with a Contributor Code of Conduct. By contributing to this project, you agree to abide by its terms.

Metadata

Version

2024.0.0

License

Unknown

Platforms (75)

    Darwin
    FreeBSD
    Genode
    GHCJS
    Linux
    MMIXware
    NetBSD
    none
    OpenBSD
    Redox
    Solaris
    WASI
    Windows
Show all
  • aarch64-darwin
  • aarch64-genode
  • aarch64-linux
  • aarch64-netbsd
  • aarch64-none
  • aarch64_be-none
  • arm-none
  • armv5tel-linux
  • armv6l-linux
  • armv6l-netbsd
  • armv6l-none
  • armv7a-darwin
  • armv7a-linux
  • armv7a-netbsd
  • armv7l-linux
  • armv7l-netbsd
  • avr-none
  • i686-cygwin
  • i686-darwin
  • i686-freebsd
  • i686-genode
  • i686-linux
  • i686-netbsd
  • i686-none
  • i686-openbsd
  • i686-windows
  • javascript-ghcjs
  • loongarch64-linux
  • m68k-linux
  • m68k-netbsd
  • m68k-none
  • microblaze-linux
  • microblaze-none
  • microblazeel-linux
  • microblazeel-none
  • mips-linux
  • mips-none
  • mips64-linux
  • mips64-none
  • mips64el-linux
  • mipsel-linux
  • mipsel-netbsd
  • mmix-mmixware
  • msp430-none
  • or1k-none
  • powerpc-netbsd
  • powerpc-none
  • powerpc64-linux
  • powerpc64le-linux
  • powerpcle-none
  • riscv32-linux
  • riscv32-netbsd
  • riscv32-none
  • riscv64-linux
  • riscv64-netbsd
  • riscv64-none
  • rx-none
  • s390-linux
  • s390-none
  • s390x-linux
  • s390x-none
  • vc4-none
  • wasm32-wasi
  • wasm64-wasi
  • x86_64-cygwin
  • x86_64-darwin
  • x86_64-freebsd
  • x86_64-genode
  • x86_64-linux
  • x86_64-netbsd
  • x86_64-none
  • x86_64-openbsd
  • x86_64-redox
  • x86_64-solaris
  • x86_64-windows