{
  "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."
  },
  "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 rate-limited and intended for single-moment calculations, not bulk ephemeris scraping.",
        "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. 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
            },
            "description": "House system letter. Used only when lon and lat are supplied."
          }
        ],
        "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"
          },
          "positions": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Position"
            }
          },
          "houses": {
            "type": ["array", "null"]
          },
          "axes": {
            "type": ["array", "null"]
          },
          "warnings": {
            "type": "array",
            "items": {
              "type": "string"
            }
          }
        }
      },
      "Position": {
        "type": "object",
        "required": ["id", "name", "longitude", "latitude", "zodiac"],
        "properties": {
          "id": {
            "type": "string",
            "examples": ["So"]
          },
          "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\""]
              }
            }
          }
        }
      }
    }
  }
}
