{
  "openapi": "3.1.0",
  "info": {
    "title": "AstroSaju public saju API",
    "version": "1.0.0",
    "summary": "Korean saju (Four Pillars, BaZi) computations: pillars, ten gods, luck pillars, Lunar New Year and Ipchun.",
    "description": "Deterministic calendar and astronomy computations (VSOP87, Meeus, Delta T, IANA time zones) for reflection and entertainment. No key. Free with a visible link to each response's attribution.card_url. About 60 requests a minute and 2,000 a day per IP. Bulk use: the Apify actor manseryeok-calculator. An MCP server with the same data runs at https://astrosaju.pages.dev/mcp.",
    "termsOfService": "https://astrosaju.pages.dev/developers/#terms",
    "license": {
      "name": "Free with attribution",
      "url": "https://astrosaju.pages.dev/developers/#terms"
    }
  },
  "servers": [
    {
      "url": "https://astrosaju.pages.dev"
    }
  ],
  "externalDocs": {
    "url": "https://astrosaju.pages.dev/developers/",
    "description": "Developer guide"
  },
  "paths": {
    "/api/v1/chart": {
      "get": {
        "operationId": "getChart",
        "summary": "Birth chart (four pillars)",
        "description": "Four pillars with stems, branches, ten gods, hidden stems and twelve stages; day master; five-element counts; ten-year luck pillars (with sex); the Ipchun and Lunar New Year facts for the birth year; the day-pillar archetype card.",
        "parameters": [
          {
            "name": "date",
            "in": "query",
            "required": true,
            "description": "Birth date, YYYY-MM-DD (1900-01-01 to 2100-12-31). Solar unless calendar=lunar.",
            "schema": {
              "type": "string",
              "format": "date"
            },
            "example": "1990-05-17"
          },
          {
            "name": "time",
            "in": "query",
            "required": false,
            "description": "Local birth time HH:MM (24h). Required unless unknown_time=1.",
            "schema": {
              "type": "string",
              "pattern": "^\\d{1,2}:\\d{2}$"
            },
            "example": "14:30"
          },
          {
            "name": "city",
            "in": "query",
            "required": false,
            "description": "Birth city, e.g. Seoul, New York, London. Sets time zone and longitude.",
            "schema": {
              "type": "string"
            },
            "example": "Seoul"
          },
          {
            "name": "tz",
            "in": "query",
            "required": false,
            "description": "IANA time zone, instead of city. Requires lon.",
            "schema": {
              "type": "string"
            },
            "example": "America/Chicago"
          },
          {
            "name": "lon",
            "in": "query",
            "required": false,
            "description": "Birthplace longitude, degrees east (negative west).",
            "schema": {
              "type": "number",
              "minimum": -180,
              "maximum": 180
            }
          },
          {
            "name": "sex",
            "in": "query",
            "required": false,
            "description": "M or F. Needed for the luck pillars' direction.",
            "schema": {
              "type": "string",
              "enum": [
                "M",
                "F"
              ]
            }
          },
          {
            "name": "unknown_time",
            "in": "query",
            "required": false,
            "description": "1 if the birth time is unknown: the hour pillar is null.",
            "schema": {
              "type": "string",
              "enum": [
                "1"
              ]
            }
          },
          {
            "name": "calendar",
            "in": "query",
            "required": false,
            "description": "solar (default) or lunar.",
            "schema": {
              "type": "string",
              "enum": [
                "solar",
                "lunar"
              ]
            }
          },
          {
            "name": "leap",
            "in": "query",
            "required": false,
            "description": "1 for a lunar leap month.",
            "schema": {
              "type": "string",
              "enum": [
                "1"
              ]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The chart",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/api/v1/pillar": {
      "get": {
        "operationId": "getDayPillar",
        "summary": "Day pillar and card for a date",
        "parameters": [
          {
            "name": "date",
            "in": "query",
            "required": true,
            "description": "YYYY-MM-DD",
            "schema": {
              "type": "string",
              "format": "date"
            },
            "example": "2027-02-04"
          }
        ],
        "responses": {
          "200": {
            "description": "The day pillar",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/api/v1/year/{year}": {
      "get": {
        "operationId": "getYear",
        "summary": "A year's pillar, start instants, month starts and roles by day master",
        "description": "2027 includes the written reading for each day master. Other years (1900 to 2100) are computed only.",
        "parameters": [
          {
            "name": "year",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer",
              "minimum": 1900,
              "maximum": 2100
            },
            "example": 2027
          },
          {
            "name": "stem",
            "in": "query",
            "required": false,
            "description": "Day master: a stem (甲..癸), a slug (yang-water) or a persona (Ocean).",
            "schema": {
              "type": "string"
            },
            "example": "壬"
          },
          {
            "name": "date",
            "in": "query",
            "required": false,
            "description": "Birth date, to find the day master. Instead of stem.",
            "schema": {
              "type": "string",
              "format": "date"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The year",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/api/v1/lunar-new-year": {
      "get": {
        "operationId": "getLunarNewYear",
        "summary": "Chinese New Year, Seollal and Ipchun for a year",
        "parameters": [
          {
            "name": "year",
            "in": "query",
            "required": true,
            "description": "1900 to 2100",
            "schema": {
              "type": "integer",
              "minimum": 1900,
              "maximum": 2100
            },
            "example": 2027
          }
        ],
        "responses": {
          "200": {
            "description": "The dates",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/api/v1/today": {
      "get": {
        "operationId": "getToday",
        "summary": "Today's day, month and year pillars",
        "parameters": [
          {
            "name": "tz",
            "in": "query",
            "required": false,
            "description": "IANA time zone (default UTC).",
            "schema": {
              "type": "string"
            },
            "example": "Asia/Seoul"
          }
        ],
        "responses": {
          "200": {
            "description": "Today",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "Attribution": {
        "type": "object",
        "required": [
          "name",
          "url",
          "card_url",
          "reading_url"
        ],
        "properties": {
          "name": {
            "type": "string"
          },
          "url": {
            "type": "string",
            "format": "uri"
          },
          "card_url": {
            "type": "string",
            "format": "uri"
          },
          "reading_url": {
            "type": "string",
            "format": "uri"
          },
          "text": {
            "type": "string"
          }
        }
      },
      "Envelope": {
        "type": "object",
        "required": [
          "attribution",
          "terms",
          "disclaimer"
        ],
        "additionalProperties": true,
        "properties": {
          "attribution": {
            "$ref": "#/components/schemas/Attribution"
          },
          "terms": {
            "type": "string"
          },
          "disclaimer": {
            "type": "string"
          },
          "source": {
            "type": "object"
          }
        }
      },
      "Error": {
        "type": "object",
        "required": [
          "error",
          "message"
        ],
        "properties": {
          "error": {
            "type": "string",
            "enum": [
              "bad_request",
              "rate_limited",
              "not_found",
              "method_not_allowed",
              "internal"
            ]
          },
          "message": {
            "type": "string"
          },
          "field": {
            "type": "string"
          },
          "docs": {
            "type": "string"
          },
          "terms": {
            "type": "string"
          }
        }
      }
    },
    "responses": {
      "Error": {
        "description": "Invalid input",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "RateLimited": {
        "description": "Too many requests",
        "headers": {
          "Retry-After": {
            "schema": {
              "type": "integer"
            }
          }
        },
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      }
    }
  }
}
