{
  "openapi": "3.1.0",
  "info": {
    "title": "SAJA Hanja API",
    "version": "1.0.0",
    "description": "Public read-only pilot. Unicode Unihan 17.0.0; 8,525 characters with Korean readings, 128 original Korean glosses. No SLA or commercial traffic quota is currently offered. Unicode data license: https://www.unicode.org/license.txt. Existing idiom terms: https://www.sajaquiz.com/api-terms/."
  },
  "servers": [
    {
      "url": "https://www.sajaquiz.com/wp-json/saja/v1"
    }
  ],
  "paths": {
    "/hanja": {
      "get": {
        "summary": "Search Hanja",
        "parameters": [
          {
            "name": "q",
            "in": "query",
            "description": "Search character, Korean reading/gloss, English definition or codepoint",
            "schema": {
              "type": "string",
              "maxLength": 80,
              "default": ""
            }
          },
          {
            "name": "page",
            "in": "query",
            "description": "Page number",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 10000,
              "default": 1
            }
          },
          {
            "name": "per_page",
            "in": "query",
            "description": "Results per page",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 50,
              "default": 24
            }
          },
          {
            "name": "strokes",
            "in": "query",
            "description": "First kTotalStrokes value",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 64
            }
          },
          {
            "name": "radical_number",
            "in": "query",
            "description": "Kangxi radical number",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 214
            }
          },
          {
            "name": "starter",
            "in": "query",
            "description": "Has an original Korean learning gloss",
            "schema": {
              "type": "integer",
              "enum": [
                0,
                1
              ]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Hanja"
                      }
                    },
                    "total": {
                      "type": "integer"
                    },
                    "page": {
                      "type": "integer"
                    },
                    "per_page": {
                      "type": "integer"
                    },
                    "pages": {
                      "type": "integer"
                    },
                    "source": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request parameter"
          }
        }
      }
    },
    "/hanja/{character}": {
      "get": {
        "summary": "Hanja detail and related idioms",
        "parameters": [
          {
            "name": "character",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 1
            },
            "example": "學"
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Hanja"
                    },
                    {
                      "type": "object",
                      "properties": {
                        "idioms": {
                          "type": "array",
                          "items": {
                            "$ref": "#/components/schemas/Idiom"
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Invalid request parameter"
          },
          "404": {
            "description": "Character not found"
          }
        }
      }
    },
    "/idioms": {
      "get": {
        "summary": "Search existing SAJA idioms",
        "parameters": [
          {
            "name": "q",
            "in": "query",
            "description": "Search character, Korean reading/gloss, English definition or codepoint",
            "schema": {
              "type": "string",
              "maxLength": 80,
              "default": ""
            }
          },
          {
            "name": "page",
            "in": "query",
            "description": "Page number",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 10000,
              "default": 1
            }
          },
          {
            "name": "per_page",
            "in": "query",
            "description": "Results per page",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 50,
              "default": 24
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Idiom"
                      }
                    },
                    "total": {
                      "type": "integer"
                    },
                    "page": {
                      "type": "integer"
                    },
                    "per_page": {
                      "type": "integer"
                    },
                    "pages": {
                      "type": "integer"
                    },
                    "source": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request parameter"
          }
        }
      }
    },
    "/meta": {
      "get": {
        "summary": "Dataset counts, version and license",
        "parameters": [],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request parameter"
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "Hanja": {
        "type": "object",
        "properties": {
          "character": {
            "type": "string"
          },
          "codepoint": {
            "type": "string"
          },
          "radical": {
            "type": "string"
          },
          "radical_strokes_raw": {
            "type": "string"
          },
          "readings_raw": {
            "type": "string"
          },
          "strokes_raw": {
            "type": "string"
          },
          "variants": {
            "type": "string"
          },
          "source": {
            "type": "string"
          },
          "license_url": {
            "type": "string"
          },
          "readings": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "strokes": {
            "type": "integer"
          },
          "radical_number": {
            "type": "integer"
          },
          "starter": {
            "type": "boolean"
          },
          "meaning_ko": {
            "type": [
              "string",
              "null"
            ]
          },
          "meaning_ko_source": {
            "type": [
              "string",
              "null"
            ]
          },
          "definition_en": {
            "type": [
              "string",
              "null"
            ]
          }
        }
      },
      "Idiom": {
        "type": "object",
        "properties": {
          "idx": {
            "type": "string"
          },
          "hanja": {
            "type": "string"
          },
          "hangul": {
            "type": "string"
          },
          "meaning": {
            "type": "string"
          }
        }
      }
    }
  }
}