Skip to content

Repository files navigation

MtgJson Client for API V5

Current version Supported PHP version Coverage Quality Gate Status CI

MtgJson Client to retrieve some information from MtgJson.com

Supported endpoints:

  • /SetList.json
  • /{SetCode}.json
  • /CardTypes.json
  • /AtomicCards.json
  • /LegacyAtomic.json
  • /PauperAtomic.json
  • /PioneerAtomic.json
  • /ModernAtomic.json
  • /StandardAtomic.json
  • /VintageAtomic.json

Currently NOT supported:

  • /EnumValues.json
  • /Keywords.json
  • /Legacy.json
  • /Pioneer.json
  • /Modern.json
  • /Standard.json
  • /Vintage.json
  • /CompiledList
  • /DeckList

Composer

composer require magiclegacy/mtgjson-client

Usage in application

<?php

namespace Application;

use MagicLegacy\Component\MtgJson\Client\MtgJsonClient;
use Eureka\Component\Curl;
use Nyholm\Psr7\Factory\Psr17Factory;
use Psr\Log\NullLogger;

//~ Declare tier required services (included as dependencies)
$httpFactory   = new Psr17Factory();
$mtgJsonClient = new MtgJsonClient(
    new Curl\HttpClient(),
    $httpFactory,
    $httpFactory,
    $httpFactory,
    new NullLogger()
);

$setList = $mtgJsonClient->getList();

foreach ($setList as $setBasic) {

    echo (string) $setBasic->getCode() . ' - ' . $setBasic->getName() . PHP_EOL;
}

see: example.php

The output will be:

P15A - 15th Anniversary Cards
HTR - 2016 Heroes of the Realm
G17 - 2017 Gift Pack
HTR17 - 2017 Heroes of the Realm
PLNY - 2018 Lunar New Year
AER - Aether Revolt
PAER - Aether Revolt Promos
ARB - Alara Reborn
ALL - Alliances
AKH - Amonkhet
MP2 - Amonkhet Invocations
PAKH - Amonkhet Promos
AKR - Amonkhet Remastered
ATH - Anthologies
ATQ - Antiquities
APC - Apocalypse
[...]
PWOR - World Championship Promos
PWCQ - World Magic Cup Qualifiers
WWK - Worldwake
PWWK - Worldwake Promos
PSS2 - XLN Standard Showdown
PXTC - XLN Treasure Chest
ZEN - Zendikar
EXP - Zendikar Expeditions
PZEN - Zendikar Promos

MtgJsonClient

About Sets

Available methods:

  • MtgJsonClient::getList(): SetBasic[]
  • MtgJsonClient::get($setCode): Set[]

About Atomic Cards

Available methods:

  • MtgJsonClient::getAllAtomicCards(): AtomicCard[]
  • MtgJsonClient::getLegacyAtomicCards(): AtomicCard[]
  • MtgJsonClient::getModernAtomicCards(): AtomicCard[]
  • MtgJsonClient::getPauperAtomicCards(): AtomicCard[]
  • MtgJsonClient::getPioneerAtomicCards(): AtomicCard[]
  • MtgJsonClient::getStandardAtomicCards(): AtomicCard[]
  • MtgJsonClient::getVintageAtomicCards(): AtomicCard[]

About Card Types

Available methods:

  • MtgJsonClient::getCardTypes(): CardTypes

About

PHP SDK client for mtgjson.com

Topics

Resources

Contributing

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages