{
  "openapi": "3.1.0",
  "info": {
    "title": "AgentTime API",
    "version": "1.0.0",
    "description": "Time, astronomy, and moon phase data via x402 micropayments. Powered by TimeAPI.io and US Naval Observatory.",
    "contact": {
      "name": "Ocean Digital Group",
      "url": "https://memoryapi.org"
    }
  },
  "servers": [
    {
      "url": "https://time.memoryapi.org",
      "description": "Production"
    }
  ],
  "paths": {
    "/x402/time/current": {
      "get": {
        "summary": "Current time in any timezone",
        "description": "Returns current local datetime, UTC datetime, unix epoch, UTC offset, DST status, day of week/year, and week number. Powered by TimeAPI.io.",
        "x-price": "$0.001 USDC",
        "parameters": [
          {
            "name": "timezone",
            "in": "query",
            "description": "IANA timezone (e.g. America/New_York, Europe/London). Default: UTC",
            "schema": {
              "type": "string",
              "default": "UTC"
            }
          },
          {
            "name": "format",
            "in": "query",
            "description": "Response format: iso, unix, or both (default)",
            "schema": {
              "type": "string",
              "enum": [
                "iso",
                "unix",
                "both"
              ],
              "default": "both"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Current time data",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "timezone": {
                      "type": "string"
                    },
                    "utc_datetime": {
                      "type": "string"
                    },
                    "local_datetime": {
                      "type": "string"
                    },
                    "unix_epoch": {
                      "type": "integer"
                    },
                    "utc_offset": {
                      "type": "string"
                    },
                    "day_of_week": {
                      "type": "string"
                    },
                    "day_of_year": {
                      "type": "integer"
                    },
                    "week_number": {
                      "type": "integer"
                    },
                    "is_dst": {
                      "type": "boolean"
                    },
                    "source": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "402": {
            "description": "Payment required"
          }
        }
      }
    },
    "/x402/time/astronomy": {
      "get": {
        "summary": "Sunrise, sunset, and twilight data",
        "description": "Get sunrise, sunset, civil twilight, and moonrise/moonset times for any location using US Naval Observatory data.",
        "x-price": "$0.001 USDC",
        "parameters": [
          {
            "name": "lat",
            "in": "query",
            "description": "Latitude (default: 40.7128 \u2014 New York City)",
            "schema": {
              "type": "number",
              "default": 40.7128
            }
          },
          {
            "name": "lon",
            "in": "query",
            "description": "Longitude (default: -74.0060 \u2014 New York City)",
            "schema": {
              "type": "number",
              "default": -74.006
            }
          },
          {
            "name": "date",
            "in": "query",
            "description": "Date in YYYY-MM-DD format (default: today)",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "tz",
            "in": "query",
            "description": "UTC offset integer (e.g. -5 for EST, 1 for CET). Default: 0",
            "schema": {
              "type": "integer",
              "default": 0
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Astronomy data",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "date": {
                      "type": "string"
                    },
                    "location": {
                      "type": "object",
                      "properties": {
                        "lat": {
                          "type": "number"
                        },
                        "lon": {
                          "type": "number"
                        }
                      }
                    },
                    "sun": {
                      "type": "object",
                      "properties": {
                        "civil_twilight_begin": {
                          "type": "string"
                        },
                        "rise": {
                          "type": "string"
                        },
                        "transit": {
                          "type": "string"
                        },
                        "set": {
                          "type": "string"
                        },
                        "civil_twilight_end": {
                          "type": "string"
                        }
                      }
                    },
                    "moon": {
                      "type": "object",
                      "properties": {
                        "rise": {
                          "type": "string"
                        },
                        "set": {
                          "type": "string"
                        }
                      }
                    },
                    "timezone_offset": {
                      "type": "integer"
                    },
                    "source": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "402": {
            "description": "Payment required"
          }
        }
      }
    },
    "/x402/time/moon": {
      "get": {
        "summary": "Moon phases",
        "description": "Get upcoming moon phases (New Moon, First Quarter, Full Moon, Last Quarter) and current illumination percentage from the US Naval Observatory.",
        "x-price": "$0.001 USDC",
        "parameters": [
          {
            "name": "date",
            "in": "query",
            "description": "Start date YYYY-MM-DD (default: today)",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "count",
            "in": "query",
            "description": "Number of phases to return (default: 4, max: 99)",
            "schema": {
              "type": "integer",
              "default": 4
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Moon phase data",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "date": {
                      "type": "string"
                    },
                    "illumination_percent": {
                      "type": "integer"
                    },
                    "phases": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "phase": {
                            "type": "string"
                          },
                          "date": {
                            "type": "string"
                          },
                          "time_utc": {
                            "type": "string"
                          }
                        }
                      }
                    },
                    "next_phase": {
                      "type": "object",
                      "properties": {
                        "name": {
                          "type": "string"
                        },
                        "date": {
                          "type": "string"
                        },
                        "time_utc": {
                          "type": "string"
                        },
                        "days_away": {
                          "type": "integer"
                        }
                      }
                    },
                    "source": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "402": {
            "description": "Payment required"
          }
        }
      }
    },
    "/mcp": {
      "get": {
        "summary": "MCP server info",
        "description": "Model Context Protocol server info and tool list.",
        "security": [],
        "responses": {
          "200": {
            "description": "MCP server info"
          }
        }
      },
      "post": {
        "summary": "MCP tool call",
        "description": "Execute MCP tools: get_current_time, get_astronomy, get_moon_phases",
        "security": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "jsonrpc": {
                    "type": "string"
                  },
                  "method": {
                    "type": "string"
                  },
                  "params": {
                    "type": "object"
                  },
                  "id": {}
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "MCP response"
          }
        }
      }
    }
  }
}