DiscordPHP-MTG Documentation

CardAttributes

This query will return a maximum of 100 cards.

Paginate the response using the page parameter.

Each field below can be used as a query parameter. By default, fields that have a singular value such as rarity, set, and name will always use a logical “or” operator when querying with a list of values. Fields that can have multiple values such as colors, supertypes, and subtypes can use a logical “and” or a logical “or” operator.

The accepted delimiters when querying fields are the pipe character or a comma character. The pipe represents a logical “or”, and a comma represents a logical “and”. The comma can only be used with fields that accept multiple values (like colors).

Example:name=nissa, worldwaker|jace|ajani, caller More examples: colors=red,white,blue versus colors=red|white|blue

Tags
link
https://docs.magicthegathering.io/#api_v1cards_list
since

v1.0.0

@property-read

$watermark

$timeshifted

$hand

$life

$reserved

$starter

$foreignNames

$printings

$originalText

$originalType

$legalities

$source

Table of Contents

Properties

$artist  : ?string|null
$border  : ?string|null
$cmc  : int
$colorIdentity  : ?array<string|int, string>|null
$colors  : ?array<string|int, string>|null
$contains  : ?string|null
$flavor  : ?string|null
$gameFormat  : ?string|null
$id  : ?string|null
$imageUrl  : ?string|null
$language  : ?string|null
$layout  : ?string|null
$legality  : ?string|null
$loyalty  : ?int|null
$manaCost  : ?string|null
$multiverseid  : ?int|null
$name  : ?string|null
$names  : ?array<string|int, mixed>|null
$number  : ?string|null
$orderBy  : ?string|null
$page  : ?int|null
$pageSize  : ?int|null
$power  : ?string|null
$random  : ?string|null
$rarity  : ?string|null
$releaseDate  : ?Carbon|null
$rulings  : ?ExCollectionInterface<string|int, Rulings>|array<string|int, Rulings>|null
$set  : ?string|null
$setName  : ?string|null
$subtypes  : ?array<string|int, string>|null
$supertypes  : ?array<string|int, string>|null
$text  : ?string|null
$toughness  : ?string|null
$type  : ?string|null
$types  : ?array<string|int, string>|null
$variations  : ?array<string|int, mixed>|null

Methods

getArtist()  : string|null
Gets the name of the artist who illustrated the card.
getCmc()  : int
Gets the converted mana cost of the card.
getColorIdentity()  : array<string|int, string>|null
Gets the color identity of the card.
getColors()  : array<string|int, string>|null
Gets the colors of the card.
getContains()  : string|null
Gets the "contains" field filter.
getFlavor()  : string|null
Gets the card's flavor text.
getGameFormat()  : string|null
Gets the game format used to filter legality.
getId()  : string|null
Gets the card's unique id.
getLanguage()  : string|null
Gets the language used when querying foreign card names.
getLayout()  : string|null
Gets the layout of the card.
getLegality()  : string|null
Gets the legality status used to filter results.
getLoyalty()  : int|null
Gets the planeswalker's starting loyalty.
getMultiverseid()  : int|null
Gets the card's Gatherer multiverse id.
getName()  : string|null
Gets the name of the card.
getNumber()  : string|null
Gets the card's collector number within its set.
getOrderBy()  : string|null
Gets the field results are ordered by.
getPage()  : int|null
Gets the results page number.
getPageSize()  : int|null
Gets the number of results per page.
getPower()  : string|null
Gets the creature's power.
getRandom()  : bool|null
Gets whether a random card was requested.
getRarity()  : string|null
Gets the rarity of the card.
getSet()  : string|null
Gets the code of the set the card belongs to.
getSetName()  : string|null
Gets the full name of the set the card belongs to.
getSubtypes()  : array<string|int, string>|null
Gets the subtypes of the card.
getSupertypes()  : array<string|int, string>|null
Gets the supertypes of the card.
getText()  : string|null
Gets the card's oracle rules text.
getToughness()  : string|null
Gets the creature's toughness.
getType()  : string|null
Gets the type of the card.
getTypes()  : array<string|int, string>|null
Gets the types of the card.
setArtist()  : self
Sets the name of the artist who illustrated the card.
setCmc()  : $this
Sets the converted mana cost of the card.
setColorIdentity()  : $this
Sets the color identity of the card.
setColors()  : $this
Sets the colors of the card.
setContains()  : self
Restricts results to cards that have the named field(s) present.
setFlavor()  : self
Sets the card's flavor text.
setGameFormat()  : self
Sets the game format to filter legality against (e.g. "Standard", "Modern").
setId()  : self
Sets the card's unique id (a hash of set code, name and collector number).
setLanguage()  : self
Sets the language to match foreign card names against when querying.
setLayout()  : $this
Sets the layout of the card.
setLegality()  : self
Sets the legality status to filter by ("Legal", "Banned" or "Restricted").
setLoyalty()  : self
Sets the planeswalker's starting loyalty.
setMultiverseid()  : self
Sets the card's Gatherer multiverse id.
setName()  : $this
Sets the name of the card.
setNumber()  : self
Sets the card's collector number within its set.
setOrderBy()  : self
Sets the field to order results by.
setPage()  : self
Sets the results page number to request (1-based pagination).
setPageSize()  : self
Sets the number of results per page.
setPower()  : self
Sets the creature's power. A string because it may be non-numeric (e.g. "*").
setRandom()  : self
Requests a single random card matching the other filters. Only a truthy value has an effect; `false`/`null` leaves the flag unset.
setRarity()  : self
Sets the rarity of the card (e.g. "Common", "Rare", "Mythic Rare").
setSet()  : self
Sets the code of the set the card belongs to.
setSetName()  : self
Sets the full name of the set the card belongs to.
setSubtypes()  : self
Sets the subtypes of the card (e.g. "Human", "Wizard", "Equipment").
setSupertypes()  : $this
Sets the supertypes of the card.
setText()  : self
Sets the card's oracle rules text.
setToughness()  : self
Sets the creature's toughness. A string because it may be non-numeric (e.g. "*").
setType()  : $this
Sets the type of the card.
setTypes()  : self
Sets the types of the card.

