A php API wrapper to connect to mtgjson.com API
A php API wrapper to connect to mtgjson.com API. This version supports the 4.6.3 (2020-04-22) version of the MTGJSON API.
When a new version is released by mtgjson, feel free to open a new issue to signal the change, or even propose a PR for the update !
From 4.6.1, this library does not follow semver, but follows the version numbers of the mtgjson.com json api.
The installation of this library is made via composer.
Download composer.phar
from their website.
Then add to your composer.json :
"require": {
...
"php-mtg/php-mtgjson-com-api": "^4.6.3",
...
}
Then run php composer.phar update
to install this library.
The autoloading of all classes of this library is made through composer's autoloader.
For the basic functions, use :
use PhpMtg\MtgjsonApi\MtgjsonApiEndpoint;
/* @var $client \Psr\Http\Client\ClientInterface */
/* @var $uriFactory \Psr\Http\Message\UriFactoryInterface */
/* @var $requestFactory \Psr\Http\Message\RequestFactoryInterface */
$endpoint = new MtgjsonApiEndpoint($client, $uriFactory, $requestFactory);
$endpoint->getAllPrintings(); // returns a JsonCollection with MtgjsonApiSet elements
$endpoint->getAllPrices(); // returns a MtgjsonApiCardPriceCollection
$endpoint->getAllCards(); // returns a JsonCollection with MtgjsonApiCard elements
$endpoint->getCardTypes(); // returns a MtgjsonApiCardTypeCollection
$endpoint->getDeckLists(); // returns a MtgjsonApiDeckCollection
$endpoint->getDeck('FaerieSchemes_ELD'); // returns a MtgjsonApiDeck
$endpoint->getKeywords(); // returns a MtgjsonKeywordCollection
$endpoint->getLegacyCards(); // returns a JsonCollection with MtgjsonApiCard elements
$endpoint->getLegacyPrintings(); // returns a JsonCollection with MtgjsonApiSet elements
$endpoint->getPauperCards(); // returns a JsonCollection with MtgjsonApiCard elements
$endpoint->getPioneerCards(); // returns a JsonCollection with MtgjsonApiCard elements
$endpoint->getPioneerPrintings(); // returns a JsonCollection with MtgjsonApiSet elements
$endpoint->getModernCards(); // returns a JsonCollection with MtgjsonApiCard elements
$endpoint->getModernPrintings(); // returns a JsonCollection with MtgjsonApiSet elements
$endpoint->getSetList(); // returns a JsonCollection with MtgjsonApiSetResume elements
$endpoint->getSet('ARB'); // returns a MtgjsonApiSet
$endpoint->getStandardCards(); // returns a JsonCollection with MtgjsonApiCard elements
$endpoint->getStandardPrintings(); // returns a JsonCollection with MtgjsonApiSet elements
$endpoint->getVersion(); // returns a MtgjsonApiVersion
$endpoint->getVintageCards(); // returns a JsonCollection with MtgjsonApiCard elements
$endpoint->getVintagePrintings(); // returns a JsonCollection with MtgjsonApiSet elements
The getSetInfo()
arguments are found with the getSetCodes()
function.
This function also returns all the cards data for the given set.
For the packages that are useful at getting http requests (HttpProcessor),
see the require-dev
of the composer.json
file.
MIT (See license file).