| Title: | 'DuckDB'-Backed Query Client for 'MTGJSON' Card Data |
|---|---|
| Description: | Auto-downloads Parquet data from the 'MTGJSON' CDN and exposes the full Magic: The Gathering dataset through R6-based query interfaces backed by 'DuckDB'. |
| Authors: | Robert Pratt [aut, cre], Zachary Halpern [ctb] |
| Maintainer: | Robert Pratt <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 0.1.0 |
| Built: | 2026-10-13 11:53:11 UTC |
| Source: | https://github.com/mtgjson/mtgjson-sdk-r |
MTGJSON SDK - DuckDB-backed query client for MTGJSON card data.
MTGJSON SDK - DuckDB-backed query client for MTGJSON card data.
Auto-downloads Parquet data from the MTGJSON CDN and provides R6-based query interfaces for the full MTG dataset.
cardsCardQuery interface.
setsSetQuery interface.
pricesPriceQuery interface.
decksDeckQuery interface.
sealedSealedQuery interface.
skusSkuQuery interface.
identifiersIdentifierQuery interface.
legalitiesLegalityQuery interface.
tokensTokenQuery interface.
enumsEnumQuery interface.
boosterBoosterSimulator interface.
metaMTGJSON build metadata.
viewsCurrently registered DuckDB views/tables.
new()
Initialize the SDK.
MtgjsonSDK$new( cache_dir = NULL, offline = FALSE, timeout = 120, on_progress = NULL )
cache_dirDirectory for cached data files. NULL for platform default.
offlineIf TRUE, never download from CDN.
timeoutHTTP request timeout in seconds.
on_progressOptional callback function(filename, downloaded, total).
sql()
Execute raw SQL against the DuckDB database.
MtgjsonSDK$sql(query, params = NULL)
querySQL query string.
paramsOptional list of positional parameters.
A data.frame.
refresh()
Check for new MTGJSON data and reset if stale.
MtgjsonSDK$refresh()
TRUE if data was stale and reset, FALSE otherwise.
export_db()
Export all loaded data to a persistent DuckDB file.
MtgjsonSDK$export_db(path)
pathOutput path for the .duckdb file.
The output path (invisibly).
close()
Close the DuckDB connection and free resources.
MtgjsonSDK$close()
clone()
The objects of this class are cloneable with this method.
MtgjsonSDK$clone(deep = FALSE)
deepWhether to make a deep clone.
SQL Builder for parameterized DuckDB queries.
SQL Builder for parameterized DuckDB queries.
All user-supplied values go through DuckDB parameter binding ($1, $2, ...),
never through string interpolation. Methods return invisible(self) for
chaining.
new()
Create a builder targeting the given table or view.
SqlBuilder$new(base_table)
base_tableThe DuckDB table/view name to query from.
select()
Set the columns to select (replaces default *).
SqlBuilder$select(...)
...Column names or expressions.
distinct()
Add DISTINCT to the SELECT clause.
SqlBuilder$distinct()
join()
Add a JOIN clause.
SqlBuilder$join(clause)
clauseFull JOIN clause string.
where()
Add a WHERE condition with $N placeholders.
SqlBuilder$where(condition, ...)
conditionSQL condition with $1, $2, ... placeholders.
...Values bound to the placeholders.
where_like()
Add a case-insensitive LIKE condition.
SqlBuilder$where_like(column, value)
columnColumn name.
valueLIKE pattern.
where_in()
Add an IN condition with parameterized values.
SqlBuilder$where_in(column, values)
columnColumn name.
valuesList of values for the IN clause.
where_eq()
Add an equality condition.
SqlBuilder$where_eq(column, value)
columnColumn name.
valueValue to match.
where_gte()
Add a >= condition.
SqlBuilder$where_gte(column, value)
columnColumn name.
valueMinimum value (inclusive).
where_lte()
Add a <= condition.
SqlBuilder$where_lte(column, value)
columnColumn name.
valueMaximum value (inclusive).
where_regex()
Add a regex match condition.
SqlBuilder$where_regex(column, pattern)
columnColumn name.
patternRegular expression pattern.
where_fuzzy()
Add a fuzzy string match condition (Jaro-Winkler similarity).
SqlBuilder$where_fuzzy(column, value, threshold = 0.8)
columnColumn name.
valueTarget string.
thresholdMinimum similarity score (0-1, default 0.8).
where_or()
Add OR-combined conditions.
SqlBuilder$where_or(...)
...Lists of c(condition_sql, param_value).
group_by()
Add GROUP BY columns.
SqlBuilder$group_by(...)
...Column names or expressions.
having()
Add a HAVING condition.
SqlBuilder$having(condition, ...)
conditionSQL condition with $N placeholders.
...Values bound to the placeholders.
order_by()
Add ORDER BY clauses.
SqlBuilder$order_by(...)
...Order clauses (e.g. "name ASC").
limit()
Set the maximum number of rows to return.
SqlBuilder$limit(n)
nNon-negative integer limit.
offset()
Set the number of rows to skip.
SqlBuilder$offset(n)
nNon-negative integer offset.
build()
Build the final SQL string and parameter list.
SqlBuilder$build()
A list with sql (character) and params (list).
clone()
The objects of this class are cloneable with this method.
SqlBuilder$clone(deep = FALSE)
deepWhether to make a deep clone.