magiclegacy / mtgjson-client
PHP SDK client to get data from mtgjson.com.
Installs: 53
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 1
Open Issues: 0
pkg:composer/magiclegacy/mtgjson-client
Requires
- php: 7.4.*|8.0.*|8.1.*
- ext-curl: *
- ext-json: *
- eureka/component-curl: ^2.0
- psr/http-client: ^1.0
- psr/http-factory: ^1.0
- psr/log: ^1.1|^2.0|^3.0
- thecodingmachine/safe: ^1.3
Requires (Dev)
- dealerdirect/phpcodesniffer-composer-installer: ^v0.7
- dg/bypass-finals: ^1.4
- phpstan/phpstan: ^1.9
- phpunit/phpcov: ^8.2
- phpunit/phpunit: ^9.5
- squizlabs/php_codesniffer: ^3.7
This package is auto-updated.
Last update: 2025-10-22 17:10:59 UTC
README
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