{
 "openapi": "3.1.0",
 "info": {
  "title": "Hi Weather! API",
  "version": "1.0.0",
  "description": "Current weather, 24-hour and 7-day forecasts by English city name, city id or coordinates. No key required. Weather data from MET Norway, place names from GeoNames, both CC BY 4.0."
 },
 "servers": [
  {
   "url": "https://hiweather.com"
  }
 ],
 "paths": {
  "/api/weather": {
   "get": {
    "operationId": "getWeather",
    "summary": "Weather for a city or coordinates",
    "description": "Pass one of q, id, or lat with lon. With none, the location of the caller's network address is used.",
    "parameters": [
     {
      "name": "q",
      "in": "query",
      "schema": {
       "type": "string"
      },
      "description": "English city name, optionally with \", region\" or \", country\".",
      "example": "Springfield, Illinois"
     },
     {
      "name": "id",
      "in": "query",
      "schema": {
       "type": "integer"
      },
      "description": "City id from /api/search."
     },
     {
      "name": "lat",
      "in": "query",
      "schema": {
       "type": "number",
       "minimum": -90,
       "maximum": 90
      }
     },
     {
      "name": "lon",
      "in": "query",
      "schema": {
       "type": "number",
       "minimum": -180,
       "maximum": 180
      }
     },
     {
      "name": "timezone",
      "in": "query",
      "schema": {
       "type": "string"
      },
      "description": "IANA zone used with lat and lon. Default UTC."
     }
    ],
    "responses": {
     "200": {
      "description": "Forecast",
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "properties": {
          "location": {
           "type": "object",
           "properties": {
            "id": {
             "type": "integer"
            },
            "name": {
             "type": "string"
            },
            "matched_name": {
             "type": "string",
             "description": "The variant that matched the query, when it differs from name."
            },
            "admin1": {
             "type": "string",
             "description": "State, province or region."
            },
            "country": {
             "type": "string"
            },
            "country_code": {
             "type": "string"
            },
            "latitude": {
             "type": "number"
            },
            "longitude": {
             "type": "number"
            },
            "timezone": {
             "type": "string"
            },
            "population": {
             "type": "integer"
            },
            "page": {
             "type": "string",
             "format": "uri",
             "description": "Web page for this city. Only the cities listed at /cities are open to search engine indexing."
            },
            "api": {
             "type": "string",
             "format": "uri"
            },
            "source": {
             "type": "string",
             "enum": [
              "city",
              "coordinates",
              "ip"
             ]
            }
           }
          },
          "current": {
           "type": "object"
          },
          "outlook": {
           "type": "array",
           "items": {
            "type": "string"
           },
           "description": "Plain-English sentences on the next 24 hours."
          },
          "plan": {
           "type": "array",
           "description": "Best windows in the next 24 hours by activity, and the 12-hour pressure trend.",
           "items": {
            "type": "object",
            "properties": {
             "key": {
              "type": "string",
              "enum": [
               "running",
               "cycling",
               "laundry",
               "golden_hour",
               "stargazing",
               "drone",
               "pressure"
              ]
             },
             "title": {
              "type": "string"
             },
             "rating": {
              "type": [
               "string",
               "null"
              ],
              "enum": [
               "good",
               "fair",
               "poor",
               null
              ]
             },
             "label": {
              "type": "string"
             },
             "when": {
              "type": "string",
              "description": "Window in local time, e.g. \"tomorrow 07:00 to 10:00\"."
             },
             "start": {
              "type": "string",
              "format": "date-time"
             },
             "end": {
              "type": "string",
              "format": "date-time"
             },
             "text": {
              "type": "string"
             }
            }
           }
          },
          "sun": {
           "type": "array",
           "items": {
            "type": "object"
           }
          },
          "live_cams": {
           "type": "array",
           "items": {
            "type": "object",
            "properties": {
             "place": {
              "type": "string"
             },
             "channel": {
              "type": "string"
             },
             "url": {
              "type": "string",
              "format": "uri"
             }
            }
           }
          },
          "hourly": {
           "type": "array",
           "items": {
            "type": "object"
           }
          },
          "daily": {
           "type": "array",
           "items": {
            "type": "object"
           }
          },
          "units": {
           "type": "object"
          },
          "forecast_updated_at": {
           "type": "string",
           "format": "date-time"
          },
          "other_matches": {
           "type": "array",
           "items": {
            "type": "object",
            "properties": {
             "id": {
              "type": "integer"
             },
             "name": {
              "type": "string"
             },
             "matched_name": {
              "type": "string",
              "description": "The variant that matched the query, when it differs from name."
             },
             "admin1": {
              "type": "string",
              "description": "State, province or region."
             },
             "country": {
              "type": "string"
             },
             "country_code": {
              "type": "string"
             },
             "latitude": {
              "type": "number"
             },
             "longitude": {
              "type": "number"
             },
             "timezone": {
              "type": "string"
             },
             "population": {
              "type": "integer"
             },
             "page": {
              "type": "string",
              "format": "uri",
              "description": "Web page for this city. Only the cities listed at /cities are open to search engine indexing."
             },
             "api": {
              "type": "string",
              "format": "uri"
             }
            }
           }
          },
          "attribution": {
           "type": "string"
          }
         }
        }
       }
      }
     },
     "400": {
      "description": "Bad request",
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "properties": {
          "error": {
           "type": "string"
          },
          "message": {
           "type": "string"
          }
         }
        }
       }
      }
     },
     "404": {
      "description": "No such city",
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "properties": {
          "error": {
           "type": "string"
          },
          "message": {
           "type": "string"
          }
         }
        }
       }
      }
     },
     "429": {
      "description": "More than 20 requests a minute from this network address",
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "properties": {
          "error": {
           "type": "string"
          },
          "message": {
           "type": "string"
          }
         }
        }
       }
      }
     },
     "502": {
      "description": "Forecast source unavailable",
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "properties": {
          "error": {
           "type": "string"
          },
          "message": {
           "type": "string"
          }
         }
        }
       }
      }
     }
    }
   }
  },
  "/api/search": {
   "get": {
    "operationId": "searchCities",
    "summary": "Search cities by English name",
    "parameters": [
     {
      "name": "q",
      "in": "query",
      "required": true,
      "schema": {
       "type": "string"
      },
      "example": "Portland, OR"
     },
     {
      "name": "limit",
      "in": "query",
      "schema": {
       "type": "integer",
       "minimum": 1,
       "maximum": 20,
       "default": 10
      }
     },
     {
      "name": "pages_only",
      "in": "query",
      "schema": {
       "type": "integer",
       "enum": [
        1
       ]
      },
      "description": "Only the cities listed at /cities."
     }
    ],
    "responses": {
     "200": {
      "description": "Matches",
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "properties": {
          "query": {
           "type": "string"
          },
          "results": {
           "type": "array",
           "items": {
            "type": "object",
            "properties": {
             "id": {
              "type": "integer"
             },
             "name": {
              "type": "string"
             },
             "matched_name": {
              "type": "string",
              "description": "The variant that matched the query, when it differs from name."
             },
             "admin1": {
              "type": "string",
              "description": "State, province or region."
             },
             "country": {
              "type": "string"
             },
             "country_code": {
              "type": "string"
             },
             "latitude": {
              "type": "number"
             },
             "longitude": {
              "type": "number"
             },
             "timezone": {
              "type": "string"
             },
             "population": {
              "type": "integer"
             },
             "page": {
              "type": "string",
              "format": "uri",
              "description": "Web page for this city. Only the cities listed at /cities are open to search engine indexing."
             },
             "api": {
              "type": "string",
              "format": "uri"
             }
            }
           }
          }
         }
        }
       }
      }
     },
     "400": {
      "description": "Bad request",
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "properties": {
          "error": {
           "type": "string"
          },
          "message": {
           "type": "string"
          }
         }
        }
       }
      }
     },
     "429": {
      "description": "More than 20 requests a minute from this network address",
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "properties": {
          "error": {
           "type": "string"
          },
          "message": {
           "type": "string"
          }
         }
        }
       }
      }
     }
    }
   }
  }
 }
}