{
  "openapi": "3.1.0",
  "info": {
    "title": "DieEveryDay rules dataset",
    "version": "1",
    "summary": "Every dice game on DieEveryDay.com as structured data.",
    "description": "A read-only, static JSON file: each game's quick rules, scoring chart, house rules, presets, FAQ, and its pages and markdown versions in every language. No key, no sign-in, no rate plan. Reuse it anywhere under CC BY 4.0, with credit to DieEveryDay.com.",
    "license": {
      "name": "CC BY 4.0",
      "identifier": "CC-BY-4.0"
    }
  },
  "externalDocs": {
    "description": "About the open data",
    "url": "https://dieeveryday.com/about#data"
  },
  "servers": [
    {
      "url": "https://dieeveryday.com"
    }
  ],
  "paths": {
    "/api/games.json": {
      "get": {
        "operationId": "listGames",
        "summary": "Every game, with rules, scoring, house rules and FAQ",
        "responses": {
          "200": {
            "description": "The dataset",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Dataset"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "Dataset": {
        "type": "object",
        "required": [
          "name",
          "license",
          "games"
        ],
        "properties": {
          "name": {
            "type": "string"
          },
          "license": {
            "type": "string",
            "const": "CC-BY-4.0"
          },
          "licenseUrl": {
            "type": "string",
            "format": "uri",
            "const": "https://creativecommons.org/licenses/by/4.0/"
          },
          "attribution": {
            "type": "string"
          },
          "source": {
            "type": "string",
            "format": "uri"
          },
          "games": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Game"
            }
          }
        }
      },
      "Game": {
        "type": "object",
        "required": [
          "id",
          "name",
          "summary",
          "url",
          "players",
          "dice",
          "quickRules"
        ],
        "properties": {
          "id": {
            "type": "string",
            "description": "Stable id, also the English URL slug"
          },
          "name": {
            "type": "string"
          },
          "aliases": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "summary": {
            "type": "string"
          },
          "url": {
            "type": "string",
            "format": "uri",
            "description": "The game page (English)"
          },
          "markdown": {
            "type": "string",
            "format": "uri",
            "description": "The game page's markdown version"
          },
          "family": {
            "type": "string",
            "enum": [
              "push-your-luck",
              "scorecard",
              "bluffing",
              "party",
              "casino",
              "board"
            ]
          },
          "mechanics": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "players": {
            "type": "object",
            "required": [
              "min",
              "max"
            ],
            "properties": {
              "min": {
                "type": "integer"
              },
              "max": {
                "type": "integer"
              }
            }
          },
          "dice": {
            "type": "object",
            "properties": {
              "count": {
                "type": "integer"
              },
              "type": {
                "type": "string",
                "description": "Die type, such as d6 or a printed poker die"
              }
            }
          },
          "minutes": {
            "type": "array",
            "items": {
              "type": "integer"
            },
            "minItems": 2,
            "maxItems": 2,
            "description": "Typical length of a game: shortest and longest, in minutes"
          },
          "quickRules": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "scoring": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "name": {
                  "type": "string"
                },
                "rule": {
                  "type": "string"
                },
                "exampleDice": {
                  "type": "array",
                  "items": {
                    "type": "integer"
                  }
                },
                "points": {
                  "type": [
                    "integer",
                    "null"
                  ],
                  "description": "Null when the line ends the turn or decides a result instead of scoring"
                },
                "result": {
                  "type": "string"
                },
                "everyFace": {
                  "type": "array",
                  "description": "The same combination with every face, when the example shows only one",
                  "items": {
                    "type": "object",
                    "properties": {
                      "face": {
                        "type": "integer"
                      },
                      "points": {
                        "type": "integer"
                      }
                    }
                  }
                }
              }
            }
          },
          "houseRules": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "key": {
                  "type": "string"
                },
                "label": {
                  "type": "string"
                },
                "description": {
                  "type": "string"
                },
                "default": {
                  "oneOf": [
                    {
                      "type": "string"
                    },
                    {
                      "type": "number"
                    },
                    {
                      "type": "boolean"
                    }
                  ]
                },
                "choices": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "properties": {
                      "value": {
                        "oneOf": [
                          {
                            "type": "string"
                          },
                          {
                            "type": "number"
                          },
                          {
                            "type": "boolean"
                          }
                        ]
                      },
                      "label": {
                        "type": "string"
                      }
                    }
                  }
                }
              }
            }
          },
          "presets": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "id": {
                  "type": "string"
                },
                "name": {
                  "type": "string"
                },
                "description": {
                  "type": "string"
                },
                "values": {
                  "type": "object",
                  "additionalProperties": {
                    "oneOf": [
                      {
                        "type": "string"
                      },
                      {
                        "type": "number"
                      },
                      {
                        "type": "boolean"
                      }
                    ]
                  }
                }
              }
            }
          },
          "faq": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "question": {
                  "type": "string"
                },
                "answer": {
                  "type": "string"
                }
              }
            }
          },
          "translations": {
            "type": "object",
            "description": "The game in every language that publishes it, keyed by language tag (en, es, pt-BR, fr, de, ja)",
            "additionalProperties": {
              "type": "object",
              "properties": {
                "name": {
                  "type": "string"
                },
                "url": {
                  "type": "string",
                  "format": "uri"
                },
                "markdown": {
                  "type": "string",
                  "format": "uri"
                }
              }
            }
          },
          "updated": {
            "type": "string",
            "format": "date"
          }
        }
      }
    }
  }
}