{
  "openapi": "3.1.0",
  "info": {
    "title": "On-line Astrology Positions API",
    "version": "0.1.0",
    "description": "Machine-readable astrology positions for one UTC moment. Returns tropical ecliptic longitude, latitude, longitude speed, retrograde flag, zodiac position and optional houses. The response also includes record, an archive-compatible JSON object using the same shape as one static AI ephemeris JSONL record."
  },
  "servers": [
    {
      "url": "https://app.on-lineastrology.com"
    }
  ],
  "paths": {
    "/api/positions.php": {
      "get": {
        "summary": "Calculate planetary positions for one moment",
        "description": "Use one ISO 8601 datetime. The endpoint is intended for single-moment calculations, not bulk ephemeris scraping. Under higher load it may be temporarily limited to protect the server; for repeated or automated use, prefer the downloadable PHP package and local Swiss Ephemeris .se1 files.",
        "parameters": [
          {
            "name": "dt",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "format": "date-time",
              "examples": ["2026-05-17T12:00:00Z"]
            },
            "description": "UTC or offset-aware ISO 8601 datetime."
          },
          {
            "name": "bodies",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "default": "So,Mo,Me,Ve,Ma,Ju,Sa,Ur,Ne,Pl,Nn,Ll"
            },
            "description": "Comma-separated body IDs. Supported: So, Mo, Me, Ve, Ma, Ju, Sa, Ur, Ne, Pl, Nn, Nt, Ll, Lt, Ch, Ph, Ce, Pa, Jo, Va, Wa, Se. Use all for all supported bodies."
          },
          {
            "name": "lon",
            "in": "query",
            "required": false,
            "schema": {
              "type": "number",
              "minimum": -180,
              "maximum": 180
            },
            "description": "Geographic longitude for house calculation."
          },
          {
            "name": "lat",
            "in": "query",
            "required": false,
            "schema": {
              "type": "number",
              "minimum": -90,
              "maximum": 90
            },
            "description": "Geographic latitude for house calculation."
          },
          {
            "name": "house",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "default": "P",
              "maxLength": 1,
              "enum": ["P", "K", "R", "O", "W", "E", "A", "N"]
            },
            "description": "House system letter: P Placidus, K Koch, R Regiomontanus, O Porphyry, W whole sign, E/A equal, N Aries = 1st house. Used only when lon and lat are supplied. Unsupported letters fall back to Placidus with a warning."
          }
        ],
        "responses": {
          "200": {
            "description": "Calculated positions",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PositionsResponse"
                }
              }
            }
          },
          "400": {
            "description": "Invalid input"
          },
          "429": {
            "description": "Rate limit exceeded"
          },
          "503": {
            "description": "Ephemeris backend unavailable or calculation failed"
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "PositionsResponse": {
        "type": "object",
        "required": ["ok", "input", "zodiac", "positions"],
        "properties": {
          "ok": {
            "type": "boolean"
          },
          "api": {
            "type": "object"
          },
          "input": {
            "type": "object"
          },
          "zodiac": {
            "type": "object"
          },
          "record": {
            "$ref": "#/components/schemas/ArchiveRecord"
          },
          "positions": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Position"
            }
          },
          "houses": {
            "type": ["array", "null"]
          },
          "axes": {
            "type": ["array", "null"]
          },
          "warnings": {
            "type": "array",
            "items": {
              "type": "string"
            }
          }
        }
      },
      "ArchiveRecord": {
        "type": "object",
        "description": "Archive-compatible record with the same core shape as one JSONL line in the static AI ephemeris archive.",
        "required": ["schema_version", "time_utc", "julian_day_ut", "coordinate_system", "bodies"],
        "properties": {
          "schema_version": {
            "type": "string",
            "examples": ["1.0"]
          },
          "time_utc": {
            "type": "string",
            "format": "date-time"
          },
          "julian_day_ut": {
            "type": "number"
          },
          "coordinate_system": {
            "type": "object",
            "properties": {
              "frame": {
                "type": "string",
                "const": "geocentric"
              },
              "zodiac": {
                "type": "string",
                "const": "tropical"
              },
              "coordinates": {
                "type": "string",
                "const": "ecliptic"
              },
              "longitude_unit": {
                "type": "string",
                "const": "degrees"
              },
              "position_type": {
                "type": "string",
                "const": "apparent"
              }
            }
          },
          "bodies": {
            "type": "object",
            "additionalProperties": {
              "$ref": "#/components/schemas/ArchiveBody"
            }
          }
        }
      },
      "ArchiveBody": {
        "type": "object",
        "required": ["name", "longitude", "latitude", "speed_longitude", "retrograde", "zodiac"],
        "properties": {
          "name": {
            "type": "string"
          },
          "longitude": {
            "type": "number"
          },
          "latitude": {
            "type": "number"
          },
          "distance_au": {
            "type": ["number", "null"]
          },
          "speed_longitude": {
            "type": ["number", "null"]
          },
          "retrograde": {
            "type": ["boolean", "null"]
          },
          "zodiac": {
            "type": "object",
            "properties": {
              "sign_index": {
                "type": "integer",
                "minimum": 1,
                "maximum": 12
              },
              "sign_code": {
                "type": "string",
                "examples": ["Ta"]
              },
              "degree_in_sign": {
                "type": "number"
              }
            }
          }
        }
      },
      "Position": {
        "type": "object",
        "required": ["id", "name", "longitude", "latitude", "zodiac"],
        "properties": {
          "id": {
            "type": "string",
            "examples": ["So", "Wa", "Se"]
          },
          "name": {
            "type": "string",
            "examples": ["Sun"]
          },
          "name_cs": {
            "type": "string",
            "examples": ["Slunce"]
          },
          "longitude": {
            "type": "number",
            "description": "Ecliptic longitude in degrees, normalized to 0-360."
          },
          "latitude": {
            "type": "number",
            "description": "Ecliptic latitude in degrees."
          },
          "speed_longitude": {
            "type": ["number", "null"],
            "description": "Daily longitude speed in degrees per day."
          },
          "distance_au": {
            "type": ["number", "null"]
          },
          "retrograde": {
            "type": ["boolean", "null"]
          },
          "zodiac": {
            "type": "object",
            "properties": {
              "type": {
                "type": "string",
                "const": "tropical"
              },
              "sign_index": {
                "type": "integer",
                "minimum": 1,
                "maximum": 12
              },
              "sign_id": {
                "type": "string",
                "examples": ["Ta"]
              },
              "sign": {
                "type": "string",
                "examples": ["Taurus"]
              },
              "sign_cs": {
                "type": "string",
                "examples": ["Býk"]
              },
              "degree_in_sign": {
                "type": "number"
              },
              "formatted": {
                "type": "string",
                "examples": ["26Ta43'12\""]
              }
            }
          }
        }
      }
    }
  }
}
