{
  "openapi": "3.1.0",
  "info": {
    "title": "Runestone Tarot — Public API",
    "description": "Public AI-friendly tarot reading API. Unauthenticated, CORS-open, intended for LLM clients (ChatGPT plugins, MCP servers, Custom GPTs, agentic apps). For self-reflection, not fortune-telling.",
    "version": "1.0.0",
    "contact": {
      "name": "Runestone Labs",
      "email": "evan@runestonelabs.io",
      "url": "https://www.runestonelabs.io"
    }
  },
  "externalDocs": {
    "description": "Runestone Tarot MCP server, llms.txt, and AI client setup",
    "url": "https://www.runestonetarot.com/mcp"
  },
  "x-llms-txt": "https://www.runestonetarot.com/llms.txt",
  "x-mcp-server": {
    "name": "io.github.runestone-labs/tarot-mcp",
    "package": "@runestone-labs/tarot-mcp",
    "metadata": "https://www.runestonetarot.com/.well-known/mcp.json"
  },
  "servers": [
    { "url": "https://www.runestonetarot.com", "description": "Production" }
  ],
  "paths": {
    "/api/v1/reading": {
      "post": {
        "operationId": "drawReading",
        "summary": "Draw a tarot reading",
        "description": "Draw cards for a spread and return an interpretive narrative + reflection questions. If `cards` is omitted, the server draws from the deck. Always returns a `deeplink` to the visual reading on the site.",
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": { "$ref": "#/components/schemas/ReadingRequest" }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Reading generated",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/ReadingResponse" }
              }
            }
          },
          "400": { "description": "Invalid request body" },
          "429": { "description": "Rate limited (5 requests/min/IP)" },
          "500": { "description": "Generation failed" }
        }
      },
      "get": {
        "operationId": "listSpreads",
        "summary": "List available spreads",
        "description": "Returns the spread catalog accepted by POST /api/v1/reading.",
        "responses": {
          "200": {
            "description": "Spread catalog",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "spreads": {
                      "type": "array",
                      "items": { "$ref": "#/components/schemas/SpreadSummary" }
                    },
                    "docs": { "type": "string" }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/cards": {
      "get": {
        "operationId": "listCards",
        "summary": "Full 78-card catalog",
        "description": "Returns every tarot card in the deck with upright + reversed meanings, keywords, and a deeplink to the card's page on runestonetarot.com.",
        "responses": {
          "200": {
            "description": "Card catalog",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "count": { "type": "integer" },
                    "cards": {
                      "type": "array",
                      "items": { "$ref": "#/components/schemas/Card" }
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/spreads": {
      "get": {
        "operationId": "listSpreadsCatalog",
        "summary": "Full spread catalog with positions",
        "responses": {
          "200": {
            "description": "Spread catalog",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "count": { "type": "integer" },
                    "spreads": {
                      "type": "array",
                      "items": { "$ref": "#/components/schemas/Spread" }
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "SpreadSlug": {
        "type": "string",
        "enum": ["single", "three-card", "situation-action-outcome", "celtic-cross"]
      },
      "SpreadSummary": {
        "type": "object",
        "properties": {
          "slug": { "$ref": "#/components/schemas/SpreadSlug" },
          "name": { "type": "string" },
          "description": { "type": "string" },
          "cardCount": { "type": "integer" }
        }
      },
      "Spread": {
        "type": "object",
        "properties": {
          "slug": { "$ref": "#/components/schemas/SpreadSlug" },
          "name": { "type": "string" },
          "description": { "type": "string" },
          "cardCount": { "type": "integer" },
          "positions": {
            "type": "array",
            "items": { "type": "string" }
          }
        }
      },
      "ReadingRequest": {
        "type": "object",
        "properties": {
          "question": {
            "type": "string",
            "maxLength": 500,
            "description": "Free-text question to weave through the interpretation. Optional."
          },
          "spread": {
            "$ref": "#/components/schemas/SpreadSlug",
            "description": "Spread layout to use. Defaults to 'single'."
          },
          "cards": {
            "type": "array",
            "maxItems": 10,
            "description": "Optional caller-supplied draw. When omitted, the server draws fresh cards.",
            "items": {
              "type": "object",
              "required": ["slug"],
              "properties": {
                "slug": {
                  "type": "string",
                  "description": "Card slug from /api/v1/cards (e.g. 'the-fool', 'three-of-cups')."
                },
                "state": {
                  "type": "string",
                  "enum": ["upright", "reversed"],
                  "default": "upright"
                },
                "position": {
                  "type": "string",
                  "description": "Optional position label. Defaults to the spread's position for this index."
                }
              }
            }
          }
        }
      },
      "DrawnCard": {
        "type": "object",
        "properties": {
          "slug": { "type": "string" },
          "name": { "type": "string" },
          "state": { "type": "string", "enum": ["upright", "reversed"] },
          "position": { "type": "string" },
          "keywords": { "type": "array", "items": { "type": "string" } },
          "meaning": { "type": "string" },
          "arcana": { "type": "string", "enum": ["major", "minor"] },
          "suit": { "type": "string" },
          "deeplink": {
            "type": "string",
            "format": "uri",
            "description": "URL to the card's detail page on runestonetarot.com."
          }
        }
      },
      "Card": {
        "allOf": [
          { "$ref": "#/components/schemas/DrawnCard" },
          {
            "type": "object",
            "properties": {
              "number": {
                "oneOf": [{ "type": "integer" }, { "type": "string" }]
              },
              "reversedKeywords": { "type": "array", "items": { "type": "string" } },
              "uprightMeaning": { "type": "string" },
              "reversedMeaning": { "type": "string" }
            }
          }
        ]
      },
      "ReadingResponse": {
        "type": "object",
        "properties": {
          "spread": { "$ref": "#/components/schemas/SpreadSummary" },
          "question": { "type": ["string", "null"] },
          "cards": {
            "type": "array",
            "items": { "$ref": "#/components/schemas/DrawnCard" }
          },
          "interpretation": {
            "type": "object",
            "properties": {
              "narrative": {
                "type": "string",
                "description": "2-3 paragraph interpretive narrative weaving the cards together."
              },
              "reflections": {
                "type": "array",
                "minItems": 3,
                "maxItems": 3,
                "items": { "type": "string" },
                "description": "Three open-ended questions for self-reflection."
              },
              "closingInsight": { "type": "string" }
            }
          },
          "deeplink": {
            "type": "string",
            "format": "uri",
            "description": "URL to view this reading rendered visually on runestonetarot.com. Always surface this to the end user."
          }
        }
      }
    }
  }
}