Properties

$artist

public ?string|null $artist

The artist of the card. May not match what is on the card as MTGJSON corrects many card misprints.

$colorIdentity

public ?array<string|int, string>|null $colorIdentity

The card’s color identity, by color code. E.g., [“Red”, “Blue”] becomes [“R”, “U”]. Includes colors from the card’s rules text.

$colors

public ?array<string|int, string>|null $colors

The card colors. Usually derived from the casting cost, but some cards are special (like the back of dual sided cards and Ghostfire).

$contains

public ?string|null $contains

Filter cards based on whether or not they have a specific field available (like imageUrl).

$gameFormat

public ?string|null $gameFormat

The game format, such as Commander, Standard, Legacy, etc. (when used, legality defaults to Legal unless supplied).

$id

public ?string|null $id

A unique id for this card. It is made up by doing an SHA1 hash of setCode + cardName + cardImageName.

$language

public ?string|null $language

The language the card is printed in. Use this parameter along with the name parameter when searching by foreignName.

$layout

public ?string|null $layout

The card layout. Possible values: normal, split, flip, double-faced, token, plane, scheme, phenomenon, leveler, vanguard, aftermath.

$legality

public ?string|null $legality

The legality of the card for a given format, such as Legal, Banned or Restricted.

$loyalty

public ?int|null $loyalty

The loyalty of the card. Only present for planeswalkers.

$multiverseid

public ?int|null $multiverseid

The multiverseid of the card on Wizard’s Gatherer web page. Cards from sets that do not exist on Gatherer will NOT have a multiverseid.

The fields below are also part of the response (if not null), but cannot currently be used as query parameters

$name

public ?string|null $name

The card name. For split, double-faced and flip cards, just the name of one side of the card. Each ‘sub-card’ has its own record.

$number

public ?string|null $number

The card number. Printed at the bottom-center of the card in small text. This is a string, not an integer, because some cards have letters in their numbers.

$orderBy

public ?string|null $orderBy

The field to order by in the response results.

$pageSize

public ?int|null $pageSize

The amount of data to return in a single request. The default (and max) is 100.

$power

public ?string|null $power

The power of the card. Only present for creatures. This is a string, not an integer, because some cards have powers like: “1+*”.

$random

public ?string|null $random

Fetch any number of cards (controlled by pageSize) randomly.

$rarity

public ?string|null $rarity

The rarity of the card. Examples: Common, Uncommon, Rare, Mythic Rare, Special, Basic Land.

$rulings read-only

public ?ExCollectionInterface<string|int, Rulings>|array<string|int, Rulings>|null $rulings

Array of rulings, each containing "date" and "text".

$set

public ?string|null $set

The set the card belongs to (set code).

$setName

public ?string|null $setName

The set name the card belongs to.

$subtypes

public ?array<string|int, string>|null $subtypes

The subtypes of the card. These appear to the right of the dash in a card type. Each word is its own subtype. Example: Trap, Arcane, Equipment, Aura, Human, Rat, Squirrel, etc.

