{
  "openapi": "3.0.3",
  "info": {
    "title": "Real-time API weather services",
    "description": "Real-time API documentation of weather services",
    "contact": {
      "email": "feedback@data.gov.sg"
    },
    "version": "1.0.11"
  },
  "servers": [
    {
      "url": "https://api-open.data.gov.sg/v2/real-time/api"
    }
  ],
  "paths": {
    "/four-day-outlook": {
      "get": {
        "summary": "Retrieve the latest 4 day weather forecast",
        "description": "**[https://api-open.data.gov.sg/v2/real-time/api/four-day-outlook](https://api-open.data.gov.sg/v2/real-time/api/four-day-outlook)**\n\n<br/>\n\n- Updated twice a day from NEA\n- The forecast is for the next 4 days.\n\n<br/>\n\n- Filter for specific date or date-time by providing `date` in query parameter.\n  - use YYYY-MM-DD format to retrieve all of the readings for that day\n  - use YYYY-MM-DDTHH:mm:ss to retrieve the latest readings at that moment in time\n  - example: `?date=2024-07-16` or `?date=2024-07-16T23:59:00`\n",
        "parameters": [
          {
            "in": "query",
            "name": "date",
            "description": "SGT date for which to retrieve data (YYYY-MM-DD or YYYY-MM-DDTHH:MM:SS)",
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "paginationToken",
            "description": "Pagination token for retrieving subsequent data pages",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "4 Day Weather Forecast",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "code": {
                      "type": "integer",
                      "description": "Response status code (always 0 for success)"
                    },
                    "errorMsg": {
                      "type": "string",
                      "description": "Error message (empty string for success)",
                      "example": null
                    },
                    "data": {
                      "type": "object",
                      "description": "Chronologically ordered forecasts for the next 4 days",
                      "properties": {
                        "records": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "date": {
                                "type": "string",
                                "example": "2024-07-17T00:00:00.000Z"
                              },
                              "updatedTimestamp": {
                                "type": "string",
                                "example": "2024-07-16T21:20:50.000Z"
                              },
                              "timestamp": {
                                "type": "string",
                                "example": "2024-07-16T21:17:00.000Z"
                              },
                              "forecasts": {
                                "type": "array",
                                "description": "Forecast summary for the day",
                                "items": {
                                  "type": "object",
                                  "properties": {
                                    "timestamp": {
                                      "type": "string",
                                      "example": "2024-07-17T16:00:00.000Z"
                                    },
                                    "temperature": {
                                      "type": "object",
                                      "description": "Unit of measure - Degrees Celsius",
                                      "properties": {
                                        "low": {
                                          "type": "number",
                                          "example": 26
                                        },
                                        "high": {
                                          "type": "number",
                                          "example": 33
                                        },
                                        "unit": {
                                          "type": "string",
                                          "example": "Degrees Celsius"
                                        }
                                      }
                                    },
                                    "relativeHumidity": {
                                      "type": "object",
                                      "description": "Unit of measure - Percentage",
                                      "properties": {
                                        "low": {
                                          "type": "number",
                                          "example": 50
                                        },
                                        "high": {
                                          "type": "number",
                                          "example": 80
                                        },
                                        "unit": {
                                          "type": "string",
                                          "example": "Percentage"
                                        }
                                      }
                                    },
                                    "forecast": {
                                      "type": "object",
                                      "properties": {
                                        "summary": {
                                          "type": "string",
                                          "example": "Fair and occasionally windy"
                                        },
                                        "code": {
                                          "type": "string",
                                          "example": "FA"
                                        },
                                        "text": {
                                          "type": "string",
                                          "enum": [
                                            "Fair",
                                            "Fair (Day)",
                                            "Fair (Night)",
                                            "Fair and Warm",
                                            "Partly Cloudy",
                                            "Partly Cloudy (Day)",
                                            "Partly Cloudy (Night)",
                                            "Cloudy",
                                            "Hazy",
                                            "Slightly Hazy",
                                            "Windy",
                                            "Mist",
                                            "Fog",
                                            "Light Rain",
                                            "Moderate Rain",
                                            "Heavy Rain",
                                            "Passing Showers",
                                            "Light Showers",
                                            "Showers",
                                            "Heavy Showers",
                                            "Thundery Showers",
                                            "Heavy Thundery Showers",
                                            "Heavy Thundery Showers with Gusty Winds"
                                          ]
                                        }
                                      }
                                    },
                                    "day": {
                                      "type": "string",
                                      "enum": [
                                        "Monday",
                                        "Tuesday",
                                        "Wednesday",
                                        "Thursday",
                                        "Friday",
                                        "Saturday",
                                        "Sunday"
                                      ]
                                    },
                                    "wind": {
                                      "type": "object",
                                      "properties": {
                                        "speed": {
                                          "type": "object",
                                          "description": "Unit of measure - Kilometeres per hour",
                                          "properties": {
                                            "low": {
                                              "type": "number",
                                              "example": 35
                                            },
                                            "high": {
                                              "type": "number",
                                              "example": 40
                                            }
                                          }
                                        },
                                        "direction": {
                                          "type": "string",
                                          "example": "SSE"
                                        }
                                      }
                                    }
                                  }
                                }
                              }
                            }
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid HTTP request body",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "code": {
                      "type": "number",
                      "example": 4
                    },
                    "name": {
                      "type": "string",
                      "example": "ERROR_PARAMS"
                    },
                    "data": {
                      "type": "object",
                      "example": null
                    },
                    "errorMsg": {
                      "type": "string",
                      "enum": [
                        "Invalid date format. Date format must be YYYY-MM-DD (2024-06-01) or YYYY-MM-DDTHH:mm:ss (2024-06-01T08:30:00).",
                        "Invalid pagination token."
                      ]
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Weather data not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "code": {
                      "type": "number",
                      "example": 17
                    },
                    "name": {
                      "type": "string",
                      "example": "REAL_TIME_API_DATA_NOT_FOUND"
                    },
                    "data": {
                      "type": "object",
                      "example": null
                    },
                    "errorMsg": {
                      "type": "string",
                      "example": "Data not found"
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}