{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/valotcg/json-schema/valotcg-scan-result-schema.json",
  "title": "ScanResult",
  "x-generated": "2026-12-04",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/valotcg-scans-api-openapi.yml#/components/schemas/ScanResult",
  "properties": {
    "status": {
      "type": "string",
      "enum": [
        "matched",
        "ambiguous",
        "no_match"
      ],
      "title": "Status",
      "description": "`matched`: the first candidate is the card, at the operating point published for this game and language. `ambiguous`: plausible candidates, none certain enough; let a person choose. `no_match`: no card recognised (none detected, or not in the catalogue); `candidates` is empty."
    },
    "finish_confidence": {
      "anyOf": [
        {
          "type": "string",
          "enum": [
            "high",
            "low"
          ]
        },
        {
          "type": "null"
        }
      ],
      "title": "Finish Confidence",
      "description": "Only when `matched`. `high`: no other card shares the artwork in this language and the card has a single price variant. `low`: the printing or the finish (e.g. foil) must be checked by eye. Independent of `score`."
    },
    "candidates": {
      "items": {
        "$ref": "#/$defs/ScanCandidate"
      },
      "type": "array",
      "title": "Candidates",
      "description": "Up to 5 candidates, best first."
    },
    "detection": {
      "anyOf": [
        {
          "$ref": "#/$defs/ScanDetection"
        },
        {
          "type": "null"
        }
      ],
      "description": "Where the card was found; `null` when none was."
    },
    "grading": {
      "anyOf": [
        {
          "$ref": "#/$defs/ScanGrading"
        },
        {
          "type": "null"
        }
      ],
      "description": "Only for a card in a graded slab: what its label says. The label also sorts the candidates (set, year and number printed on it). `null` for a raw card or an unreadable label. Read from the photo, not verified with the grading company."
    },
    "model_version": {
      "type": "string",
      "title": "Model Version",
      "description": "Version of the recognition service, for support and reproducibility."
    },
    "catalog_date": {
      "type": "string",
      "format": "date",
      "title": "Catalog Date",
      "description": "Date of the catalogue the photo was compared against."
    },
    "latency_ms": {
      "type": "integer",
      "title": "Latency Ms",
      "description": "Server processing time of this scan."
    }
  },
  "type": "object",
  "required": [
    "status",
    "finish_confidence",
    "candidates",
    "detection",
    "model_version",
    "catalog_date",
    "latency_ms"
  ],
  "$defs": {
    "CardSummary": {
      "properties": {
        "card_id": {
          "type": "integer",
          "title": "Card Id",
          "description": "Stable Valo.Data card id."
        },
        "game": {
          "type": "string",
          "title": "Game",
          "description": "Game slug, e.g. `pokemon`, `onepiece`, `star_wars_unlimited`."
        },
        "name": {
          "type": "string",
          "title": "Name",
          "description": "Printed name in the card language."
        },
        "name_en": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Name En",
          "description": "English name when known; `name` on an English card."
        },
        "number": {
          "type": "string",
          "title": "Number",
          "description": "Collector number as printed, e.g. `001/102`, `OP01-012`."
        },
        "rarity": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Rarity",
          "description": "Rarity label as printed on the card or as given by the source, in the card language, e.g. `Illustration spéciale rare`, `SuperRare`."
        },
        "rarity_code": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Rarity Code",
          "description": "Canonical rarity code, shared by every language of one rarity system, e.g. `special_illustration_rare`. Japanese and Chinese Pokémon prints follow their own system (`sar`, `ur`). `null` when the rarity is unknown. Codes of a game: `GET /data/v1/games/{game}/rarities`."
        },
        "language": {
          "type": "string",
          "enum": [
            "fr",
            "en",
            "ja",
            "zh",
            "de",
            "es",
            "it",
            "pt"
          ],
          "title": "Language",
          "description": "Language of the printed card."
        },
        "edition": {
          "$ref": "#/$defs/EditionRef"
        },
        "image_url": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Image Url"
        },
        "variants": {
          "items": {
            "type": "string",
            "enum": [
              "default",
              "foil",
              "first_edition",
              "reverse",
              "pokeball",
              "masterball"
            ]
          },
          "type": "array",
          "title": "Variants",
          "description": "Price variants tracked for this card, each with its own quotes: `default` (main printing); `foil` for games pricing foils separately (Magic, Lorcana, Riftbound, Dragon Ball Super...); for Pokémon, `first_edition` (1st Edition of a card also printed unlimited), `reverse` (reverse holo), `pokeball` and `masterball` (reverse Poké Ball and Master Ball patterns) on cards printed in them. Only the variants the card exists in are listed; a card printed only in 1st Edition lists `default`, which is that print."
        },
        "cardmarket_product_id": {
          "anyOf": [
            {
              "type": "integer"
            },
            {
              "type": "null"
            }
          ],
          "title": "Cardmarket Product Id",
          "description": "Cardmarket idProduct; `null` on Sandbox and Starter."
        },
        "tcgplayer_product_id": {
          "anyOf": [
            {
              "type": "integer"
            },
            {
              "type": "null"
            }
          ],
          "title": "US market product id",
          "description": "US market product id; `null` on Sandbox and Starter."
        }
      },
      "type": "object",
      "required": [
        "card_id",
        "game",
        "name",
        "number",
        "language",
        "edition",
        "variants"
      ],
      "title": "CardSummary"
    },
    "EditionRef": {
      "properties": {
        "id": {
          "type": "integer",
          "title": "Id",
          "description": "Edition id, usable as `edition_id` filter."
        },
        "name": {
          "type": "string",
          "title": "Name"
        },
        "code": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Code",
          "description": "Publisher set code, e.g. `SV06`, `OP-01`."
        },
        "release_date": {
          "anyOf": [
            {
              "type": "string",
              "format": "date"
            },
            {
              "type": "null"
            }
          ],
          "title": "Release Date"
        }
      },
      "type": "object",
      "required": [
        "id",
        "name"
      ],
      "title": "EditionRef"
    },
    "ScanBox": {
      "properties": {
        "x": {
          "type": "number",
          "title": "X",
          "description": "Left edge, as a fraction of the photo width (photo turned upright)."
        },
        "y": {
          "type": "number",
          "title": "Y",
          "description": "Top edge, as a fraction of the photo height."
        },
        "width": {
          "type": "number",
          "title": "Width",
          "description": "Box width, as a fraction of the photo width."
        },
        "height": {
          "type": "number",
          "title": "Height",
          "description": "Box height, as a fraction of the photo height."
        }
      },
      "type": "object",
      "required": [
        "x",
        "y",
        "width",
        "height"
      ],
      "title": "ScanBox"
    },
    "ScanCandidate": {
      "properties": {
        "rank": {
          "type": "integer",
          "title": "Rank",
          "description": "1 for the best candidate."
        },
        "score": {
          "type": "number",
          "title": "Score",
          "description": "Visual similarity between the photo and the catalogue card. It is not a probability: compare candidates of one scan, do not read it as a percentage."
        },
        "card": {
          "$ref": "#/$defs/CardSummary",
          "description": "The Valo.Data card. `cardmarket_product_id` and `tcgplayer_product_id` are filled on the Growth and Scale plans only; prices come from `GET /data/v1/cards/{card_id}/prices`."
        },
        "same_artwork_card_ids": {
          "items": {
            "type": "integer"
          },
          "type": "array",
          "title": "Same Artwork Card Ids",
          "description": "Other cards of the same language printed with this artwork (reprints, promos). A photo cannot tell them apart; check the set symbol and number."
        }
      },
      "type": "object",
      "required": [
        "rank",
        "score",
        "card",
        "same_artwork_card_ids"
      ],
      "title": "ScanCandidate"
    },
    "ScanDetection": {
      "properties": {
        "confidence": {
          "type": "number",
          "title": "Confidence",
          "description": "Confidence that the box holds a card (0 to 1)."
        },
        "box": {
          "$ref": "#/$defs/ScanBox"
        }
      },
      "type": "object",
      "required": [
        "confidence",
        "box"
      ],
      "title": "ScanDetection"
    },
    "ScanGrading": {
      "properties": {
        "company": {
          "type": "string",
          "enum": [
            "psa",
            "pca",
            "ccc",
            "collect_aura",
            "bgs",
            "cgc",
            "sgc",
            "pure_grading",
            "sfg",
            "sgs",
            "mtg"
          ],
          "title": "Company",
          "description": "Grading company read on the slab label; the same code as `grader` in the graded prices of Valo.Data (`psa`, `pca`, `ccc`, `collect_aura`, `bgs`, `cgc`), or `sgc`, `pure_grading`, `sfg`, `sgs`, `mtg`."
        },
        "grade": {
          "anyOf": [
            {
              "type": "integer"
            },
            {
              "type": "number"
            },
            {
              "type": "null"
            }
          ],
          "title": "Grade",
          "description": "Grade printed on the label (1 to 10, half grades included); `null` when unreadable."
        },
        "certificate_number": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Certificate Number",
          "description": "Certificate number printed on the label, digits only; `null` when the company prints none (Collect Aura, MTG) or when it is unreadable. Check it on the company's site before relying on it."
        }
      },
      "type": "object",
      "required": [
        "company",
        "grade",
        "certificate_number"
      ],
      "title": "ScanGrading"
    }
  }
}