{
  "openapi": "3.1.0",
  "info": {
    "title": "Elsu outage API",
    "version": "0.2.0",
    "description": "Power and water cuts in Istanbul, from the operators' own published lists. Read-only, free, no key. Not an official source. The same data is available over MCP at /mcp.",
    "contact": {
      "url": "https://elsu.app"
    },
    "license": {
      "name": "Data: attribute Elsu and the operator; streets © OpenStreetMap contributors (ODbL)"
    }
  },
  "servers": [
    {
      "url": "https://elsu.app"
    }
  ],
  "paths": {
    "/v1/istanbul/status": {
      "get": {
        "operationId": "checkOutages",
        "summary": "Power and water status for one address",
        "description": "Per utility: a state (ongoing, planned, restored, clear, none_reported, unavailable), a one-line summary, events with confidence, and sources with health. Never \"clear\" when a source is down.",
        "parameters": [
          {
            "name": "district",
            "in": "query",
            "required": true,
            "description": "District slug, e.g. kadikoy",
            "schema": {
              "type": "string"
            },
            "example": "kadikoy"
          },
          {
            "name": "neighbourhood",
            "in": "query",
            "required": true,
            "description": "Neighbourhood name, e.g. Caferağa",
            "schema": {
              "type": "string"
            },
            "example": "Caferağa"
          },
          {
            "name": "street",
            "in": "query",
            "required": false,
            "description": "Optional street, e.g. Moda Caddesi",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Status",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Status"
                }
              }
            }
          },
          "400": {
            "description": "Missing district or neighbourhood"
          }
        }
      }
    },
    "/v1/istanbul/find": {
      "get": {
        "operationId": "findPlace",
        "summary": "Find a place",
        "description": "Turn free text into Istanbul places Elsu knows: \"Moda Caddesi Kadıköy\", \"caferaga\", \"Bağdat Cd Suadiye\". Returns neighbourhoods and streets with their district, best first. Use the result in check_outages.",
        "parameters": [
          {
            "name": "q",
            "in": "query",
            "required": true,
            "description": "Free text: street and/or neighbourhood, optionally with the district",
            "schema": {
              "type": "string"
            },
            "example": "moda caddesi kadıköy"
          },
          {
            "name": "district",
            "in": "query",
            "required": false,
            "description": "Optional district to search within",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Places",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "query",
                    "places"
                  ],
                  "properties": {
                    "query": {
                      "type": "string"
                    },
                    "places": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "required": [
                          "district",
                          "neighbourhood"
                        ],
                        "properties": {
                          "district": {
                            "type": "string"
                          },
                          "districtSlug": {
                            "type": "string"
                          },
                          "neighbourhood": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "street": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "lat": {
                            "type": [
                              "number",
                              "null"
                            ]
                          },
                          "lon": {
                            "type": [
                              "number",
                              "null"
                            ]
                          },
                          "match": {
                            "type": "string",
                            "enum": [
                              "neighbourhood",
                              "street",
                              "district"
                            ]
                          }
                        }
                      }
                    },
                    "note": {
                      "type": [
                        "string",
                        "null"
                      ]
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/v1/istanbul/districts/{slug}": {
      "get": {
        "operationId": "districtOutages",
        "summary": "Current and recently ended cuts in a district",
        "parameters": [
          {
            "name": "slug",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "example": "kadikoy"
          }
        ],
        "responses": {
          "200": {
            "description": "District status"
          },
          "404": {
            "description": "Unknown district"
          }
        }
      }
    },
    "/v1/istanbul/outages": {
      "get": {
        "operationId": "listOutages",
        "summary": "List outages",
        "description": "Every current and recently ended cut in one district, or across the whole city if no district is given, optionally for one utility or one local day. Use for \"where are the cuts today\" or neighbourhood roundups.",
        "parameters": [
          {
            "name": "district",
            "in": "query",
            "required": false,
            "description": "Optional district",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "utility",
            "in": "query",
            "required": false,
            "description": "power or water",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "date",
            "in": "query",
            "required": false,
            "description": "YYYY-MM-DD, Istanbul time",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "status",
            "in": "query",
            "required": false,
            "description": "now, upcoming or all",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Outages",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "city",
                    "count",
                    "outages",
                    "incomplete",
                    "disclaimer"
                  ],
                  "properties": {
                    "city": {
                      "type": "string"
                    },
                    "count": {
                      "type": "integer"
                    },
                    "outages": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "required": [
                          "id",
                          "district",
                          "utility",
                          "kind",
                          "status",
                          "startsAt",
                          "sourceUrl"
                        ],
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "district": {
                            "type": "string"
                          },
                          "utility": {
                            "type": "string"
                          },
                          "kind": {
                            "type": "string"
                          },
                          "status": {
                            "type": "string"
                          },
                          "startsAt": {
                            "type": "string"
                          },
                          "endsAt": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "reason": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "provider": {
                            "type": "string"
                          },
                          "via": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "sourceUrl": {
                            "type": "string"
                          },
                          "neighbourhoods": {
                            "type": "array",
                            "items": {
                              "type": "object",
                              "properties": {
                                "name": {
                                  "type": [
                                    "string",
                                    "null"
                                  ]
                                },
                                "streets": {
                                  "type": "array",
                                  "items": {
                                    "type": "string"
                                  }
                                }
                              }
                            }
                          }
                        }
                      }
                    },
                    "incomplete": {
                      "type": "boolean"
                    },
                    "sourcesDown": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "notes": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "disclaimer": {
                      "type": "string",
                      "description": "Always pass on: not an official source."
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/v1/istanbul/events/{id}": {
      "get": {
        "operationId": "getOutage",
        "summary": "Outage detail",
        "description": "Full detail for one outage id (from check_outages or list_outages): official text, every area and street, times, source link, and an .ics calendar link. Append .ics to the path for a calendar file.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "example": "bedas:37004051"
          }
        ],
        "responses": {
          "200": {
            "description": "Outage",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "id",
                    "utility",
                    "kind",
                    "status",
                    "startsAt",
                    "sourceUrl",
                    "areas",
                    "disclaimer"
                  ],
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "provider": {
                      "type": "string"
                    },
                    "providerName": {
                      "type": "string"
                    },
                    "via": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "utility": {
                      "type": "string"
                    },
                    "kind": {
                      "type": "string"
                    },
                    "status": {
                      "type": "string"
                    },
                    "startsAt": {
                      "type": "string"
                    },
                    "endsAt": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "reason": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "officialText": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "sourceUrl": {
                      "type": "string"
                    },
                    "calendarUrl": {
                      "type": "string"
                    },
                    "firstSeen": {
                      "type": "string"
                    },
                    "lastChanged": {
                      "type": "string"
                    },
                    "areas": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "district": {
                            "type": "string"
                          },
                          "neighbourhood": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "streets": {
                            "type": "array",
                            "items": {
                              "type": "string"
                            }
                          }
                        }
                      }
                    },
                    "disclaimer": {
                      "type": "string",
                      "description": "Always pass on: not an official source."
                    }
                  }
                }
              },
              "text/calendar": {}
            }
          },
          "404": {
            "description": "Unknown id"
          }
        }
      }
    },
    "/v1/istanbul/health": {
      "get": {
        "operationId": "sourceHealth",
        "summary": "Which sources are up, and when each last updated",
        "responses": {
          "200": {
            "description": "Health"
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "Status": {
        "type": "object",
        "required": [
          "city",
          "district",
          "neighbourhood",
          "utilities",
          "notes",
          "disclaimer"
        ],
        "properties": {
          "city": {
            "type": "string"
          },
          "district": {
            "type": "string"
          },
          "neighbourhood": {
            "type": "string"
          },
          "street": {
            "type": [
              "string",
              "null"
            ]
          },
          "verified": {
            "type": "boolean",
            "description": "Whether the neighbourhood was checked against the gazetteer."
          },
          "streetVerified": {
            "type": "boolean",
            "description": "Whether the street was checked; an unchecked street never hides a cut."
          },
          "utilities": {
            "type": "object",
            "properties": {
              "power": {
                "type": "object",
                "required": [
                  "state",
                  "summary",
                  "events",
                  "incomplete",
                  "sources"
                ],
                "properties": {
                  "state": {
                    "type": "string",
                    "enum": [
                      "ongoing",
                      "planned",
                      "restored",
                      "clear",
                      "none_reported",
                      "unavailable"
                    ]
                  },
                  "summary": {
                    "type": "string",
                    "description": "One plain sentence, safe to quote."
                  },
                  "events": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "required": [
                        "id",
                        "utility",
                        "kind",
                        "status",
                        "startsAt",
                        "sourceUrl"
                      ],
                      "properties": {
                        "id": {
                          "type": "string",
                          "description": "Pass to get_outage for full detail."
                        },
                        "provider": {
                          "type": "string"
                        },
                        "providerName": {
                          "type": "string"
                        },
                        "utility": {
                          "type": "string",
                          "enum": [
                            "power",
                            "water",
                            "gas"
                          ]
                        },
                        "kind": {
                          "type": "string",
                          "enum": [
                            "planned",
                            "unplanned"
                          ]
                        },
                        "status": {
                          "type": "string",
                          "enum": [
                            "active",
                            "ended"
                          ]
                        },
                        "startsAt": {
                          "type": "string",
                          "description": "ISO 8601, Istanbul time."
                        },
                        "endsAt": {
                          "type": [
                            "string",
                            "null"
                          ],
                          "description": "ISO 8601. For unplanned cuts, the operator's estimate."
                        },
                        "reason": {
                          "type": [
                            "string",
                            "null"
                          ]
                        },
                        "sourceUrl": {
                          "type": "string"
                        },
                        "confidence": {
                          "type": "string",
                          "enum": [
                            "street",
                            "neighbourhood",
                            "district"
                          ]
                        }
                      }
                    }
                  },
                  "incomplete": {
                    "type": "boolean",
                    "description": "True when a source for this utility is down."
                  },
                  "sources": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "required": [
                        "provider",
                        "name",
                        "url",
                        "healthy",
                        "coverage"
                      ],
                      "properties": {
                        "provider": {
                          "type": "string"
                        },
                        "name": {
                          "type": "string"
                        },
                        "via": {
                          "type": [
                            "string",
                            "null"
                          ]
                        },
                        "url": {
                          "type": "string"
                        },
                        "healthy": {
                          "type": "boolean"
                        },
                        "coverage": {
                          "type": "string",
                          "enum": [
                            "full",
                            "partial"
                          ]
                        },
                        "kinds": {
                          "type": "array",
                          "items": {
                            "type": "string"
                          }
                        },
                        "lastSuccessAt": {
                          "type": [
                            "string",
                            "null"
                          ]
                        },
                        "coverageNote": {
                          "type": "string",
                          "description": "What a partial source misses, e.g. a publishing lag."
                        }
                      }
                    }
                  },
                  "lastUpdate": {
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "elsewhereInNeighbourhood": {
                    "type": "integer",
                    "description": "Cuts in the neighbourhood that list other streets, not this one."
                  }
                }
              },
              "water": {
                "type": "object",
                "required": [
                  "state",
                  "summary",
                  "events",
                  "incomplete",
                  "sources"
                ],
                "properties": {
                  "state": {
                    "type": "string",
                    "enum": [
                      "ongoing",
                      "planned",
                      "restored",
                      "clear",
                      "none_reported",
                      "unavailable"
                    ]
                  },
                  "summary": {
                    "type": "string",
                    "description": "One plain sentence, safe to quote."
                  },
                  "events": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "required": [
                        "id",
                        "utility",
                        "kind",
                        "status",
                        "startsAt",
                        "sourceUrl"
                      ],
                      "properties": {
                        "id": {
                          "type": "string",
                          "description": "Pass to get_outage for full detail."
                        },
                        "provider": {
                          "type": "string"
                        },
                        "providerName": {
                          "type": "string"
                        },
                        "utility": {
                          "type": "string",
                          "enum": [
                            "power",
                            "water",
                            "gas"
                          ]
                        },
                        "kind": {
                          "type": "string",
                          "enum": [
                            "planned",
                            "unplanned"
                          ]
                        },
                        "status": {
                          "type": "string",
                          "enum": [
                            "active",
                            "ended"
                          ]
                        },
                        "startsAt": {
                          "type": "string",
                          "description": "ISO 8601, Istanbul time."
                        },
                        "endsAt": {
                          "type": [
                            "string",
                            "null"
                          ],
                          "description": "ISO 8601. For unplanned cuts, the operator's estimate."
                        },
                        "reason": {
                          "type": [
                            "string",
                            "null"
                          ]
                        },
                        "sourceUrl": {
                          "type": "string"
                        },
                        "confidence": {
                          "type": "string",
                          "enum": [
                            "street",
                            "neighbourhood",
                            "district"
                          ]
                        }
                      }
                    }
                  },
                  "incomplete": {
                    "type": "boolean",
                    "description": "True when a source for this utility is down."
                  },
                  "sources": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "required": [
                        "provider",
                        "name",
                        "url",
                        "healthy",
                        "coverage"
                      ],
                      "properties": {
                        "provider": {
                          "type": "string"
                        },
                        "name": {
                          "type": "string"
                        },
                        "via": {
                          "type": [
                            "string",
                            "null"
                          ]
                        },
                        "url": {
                          "type": "string"
                        },
                        "healthy": {
                          "type": "boolean"
                        },
                        "coverage": {
                          "type": "string",
                          "enum": [
                            "full",
                            "partial"
                          ]
                        },
                        "kinds": {
                          "type": "array",
                          "items": {
                            "type": "string"
                          }
                        },
                        "lastSuccessAt": {
                          "type": [
                            "string",
                            "null"
                          ]
                        },
                        "coverageNote": {
                          "type": "string",
                          "description": "What a partial source misses, e.g. a publishing lag."
                        }
                      }
                    }
                  },
                  "lastUpdate": {
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "elsewhereInNeighbourhood": {
                    "type": "integer",
                    "description": "Cuts in the neighbourhood that list other streets, not this one."
                  }
                }
              },
              "gas": {
                "type": "object",
                "required": [
                  "state",
                  "summary",
                  "events",
                  "incomplete",
                  "sources"
                ],
                "properties": {
                  "state": {
                    "type": "string",
                    "enum": [
                      "ongoing",
                      "planned",
                      "restored",
                      "clear",
                      "none_reported",
                      "unavailable"
                    ]
                  },
                  "summary": {
                    "type": "string",
                    "description": "One plain sentence, safe to quote."
                  },
                  "events": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "required": [
                        "id",
                        "utility",
                        "kind",
                        "status",
                        "startsAt",
                        "sourceUrl"
                      ],
                      "properties": {
                        "id": {
                          "type": "string",
                          "description": "Pass to get_outage for full detail."
                        },
                        "provider": {
                          "type": "string"
                        },
                        "providerName": {
                          "type": "string"
                        },
                        "utility": {
                          "type": "string",
                          "enum": [
                            "power",
                            "water",
                            "gas"
                          ]
                        },
                        "kind": {
                          "type": "string",
                          "enum": [
                            "planned",
                            "unplanned"
                          ]
                        },
                        "status": {
                          "type": "string",
                          "enum": [
                            "active",
                            "ended"
                          ]
                        },
                        "startsAt": {
                          "type": "string",
                          "description": "ISO 8601, Istanbul time."
                        },
                        "endsAt": {
                          "type": [
                            "string",
                            "null"
                          ],
                          "description": "ISO 8601. For unplanned cuts, the operator's estimate."
                        },
                        "reason": {
                          "type": [
                            "string",
                            "null"
                          ]
                        },
                        "sourceUrl": {
                          "type": "string"
                        },
                        "confidence": {
                          "type": "string",
                          "enum": [
                            "street",
                            "neighbourhood",
                            "district"
                          ]
                        }
                      }
                    }
                  },
                  "incomplete": {
                    "type": "boolean",
                    "description": "True when a source for this utility is down."
                  },
                  "sources": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "required": [
                        "provider",
                        "name",
                        "url",
                        "healthy",
                        "coverage"
                      ],
                      "properties": {
                        "provider": {
                          "type": "string"
                        },
                        "name": {
                          "type": "string"
                        },
                        "via": {
                          "type": [
                            "string",
                            "null"
                          ]
                        },
                        "url": {
                          "type": "string"
                        },
                        "healthy": {
                          "type": "boolean"
                        },
                        "coverage": {
                          "type": "string",
                          "enum": [
                            "full",
                            "partial"
                          ]
                        },
                        "kinds": {
                          "type": "array",
                          "items": {
                            "type": "string"
                          }
                        },
                        "lastSuccessAt": {
                          "type": [
                            "string",
                            "null"
                          ]
                        },
                        "coverageNote": {
                          "type": "string",
                          "description": "What a partial source misses, e.g. a publishing lag."
                        }
                      }
                    }
                  },
                  "lastUpdate": {
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "elsewhereInNeighbourhood": {
                    "type": "integer",
                    "description": "Cuts in the neighbourhood that list other streets, not this one."
                  }
                }
              }
            }
          },
          "notes": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Corrections made and anything that could not be checked."
          },
          "updatedAt": {
            "type": [
              "string",
              "null"
            ]
          },
          "disclaimer": {
            "type": "string",
            "description": "Always pass on: not an official source."
          }
        }
      }
    }
  }
}