Title: | Interface with the Brickset API for Getting Data About LEGO Sets |
---|---|
Description: | 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. |
Authors: | Jason Bryer [aut, cre] |
Maintainer: | Jason Bryer <[email protected]> |
License: | GPL (>= 3) |
Version: | 2024.0.0 |
Built: | 2025-01-03 06:15:15 UTC |
Source: | https://github.com/jbryer/brickset |
R package to interface with the Brickset API for getting data about LEGO.
You can request an API key on the Brickset website here: https://brickset.com/tools/webservices/requestkey/
The API key can be passed as function parameter or may be set globally using:
options(brickset_key = YOUR_API_KEY)
You can request an API key on the Brickset website here: https://brickset.com/tools/webservices/requestkey/
checkKey(key = getOption("brickset_key"))
checkKey(key = getOption("brickset_key"))
key |
the Brickset API key |
The API key can be passed as function parameter or may be set globally using:
options(brickset_key = YOUR_API_KEY)
Brickset API documentation is available here: https://brickset.com/article/52664/api-version-3-documentation
TRUE if the API key is valid.
## Not run: options(brickset_key = 'BRICKSET_KEY', brickset_username = 'BRICKSET_UERNAME', brickset_password = 'BRICKSET_PASSWORD') checkKey() # Will return TRUE if the credentials are correct ## End(Not run)
## Not run: options(brickset_key = 'BRICKSET_KEY', brickset_username = 'BRICKSET_UERNAME', brickset_password = 'BRICKSET_PASSWORD') checkKey() # Will return TRUE if the credentials are correct ## End(Not run)
You can request an API key on the Brickset website here: https://brickset.com/tools/webservices/requestkey/
checkUserHash(key = getOption("brickset_key"), userHash)
checkUserHash(key = getOption("brickset_key"), userHash)
key |
the API key |
userHash |
the user hash returned from login. |
Brickset API documentation is available here: https://brickset.com/article/52664/api-version-3-documentation/
TRUE if the API key is fine.
This function will return a data frame with all the reviews as of last package
build. Since this data frame is larger than what is allowed in CRAN packages,
the data files are saved as releases on Github. The piggyback::pb_upload()
function is used to upload the data frame.
download_reviews(dest = tempdir(), ...)
download_reviews(dest = tempdir(), ...)
dest |
directory to download the |
... |
other parameters passed to |
To see what versions are available use the piggyback::pb_list(repo = 'jbryer/brickset')
function call. By default the latest version will be returned. For reproducibility
you can use the tag
parameter to return a specific version of the data frame.
a data frame with all the reviews as of the tag date.
Brickset API documentation is available here: https://brickset.com/article/52664/api-version-3-documentation/
getInstructions(setID, setNumber, key = getOption("brickset_key"), ...)
getInstructions(setID, setNumber, key = getOption("brickset_key"), ...)
setID |
the ID of the set (see |
setNumber |
the set number from on the LEGO box |
key |
the Brickset API key. |
... |
other parameters passed to |
a data.frame with the instructions.
Provides information about how frequently the API key has been used.
getKeyUsageStats(key = getOption("brickset_key"))
getKeyUsageStats(key = getOption("brickset_key"))
key |
the API key |
a data.frame with the number of times the key has been used.
The date
The number of times the key was used for the given date
## Not run: options(brickset_key = 'BRICKSET_KEY', brickset_username = 'BRICKSET_UERNAME', brickset_password = 'BRICKSET_PASSWORD') getKeyUsageStats() ## End(Not run)
## Not run: options(brickset_key = 'BRICKSET_KEY', brickset_username = 'BRICKSET_UERNAME', brickset_password = 'BRICKSET_PASSWORD') getKeyUsageStats() ## End(Not run)
Downloads reviews for a LEGO set.
getReviews(setID, key = getOption("brickset_key"), ...)
getReviews(setID, key = getOption("brickset_key"), ...)
setID |
the ID of the set (see |
key |
the Brickset API key. |
... |
other parameters passed to |
a data.frame with the reviews.
Author of the review
Date of the review
Title of the review
The text of the review
TRUE if the review contains HTML
overall rating by the reviewer
rating for the parts
rating for the building experience
rating for the playability
rating for the value for money
## Not run: options(brickset_key = 'BRICKSET_KEY', brickset_username = 'BRICKSET_UERNAME', brickset_password = 'BRICKSET_PASSWORD') getReviews('31728') # Will return TRUE if the credentials are correct ## End(Not run)
## Not run: options(brickset_key = 'BRICKSET_KEY', brickset_username = 'BRICKSET_UERNAME', brickset_password = 'BRICKSET_PASSWORD') getReviews('31728') # Will return TRUE if the credentials are correct ## End(Not run)
Brickset API documentation is available here: https://brickset.com/article/52664/api-version-3-documentation/
getSets(year, key = getOption("brickset_key"), ...)
getSets(year, key = getOption("brickset_key"), ...)
year |
the year of data to download. |
key |
the Brickset key. |
... |
other parameters passed to |
a data.frame with all sets from the given year.
integer; 19409 unique values
character; 17997 unique values
integer; 25 unique values
character; 16206 unique values
integer; 54 unique values
character; 158 unique values
character; 17 unique values
character; 957 unique values
character; 7 unique values
logical; 2 unique values
integer; 1461 unique values
integer; 34 unique values
character; 19409 unique values
numeric; 30 unique values
integer; 63 unique values
character; 19 unique values
character; 10 unique values
integer; 17 unique values
character; 18355 unique values
character; 18355 unique values
numeric; 154 unique values
Date; 979 unique values
Date; 2197 unique values
numeric; 226 unique values
Date; 927 unique values
Date; 2068 unique values
numeric; 177 unique values
Date; 745 unique values
Date; 1880 unique values
numeric; 173 unique values
Date; 514 unique values
Date; 1252 unique values
numeric; 248 unique values
numeric; 290 unique values
numeric; 282 unique values
numeric; 1107 unique values
Brickset API documentation is available here: https://brickset.com/article/52664/api-version-3-documentation/
getSubthemes(theme, key = getOption("brickset_key"), ...)
getSubthemes(theme, key = getOption("brickset_key"), ...)
theme |
the theme. |
key |
the Brickset API key. |
... |
other parameters passed to |
a data.frame with the subthemes.
Brickset API documentation is available here: https://brickset.com/article/52664/api-version-3-documentation/
getThemes(key = getOption("brickset_key"), ...)
getThemes(key = getOption("brickset_key"), ...)
key |
the Brickset API key. |
... |
other parameters passed to |
a data.frame with the themes.
## Not run: options(brickset_key = 'BRICKSET_KEY', brickset_username = 'BRICKSET_UERNAME', brickset_password = 'BRICKSET_PASSWORD') getThemes() ## End(Not run)
## Not run: options(brickset_key = 'BRICKSET_KEY', brickset_username = 'BRICKSET_UERNAME', brickset_password = 'BRICKSET_PASSWORD') getThemes() ## End(Not run)
Many of the Brickset API calls require a user to login. This function wraps
the login
function to managing the user hash returned from
login across multiple API calls. It will also ensure that the hash is still
valid and if it expired a new hash will be requested.
getUserHash( username = getOption("brickset_username"), password = getOption("brickset_password"), key = getOption("brickset_key") )
getUserHash( username = getOption("brickset_username"), password = getOption("brickset_password"), key = getOption("brickset_key") )
username |
the Brickset username. |
password |
the Brickset password. |
key |
the Brickset API key. |
Brickset API documentation is available here: https://brickset.com/article/52664/api-version-3-documentation/
the user hash for the current API session.
Get a list of years for a given theme, with the total number of sets in each.
getYears(theme, key = getOption("brickset_key"), ...)
getYears(theme, key = getOption("brickset_key"), ...)
theme |
the theme |
key |
the Brickset API key. |
... |
other parameters passed to |
a data.frame with the years of a given theme.
Name of the theme
Year
Number of sets released in the given year and theme
## Not run: options(brickset_key = 'BRICKSET_KEY', brickset_username = 'BRICKSET_UERNAME', brickset_password = 'BRICKSET_PASSWORD') getYears('Architecture') ## End(Not run)
## Not run: options(brickset_key = 'BRICKSET_KEY', brickset_username = 'BRICKSET_UERNAME', brickset_password = 'BRICKSET_PASSWORD') getYears('Architecture') ## End(Not run)
This dataset was built using the getSets
function. For working
with the LEGO sets data frame this pre-built data is preferred as it will
minimize the API requests. Note that the only disadvantage is that the
rating
and reviewCount
may be out-of-date and inaccurate. The
remaining variables are relatively static.
A data.frame.
integer; 19409 unique values
character; 17997 unique values
integer; 25 unique values
character; 16206 unique values
integer; 54 unique values
character; 158 unique values
character; 17 unique values
character; 957 unique values
character; 7 unique values
logical; 2 unique values
integer; 1461 unique values
integer; 34 unique values
character; 19409 unique values
numeric; 30 unique values
integer; 63 unique values
character; 19 unique values
character; 10 unique values
integer; 17 unique values
character; 18355 unique values
character; 18355 unique values
numeric; 154 unique values
Date; 979 unique values
Date; 2197 unique values
numeric; 226 unique values
Date; 927 unique values
Date; 2068 unique values
numeric; 177 unique values
Date; 745 unique values
Date; 1880 unique values
numeric; 173 unique values
Date; 514 unique values
Date; 1252 unique values
numeric; 248 unique values
numeric; 290 unique values
numeric; 282 unique values
numeric; 1107 unique values
Brickset API documentation is available here: https://brickset.com/article/52664/api-version-3-documentation/
login( username = getOption("brickset_username"), password = getOption("brickset_password"), key = getOption("brickset_key") )
login( username = getOption("brickset_username"), password = getOption("brickset_password"), key = getOption("brickset_key") )
username |
the Brickset username. |
password |
the Brickset password. |
key |
the Brickset API key. |
the user hash used for other API calls.