mtg_sdk 1.0.1

  • Installing
  • Versions
  • 44


A library for Magic: The Gathering developers working in dart. It uses the official mtg api endpoint at

Created from templates made available by Stagehand under a BSD-style license.


There are two main modules in this library for querying: the sets and cards module. This library is all asynchronous, so familarizing yourself with dart:async at is important.


cards.where(Map properties)

cards.where() returns a list of all cards with specefied properties. The cards are represented by a map of all their properties. It takes in one parameter which is a map of all desired properties. Note that in all queries capitilization is unnecessary, but correct capitilization is necessary when accessing the json. A list of all properties for cards can be found at

import 'package:mtg_sdk/mtg_sdk.dart';
import 'dart:async';

Future<null> main() async {
  List<Map> stdcounters = await cards.where({"gameFormat": "standard", "legality": "legal", "text": "counter target"});
  stdcounters.forEach((e) => print(e["name"]));
Essence Scatter
Metallic Rebuke

Note: There may be different versions of the same card returned (as shown above with cancel).

cards.find(int id)

cards.find() returns a map of all the properties of the desired card. It takes in one parameter which is the multiverse id of the desired card.

import 'package:mtg_sdk/mtg_sdk.dart';
import 'dart:async';

Future<null> main() async {
  print(await cards.find(3369)["name"]);
Teferi's Imp

cards.formats(), cards.types(), cards.supertypes(), and cards.subtypes()

cards.formats(), cards.types(), cards.supertypes(), and cards.subtypes() are general informative functions which each return a list of all their respective information.

import 'package:mtg_sdk/mtg_sdk.dart';
import 'dart:async';

Future<null> main() async {
  print(await cards.formats());
[Amonkhet Block, Battle for Zendikar Block, Classic, Commander, Extended, Ice Age Block, Innistrad Block, Invasion Block, Ixalan    Block, Kaladesh Block, Kamigawa Block...


sets.where(Map properties)

sets.where() is identical to cards.where(), except it queries all sets. A list of all properties for sets can be found at

import 'package:mtg_sdk/mtg_sdk.dart';
import 'dart:async';

Future<null> main() async {
  un = await sets.where({"border": "silver"});
  un.foreach((e) => print(e["name"]));

sets.find(String id)

sets.find() functions the same as cards.find(), except the parameter required is the three letter set code.

import 'package:mtg_sdk/mtg_sdk.dart';
import 'dart:async';

Future<null> main() async {
  print(await sets.find("UST")["name"]);

sets.generateBooster(String id)

sets.generateBooster() returns a simulated booster pack opening of a desired product. This is returned in the form of a list of all cards in the simulated booster, where each card is a map of its properties. It takes in a single paramater that is a three letter set code.

import 'package:mtg_sdk/mtg_sdk.dart';
import 'dart:async';

Future<null> main() async {
  hmlpack = await sets.generateBooster("HML");
  hmlpack.foreach((e) => print(e["name"]))


If you make a query and there is an error with it, (most commonly no cards found with the specefied parameters), an exception will be thrown.

import 'package:mtg_sdk/mtg_sdk.dart';
import 'dart:async';

Future<null> main() async {
  await cards.where({"name": "I'maboutto404", "colors": ["blue"], "power": 2});
Unhandled exception:
Exception: Error 404 while querying. 'Not Found' at'maboutto404 with search terms:
{"name": "I'maboutto404", "colors": ["blue"], "power": 2}

If you have a 404 and suspect that there may be a typo, you can call debug404() on the error. debug404() queries for a single card with each parameter alone and returns all parameters that fail.

import 'package:mtg_sdk/mtg_sdk.dart';
import 'dart:async';

Future<null> main() async {
  try {
    await cards.where({"name": "I'maboutto404", "colors": ["blue"], "power": 2});
  } catch (e) {
    print("Failed properties: ${await e.debug404()}");
Failed properties: {name: I'maboutto404}

If you would like to do error handling yourself or simply do not want errors to be thrown, you can do any of the following. Setting exceptions to false is the recommended of the below, considering that you will likely consistently want or not want errors to be thrown.

sets.exceptions = false;
cards.exceptions = false;
// OR"DOM");{});
// OR


If you have any issues, you can submit a pull request or raise an issue at



1st release!

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:

  mtg_sdk: "^1.0.1"

2. Install it

You can install packages from the command line:

with pub:

$ pub get

with Flutter:

$ flutter packages get

Alternatively, your editor might support pub get or flutter packages get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:

      import 'package:mtg_sdk/mtg_sdk.dart';
Version Uploaded Documentation Archive
1.0.1 May 11, 2018 Go to the documentation of mtg_sdk 1.0.1 Download mtg_sdk 1.0.1 archive
1.0.0 May 11, 2018 Go to the documentation of mtg_sdk 1.0.0 Download mtg_sdk 1.0.0 archive


We analyzed this package on Jul 13, 2018, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.0.0-dev.63.0
  • pana: 0.11.3


Describes how popular the package is relative to other packages. [more]
0 / 100
Code health derived from static analysis. [more]
81 / 100
Reflects how tidy and up-to-date the package is. [more]
99 / 100
Overall score:
Weighted score of the above. [more]
Learn more about scoring.


Detected platforms: Flutter, web, other

No platform restriction found in primary library package:mtg_sdk/mtg_sdk.dart.


  • Fix analysis and formatting issues.

    Analysis or formatting checks reported 1 error 6 hints.

    Strong-mode analysis of lib/src/querybuilder.dart failed with the following error:

    line: 35 col: 33
    The element type 'int' can't be assigned to the list type 'Map'.

    Strong-mode analysis of lib/src/query_exceptions.dart gave the following hint:

    line: 5 col: 14
    The top level variable '_client' isn't used.

  • Maintain an example.

    Create a short demo in the example/ directory to show how to use this package. Common file name patterns include: main.dart, example.dart or you could also use mtg_sdk.dart.


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=1.20.1 <2.0.0
http ^0.11.3+16 0.11.3+17
Transitive dependencies
async 2.0.7
charcode 1.1.2
collection 1.14.10
http_parser 3.1.2
path 1.6.1
source_span 1.4.0
string_scanner 1.0.2
typed_data 1.1.5
Dev dependencies
test ^0.12.0