{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/gasquebec-ca/json-schema/gasquebec-ca-city-prices-schema.json",
  "title": "CityPrices",
  "x-generated": "2026-11-09",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/gasquebec-ca-openapi.yml#/components/schemas/CityPrices",
  "type": "object",
  "properties": {
    "citySlug": {
      "type": "string",
      "description": "Canonical slug — the one to poll. A renamed or merged slug (quebec-city, deschaillons, …) resolves here."
    },
    "city": {
      "type": "string"
    },
    "region": {
      "type": "object",
      "properties": {
        "slug": {
          "type": "string"
        },
        "fr": {
          "type": [
            "string",
            "null"
          ]
        },
        "en": {
          "type": [
            "string",
            "null"
          ]
        }
      }
    },
    "stationCount": {
      "type": "integer",
      "description": "Every station listed under the city, fresh or stale"
    },
    "updatedAt": {
      "type": [
        "string",
        "null"
      ],
      "format": "date-time",
      "description": "When the city aggregate was last rebuilt"
    },
    "unit": {
      "type": "string",
      "const": "¢/L"
    },
    "currency": {
      "type": "string",
      "const": "CAD"
    },
    "prices": {
      "type": "object",
      "properties": {
        "regular": {
          "$ref": "#/$defs/FuelStats"
        },
        "premium": {
          "$ref": "#/$defs/FuelStats"
        },
        "diesel": {
          "$ref": "#/$defs/FuelStats"
        }
      }
    },
    "typicalGapRegular": {
      "type": [
        "number",
        "null"
      ],
      "description": "Typical ¢/L between the city's cheapest non-Costco station and their mean, regular fuel: 30-day median of noon and 6 pm samples, rounded down. Null when the city lacks the samples."
    },
    "stations": {
      "type": "array",
      "description": "Fresh stations first, cheapest regular first; stale stations trail",
      "items": {
        "$ref": "#/$defs/CityPricesStation"
      }
    },
    "links": {
      "type": "object",
      "properties": {
        "page": {
          "type": "object",
          "properties": {
            "fr": {
              "type": "string",
              "format": "uri"
            },
            "en": {
              "type": "string",
              "format": "uri"
            }
          }
        },
        "fairPrice": {
          "type": "string",
          "format": "uri"
        }
      }
    },
    "meta": {
      "type": "object",
      "properties": {
        "source": {
          "type": "string"
        },
        "dataSource": {
          "type": "object",
          "description": "Attribution for the underlying price data — must be preserved when redistributing"
        },
        "attribution": {
          "$ref": "#/$defs/Attribution"
        },
        "license": {
          "type": "string",
          "format": "uri"
        },
        "staleAfterDays": {
          "type": "integer"
        }
      }
    }
  },
  "$defs": {
    "Attribution": {
      "type": "object",
      "description": "Ready-to-use link-back credit. Required wherever the data is displayed publicly (API terms: https://www.gasquebec.ca/en/terms); private use is exempt.",
      "properties": {
        "url": {
          "type": "string",
          "format": "uri",
          "description": "Page to link to: the city page for city data, otherwise https://www.gasquebec.ca/"
        },
        "text": {
          "type": "object",
          "properties": {
            "fr": {
              "type": "string"
            },
            "en": {
              "type": "string"
            }
          }
        },
        "html": {
          "type": "object",
          "description": "`text` with \"Gas Québec\" as a link to `url`, ready to paste",
          "properties": {
            "fr": {
              "type": "string"
            },
            "en": {
              "type": "string"
            }
          }
        }
      },
      "required": [
        "url",
        "text",
        "html"
      ]
    },
    "CityPricesStation": {
      "type": "object",
      "description": "One station under the city. Price fields share their names with NearbyStation.",
      "properties": {
        "stationId": {
          "type": "string"
        },
        "name": {
          "type": "string"
        },
        "brand": {
          "type": "string"
        },
        "address": {
          "type": "string"
        },
        "lat": {
          "type": [
            "number",
            "null"
          ]
        },
        "lng": {
          "type": [
            "number",
            "null"
          ]
        },
        "prixOrdinaire": {
          "type": [
            "number",
            "null"
          ],
          "description": "Regular, ¢/L"
        },
        "prixSuper": {
          "type": [
            "number",
            "null"
          ],
          "description": "Premium, ¢/L"
        },
        "prixDiesel": {
          "type": [
            "number",
            "null"
          ],
          "description": "Diesel, ¢/L"
        },
        "updatedAt": {
          "type": [
            "string",
            "null"
          ],
          "format": "date-time",
          "description": "When the station last reported a price change"
        },
        "stale": {
          "type": "boolean",
          "description": "True when the price is unconfirmed: frozen for 7+ days, or disputed by a corroborated visitor report (in which case `updatedAt` can be recent). Listed for completeness, excluded from `prices`."
        }
      }
    },
    "FuelStats": {
      "type": "object",
      "description": "Summary for one fuel over the city's fresh stations (price updated within 7 days). Null when no fresh station posts that fuel.",
      "properties": {
        "cheapest": {
          "type": [
            "number",
            "null"
          ],
          "description": "Lowest fresh price, ¢/L — the city page's \"lowest price\" tile"
        },
        "average": {
          "type": [
            "number",
            "null"
          ],
          "description": "Mean of fresh prices to one decimal, ¢/L — the city page's \"average\" tile"
        },
        "stationCount": {
          "type": "integer",
          "description": "Fresh stations posting this fuel"
        }
      }
    }
  }
}