{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://housebook.global/feed-spec/housebook-feed-v1.schema.json",
  "title": "Housebook developer and partner feed, version 1",
  "description": "Ids stay stable across exports, updated_at is ISO 8601, prices are numbers, photos are direct links, the file is UTF-8. One file per URL; next_url is optional and only needed when the export does not fit into a single response.",
  "type": "object",
  "properties": {
    "version": {
      "type": "string",
      "const": "1"
    },
    "provider": {
      "type": "object",
      "properties": {
        "name": {
          "type": "string",
          "minLength": 1
        },
        "country": {
          "type": "string",
          "enum": [
            "AE",
            "AZ",
            "CL",
            "CY",
            "GE",
            "ID",
            "OM",
            "PA",
            "SA",
            "TH",
            "TR",
            "US",
            "UZ"
          ]
        },
        "contact": {
          "type": "string",
          "minLength": 1
        }
      },
      "required": [
        "name",
        "country",
        "contact"
      ]
    },
    "generated_at": {
      "type": "string",
      "pattern": "^\\d{4}-\\d{2}-\\d{2}([Tt ]\\d{2}:\\d{2}(:\\d{2}(\\.\\d+)?)?([Zz]|[+-]\\d{2}:?\\d{2}))?$"
    },
    "buildings": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "minLength": 1
          },
          "name": {
            "type": "string",
            "minLength": 1
          },
          "country": {
            "type": "string",
            "enum": [
              "AE",
              "AZ",
              "CL",
              "CY",
              "GE",
              "ID",
              "OM",
              "PA",
              "SA",
              "TH",
              "TR",
              "US",
              "UZ"
            ]
          },
          "city": {
            "type": "string",
            "minLength": 1
          },
          "district": {
            "type": "string"
          },
          "address": {
            "type": "string"
          },
          "lat": {
            "type": "number",
            "minimum": -90,
            "maximum": 90
          },
          "lng": {
            "type": "number",
            "minimum": -180,
            "maximum": 180
          },
          "developer": {
            "type": "object",
            "properties": {
              "name": {
                "type": "string",
                "minLength": 1
              },
              "id": {
                "type": "string"
              }
            },
            "required": [
              "name"
            ]
          },
          "completion": {
            "type": "object",
            "properties": {
              "status": {
                "type": "string",
                "enum": [
                  "planned",
                  "under_construction",
                  "completed"
                ]
              },
              "date": {
                "type": "string",
                "pattern": "^\\d{4}-\\d{2}(-\\d{2})?$"
              }
            },
            "required": [
              "status"
            ]
          },
          "ownership": {
            "type": "string",
            "enum": [
              "freehold",
              "leasehold",
              "other"
            ]
          },
          "description": {
            "type": "object",
            "propertyNames": {
              "type": "string",
              "pattern": "^[a-z]{2}$"
            },
            "additionalProperties": {
              "type": "string"
            }
          },
          "photos": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "url": {
                  "type": "string",
                  "pattern": "^https?:\\/\\/"
                },
                "kind": {
                  "type": "string",
                  "enum": [
                    "photo",
                    "plan",
                    "masterplan",
                    "facility"
                  ]
                }
              },
              "required": [
                "url"
              ]
            }
          },
          "amenities": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "updated_at": {
            "type": "string",
            "pattern": "^\\d{4}-\\d{2}-\\d{2}([Tt ]\\d{2}:\\d{2}(:\\d{2}(\\.\\d+)?)?([Zz]|[+-]\\d{2}:?\\d{2}))?$"
          }
        },
        "required": [
          "id",
          "name",
          "country",
          "city",
          "developer",
          "updated_at"
        ]
      }
    },
    "units": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "minLength": 1
          },
          "building_id": {
            "type": "string",
            "minLength": 1
          },
          "type": {
            "type": "string",
            "enum": [
              "studio",
              "1br",
              "2br",
              "3br",
              "4br+",
              "villa",
              "townhouse",
              "penthouse",
              "land",
              "commercial"
            ]
          },
          "bedrooms": {
            "type": "integer",
            "minimum": 0,
            "maximum": 9007199254740991
          },
          "bathrooms": {
            "type": "integer",
            "minimum": 0,
            "maximum": 9007199254740991
          },
          "area": {
            "type": "object",
            "properties": {
              "value": {
                "type": "number",
                "exclusiveMinimum": 0
              },
              "unit": {
                "type": "string",
                "enum": [
                  "sqm",
                  "sqft"
                ]
              }
            },
            "required": [
              "value",
              "unit"
            ]
          },
          "floor": {
            "type": "integer",
            "minimum": -9007199254740991,
            "maximum": 9007199254740991
          },
          "price": {
            "type": "object",
            "properties": {
              "amount": {
                "type": "number",
                "exclusiveMinimum": 0
              },
              "currency": {
                "type": "string",
                "pattern": "^[A-Z]{3}$"
              },
              "per": {
                "type": "string",
                "enum": [
                  "total",
                  "sqm",
                  "sqft"
                ]
              }
            },
            "required": [
              "amount",
              "currency",
              "per"
            ]
          },
          "status": {
            "type": "string",
            "enum": [
              "available",
              "reserved",
              "sold"
            ]
          },
          "floor_plan_url": {
            "type": "string",
            "pattern": "^https?:\\/\\/"
          },
          "updated_at": {
            "type": "string",
            "pattern": "^\\d{4}-\\d{2}-\\d{2}([Tt ]\\d{2}:\\d{2}(:\\d{2}(\\.\\d+)?)?([Zz]|[+-]\\d{2}:?\\d{2}))?$"
          }
        },
        "required": [
          "id",
          "building_id",
          "type",
          "area",
          "price",
          "status",
          "updated_at"
        ]
      }
    },
    "next_url": {
      "type": "string",
      "pattern": "^https?:\\/\\/"
    }
  },
  "required": [
    "version",
    "provider",
    "generated_at",
    "buildings",
    "units"
  ]
}