$supertypes

public ?array<string|int, string>|null $supertypes

The supertypes of the card. These appear to the far left of the card type. Example: Basic, Legendary, Snow, World, Ongoing.

$text

public ?string|null $text

The oracle text of the card. May contain mana symbols and other symbols.

$toughness

public ?string|null $toughness

The toughness of the card. Only present for creatures. This is a string, not an integer, because some cards have toughness like: “1+*”.

$type

public ?string|null $type

The card type. This is the type you would see on the card if printed today. Note: The dash is a UTF8 ‘long dash’ as per the MTG rules.

$types

public ?array<string|int, string>|null $types

The types of the card. These appear to the left of the dash in a card type. Example: Instant, Sorcery, Artifact, Creature, Enchantment, Land, Planeswalker.

$variations read-only

public ?array<string|int, mixed>|null $variations

Methods

getArtist()

Gets the name of the artist who illustrated the card.

public getArtist() : string|null
Return values
string|null

getCmc()

Gets the converted mana cost of the card.

public getCmc() : int
Return values
int

getColorIdentity()

Gets the color identity of the card.

public getColorIdentity() : array<string|int, string>|null
Return values
array<string|int, string>|null

getColors()

Gets the colors of the card.

public getColors() : array<string|int, string>|null
Return values
array<string|int, string>|null

getContains()

Gets the "contains" field filter.

public getContains() : string|null
Return values
string|null

getFlavor()

Gets the card's flavor text.

public getFlavor() : string|null
Return values
string|null

getGameFormat()

Gets the game format used to filter legality.

public getGameFormat() : string|null
Return values
string|null

getId()

Gets the card's unique id.

public getId() : string|null
Return values
string|null

getLanguage()

Gets the language used when querying foreign card names.

public getLanguage() : string|null
Return values
string|null

getLayout()

Gets the layout of the card.

public getLayout() : string|null
Return values
string|null

getLegality()

Gets the legality status used to filter results.

public getLegality() : string|null
Return values
string|null

getLoyalty()

Gets the planeswalker's starting loyalty.

public getLoyalty() : int|null
Return values
int|null

getMultiverseid()

Gets the card's Gatherer multiverse id.

public getMultiverseid() : int|null
Return values
int|null

getName()

Gets the name of the card.

public getName() : string|null
Return values
string|null

getNumber()

Gets the card's collector number within its set.

public getNumber() : string|null
Return values
string|null

getOrderBy()

Gets the field results are ordered by.

public getOrderBy() : string|null
Return values
string|null

getPage()

Gets the results page number.

public getPage() : int|null
Return values
int|null

getPageSize()

Gets the number of results per page.

public getPageSize() : int|null
Return values
int|null

getPower()

Gets the creature's power.

public getPower() : string|null
Return values
string|null

getRandom()

Gets whether a random card was requested.

public getRandom() : bool|null
Return values
bool|null

getRarity()

Gets the rarity of the card.

public getRarity() : string|null
Return values
string|null

getSet()

Gets the code of the set the card belongs to.

public getSet() : string|null
Return values
string|null

getSetName()

Gets the full name of the set the card belongs to.

public getSetName() : string|null
Return values
string|null

getSubtypes()

Gets the subtypes of the card.

public getSubtypes() : array<string|int, string>|null
Return values
array<string|int, string>|null

getSupertypes()

Gets the supertypes of the card.

public getSupertypes() : array<string|int, string>|null
Return values
array<string|int, string>|null

getText()

Gets the card's oracle rules text.

public getText() : string|null
Return values
string|null

getToughness()

Gets the creature's toughness.

public getToughness() : string|null
Return values
string|null

getType()

Gets the type of the card.

public getType() : string|null
Return values
string|null

getTypes()

Gets the types of the card.

public getTypes() : array<string|int, string>|null
Return values
array<string|int, string>|null

setArtist()

Sets the name of the artist who illustrated the card.

public setArtist(string|null $artist) : self
Parameters
$artist : string|null

Artist name.

Return values
self

setCmc()

Sets the converted mana cost of the card.

public setCmc([int $cmc = 0 ]) : $this
Parameters
$cmc : int = 0

Converted mana cost of the card.

Return values
$this

setColorIdentity()

Sets the color identity of the card.

public setColorIdentity(array<string|int, string>|null $colorIdentity) : $this
Parameters
$colorIdentity : array<string|int, string>|null

Color identity of the card.

Return values
$this

setColors()

Sets the colors of the card.

public setColors(array<string|int, string>|null $colors) : $this
Parameters
$colors : array<string|int, string>|null

