{
  "openapi": "3.1.0",
  "info": {
    "title": "TimePortal Saju reading API",
    "version": "1.0.0",
    "description": "Full reading query with JSON or Markdown table output. Existing reading access controls apply. Structured requests do not call Jev."
  },
  "servers": [
    {
      "url": "https://timeportal.pro/saju"
    }
  ],
  "security": [
    {},
    {
      "SiteCredential": []
    }
  ],
  "paths": {
    "/query.php": {
      "get": {
        "operationId": "sajuReadingGet",
        "summary": "Read saju tables or capabilities",
        "parameters": [
          {
            "name": "query",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "maxLength": 3000,
              "description": "Natural-language request with explicit ISO dates, interpreted by Jev; omit when using structured fields."
            }
          },
          {
            "name": "aspects",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "description": "Comma-separated values or all."
            }
          },
          {
            "name": "language",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "en",
                "ko"
              ],
              "default": "en"
            }
          },
          {
            "name": "format",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "json",
                "markdown"
              ],
              "default": "json"
            }
          },
          {
            "name": "date1",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "format": "date",
              "description": "1930-01-01 through 2029-12-31"
            }
          },
          {
            "name": "date2",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "format": "date",
              "description": "1930-01-01 through 2029-12-31"
            }
          },
          {
            "name": "southern1",
            "in": "query",
            "required": false,
            "schema": {
              "type": "boolean",
              "default": false
            }
          },
          {
            "name": "southern2",
            "in": "query",
            "required": false,
            "schema": {
              "type": "boolean",
              "default": false
            }
          },
          {
            "name": "mask_dates",
            "in": "query",
            "required": false,
            "schema": {
              "type": "boolean",
              "default": false
            }
          },
          {
            "name": "name1",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "maxLength": 60,
              "description": "Display-only label; never saved."
            }
          },
          {
            "name": "name2",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "maxLength": 60,
              "description": "Display-only label; never saved."
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Calculated tables, or endpoint capabilities when GET has no arguments.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "app": {
                      "type": "string"
                    },
                    "tables": {
                      "type": "array",
                      "items": {
                        "type": "object"
                      }
                    },
                    "markdown": {
                      "type": "string"
                    },
                    "query": {
                      "type": "object"
                    },
                    "meta": {
                      "type": "object"
                    },
                    "notes": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    }
                  }
                }
              },
              "text/plain": {
                "schema": {
                  "type": "string",
                  "description": "UTF-8 Markdown tables"
                }
              }
            }
          },
          "400": {
            "description": "Malformed request."
          },
          "422": {
            "description": "Missing or invalid query arguments."
          },
          "429": {
            "description": "Existing site reading limit."
          },
          "502": {
            "description": "Upstream service failure."
          },
          "504": {
            "description": "Upstream timeout."
          }
        }
      },
      "post": {
        "operationId": "sajuReadingPost",
        "summary": "Submit a full-feature saju query",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "query": {
                    "type": "string",
                    "maxLength": 3000,
                    "description": "Natural-language request with explicit ISO dates, interpreted by Jev; omit when using structured fields."
                  },
                  "aspects": {
                    "oneOf": [
                      {
                        "type": "array",
                        "items": {
                          "type": "string"
                        }
                      },
                      {
                        "type": "string"
                      }
                    ],
                    "default": "all"
                  },
                  "language": {
                    "type": "string",
                    "enum": [
                      "en",
                      "ko"
                    ],
                    "default": "en"
                  },
                  "format": {
                    "type": "string",
                    "enum": [
                      "json",
                      "markdown"
                    ],
                    "default": "json"
                  },
                  "access_code": {
                    "type": "string",
                    "writeOnly": true,
                    "description": "Optional existing site access credential. POST only; never include in a URL."
                  },
                  "date1": {
                    "type": "string",
                    "format": "date",
                    "description": "1930-01-01 through 2029-12-31"
                  },
                  "date2": {
                    "type": "string",
                    "format": "date",
                    "description": "1930-01-01 through 2029-12-31"
                  },
                  "southern1": {
                    "type": "boolean",
                    "default": false
                  },
                  "southern2": {
                    "type": "boolean",
                    "default": false
                  },
                  "mask_dates": {
                    "type": "boolean",
                    "default": false
                  },
                  "name1": {
                    "type": "string",
                    "maxLength": 60,
                    "description": "Display-only label; never saved."
                  },
                  "name2": {
                    "type": "string",
                    "maxLength": 60,
                    "description": "Display-only label; never saved."
                  }
                },
                "anyOf": [
                  {
                    "required": [
                      "date1",
                      "date2"
                    ]
                  },
                  {
                    "required": [
                      "query"
                    ]
                  }
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Calculated tables, or endpoint capabilities when GET has no arguments.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "app": {
                      "type": "string"
                    },
                    "tables": {
                      "type": "array",
                      "items": {
                        "type": "object"
                      }
                    },
                    "markdown": {
                      "type": "string"
                    },
                    "query": {
                      "type": "object"
                    },
                    "meta": {
                      "type": "object"
                    },
                    "notes": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    }
                  }
                }
              },
              "text/plain": {
                "schema": {
                  "type": "string",
                  "description": "UTF-8 Markdown tables"
                }
              }
            }
          },
          "400": {
            "description": "Malformed request."
          },
          "422": {
            "description": "Missing or invalid query arguments."
          },
          "429": {
            "description": "Existing site reading limit."
          },
          "502": {
            "description": "Upstream service failure."
          },
          "504": {
            "description": "Upstream timeout."
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "SiteCredential": {
        "type": "http",
        "scheme": "bearer",
        "description": "Existing website reading credential, if the user has one. Not the TypeSafe API key."
      }
    }
  }
}