Colors of the card.

Return values
$this

setContains()

Restricts results to cards that have the named field(s) present.

public setContains(string|null $contains) : self
Parameters
$contains : string|null

Comma-separated field names.

Return values
self

setFlavor()

Sets the card's flavor text.

public setFlavor(string|null $flavor) : self
Parameters
$flavor : string|null

Flavor text.

Return values
self

setGameFormat()

Sets the game format to filter legality against (e.g. "Standard", "Modern").

public setGameFormat(string|null $gameFormat) : self
Parameters
$gameFormat : string|null

Game format name.

Return values
self

setId()

Sets the card's unique id (a hash of set code, name and collector number).

public setId(string|null $id) : self
Parameters
$id : string|null

Card id.

Return values
self

setLanguage()

Sets the language to match foreign card names against when querying.

public setLanguage(string|null $language) : self
Parameters
$language : string|null

Language name.

Return values
self

setLayout()

Sets the layout of the card.

public setLayout(string|null $layout) : $this
Parameters
$layout : string|null

Layout of the card.

Return values
$this

setLegality()

Sets the legality status to filter by ("Legal", "Banned" or "Restricted").

public setLegality(string|null $legality) : self
Parameters
$legality : string|null

Legality status.

Return values
self

setLoyalty()

Sets the planeswalker's starting loyalty.

public setLoyalty(int|null $loyalty) : self
Parameters
$loyalty : int|null

Starting loyalty.

Return values
self

setMultiverseid()

Sets the card's Gatherer multiverse id.

public setMultiverseid(int|null $multiverseid) : self
Parameters
$multiverseid : int|null

Multiverse id.

Return values
self

setName()

Sets the name of the card.

public setName(string|null $name) : $this
Parameters
$name : string|null

Name of the card.

Return values
$this

setNumber()

Sets the card's collector number within its set.

public setNumber(string|null $number) : self
Parameters
$number : string|null

Collector number.

Return values
self

setOrderBy()

Sets the field to order results by.

public setOrderBy(string|null $orderBy) : self
Parameters
$orderBy : string|null

Field name.

Return values
self

setPage()

Sets the results page number to request (1-based pagination).

public setPage(int|null $page) : self
Parameters
$page : int|null

Page number.

Return values
self

setPageSize()

Sets the number of results per page.

public setPageSize(int|null $pageSize) : self
Parameters
$pageSize : int|null

Page size, 1-100.

Tags
throws
InvalidArgumentException

When outside the 1-100 range.

Return values
self

setPower()

Sets the creature's power. A string because it may be non-numeric (e.g. "*").

public setPower(string|null $power) : self
Parameters
$power : string|null

Power.

Return values
self

setRandom()

Requests a single random card matching the other filters. Only a truthy value has an effect; `false`/`null` leaves the flag unset.

public setRandom(bool|null $random) : self
Parameters
$random : bool|null

Whether to return a random card.

Return values
self

setRarity()

Sets the rarity of the card (e.g. "Common", "Rare", "Mythic Rare").

public setRarity(string|null $rarity) : self
Parameters
$rarity : string|null

Rarity of the card.

Return values
self

setSet()

Sets the code of the set the card belongs to.

public setSet(string|null $set) : self
Parameters
$set : string|null

Set code.

Return values
self

setSetName()

Sets the full name of the set the card belongs to.

public setSetName(string|null $setName) : self
Parameters
$setName : string|null

Set name.

Return values
self

setSubtypes()

Sets the subtypes of the card (e.g. "Human", "Wizard", "Equipment").

public setSubtypes(array<string|int, string>|null $subtypes) : self
Parameters
$subtypes : array<string|int, string>|null

Subtypes of the card.

Return values
self

setSupertypes()

Sets the supertypes of the card.

public setSupertypes(array<string|int, string>|null $supertypes) : $this
Parameters
$supertypes : array<string|int, string>|null

Supertypes of the card.

Return values
$this

setText()

Sets the card's oracle rules text.

public setText(string|null $text) : self
Parameters
$text : string|null

Rules text.

Return values
self

setToughness()

Sets the creature's toughness. A string because it may be non-numeric (e.g. "*").

public setToughness(string|null $toughness) : self
Parameters
$toughness : string|null

Toughness.

Return values
self

setType()

Sets the type of the card.

public setType(string|null $type) : $this
Parameters
$type : string|null

Type of the card.

Return values
$this

setTypes()

Sets the types of the card.

public setTypes(array<string|int, string>|null $types) : self
Parameters
$types : array<string|int, string>|null

Types of the card.

Return values
self
On this page

Search results