{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/geogridapi-io/json-schema/geogridapi-io-grid-schema.json",
  "title": "Grid",
  "x-generated": "2026-11-09",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/geogridapi-io-openapi.json#/components/schemas/Grid",
  "type": "object",
  "properties": {
    "id": {
      "type": "string",
      "format": "uuid"
    },
    "object": {
      "type": "string",
      "enum": [
        "grid"
      ]
    },
    "status": {
      "type": "string",
      "enum": [
        "pending",
        "running",
        "completed",
        "failed"
      ]
    },
    "mode": {
      "type": "string",
      "enum": [
        "live",
        "test"
      ]
    },
    "source": {
      "type": "string",
      "enum": [
        "api",
        "mcp",
        "console"
      ]
    },
    "api_key_id": {
      "type": [
        "string",
        "null"
      ]
    },
    "place": {
      "$ref": "#/$defs/Place"
    },
    "keyword": {
      "type": "string"
    },
    "shape": {
      "type": "string"
    },
    "density": {
      "type": [
        "string",
        "null"
      ]
    },
    "size": {
      "type": "integer"
    },
    "rows": {
      "type": "integer"
    },
    "cols": {
      "type": "integer"
    },
    "radius_km": {
      "type": "number"
    },
    "language": {
      "type": "string"
    },
    "country": {
      "type": [
        "string",
        "null"
      ]
    },
    "points_total": {
      "type": "integer",
      "description": "Grid points measured (points at sea are neither measured nor charged)."
    },
    "points_charged": {
      "type": "integer",
      "description": "Credits charged to the GeoGridAPI balance (0 with a test key or through RapidAPI)."
    },
    "summary": {
      "$ref": "#/$defs/GridSummary"
    },
    "ranks": {
      "type": [
        "array",
        "null"
      ],
      "description": "rows × cols matrix, row 0 = north, column 0 = west. null = not in the top 20 (or outside the shape).",
      "items": {
        "type": "array",
        "items": {
          "type": [
            "integer",
            "null"
          ]
        }
      }
    },
    "points": {
      "type": [
        "array",
        "null"
      ],
      "items": {
        "$ref": "#/$defs/GridPoint"
      }
    },
    "competitors": {
      "type": [
        "array",
        "null"
      ],
      "items": {
        "$ref": "#/$defs/Competitor"
      },
      "description": "Who ranks ahead: the top 3 listings summed over the map."
    },
    "previous": {
      "$ref": "#/$defs/PreviousGrid"
    },
    "error": {
      "$ref": "#/$defs/GridError"
    },
    "webhook": {
      "type": [
        "object",
        "null"
      ],
      "description": "Delivery of the webhook_url, when one was given.",
      "properties": {
        "status": {
          "type": [
            "string",
            "null"
          ]
        },
        "attempts": {
          "type": "integer"
        }
      }
    },
    "created_at": {
      "type": "string",
      "format": "date-time"
    },
    "completed_at": {
      "type": [
        "string",
        "null"
      ],
      "format": "date-time"
    }
  },
  "$defs": {
    "Competitor": {
      "type": "object",
      "properties": {
        "place_id": {
          "type": "string"
        },
        "name": {
          "type": "string"
        },
        "top3_points": {
          "type": "integer",
          "description": "Points where it is in the top 3."
        },
        "first_points": {
          "type": "integer",
          "description": "Points where it ranks first."
        },
        "ahead_points": {
          "type": "integer",
          "description": "Points where it ranks ahead of your listing."
        }
      }
    },
    "GridError": {
      "type": [
        "object",
        "null"
      ],
      "description": "Why a grid (or a batch item) failed; null otherwise.",
      "required": [
        "code",
        "message"
      ],
      "properties": {
        "code": {
          "type": "string"
        },
        "message": {
          "type": "string"
        }
      }
    },
    "GridPoint": {
      "type": "object",
      "properties": {
        "row": {
          "type": "integer",
          "description": "0 = north."
        },
        "col": {
          "type": "integer",
          "description": "0 = west."
        },
        "lat": {
          "type": "number"
        },
        "lng": {
          "type": "number"
        },
        "rank": {
          "type": [
            "integer",
            "null"
          ],
          "description": "Position in the Google Maps results at this point; null = not in the top 20."
        },
        "top": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/TopListing"
          },
          "description": "Top 3 listings at this point."
        }
      }
    },
    "GridSummary": {
      "type": [
        "object",
        "null"
      ],
      "properties": {
        "average_rank": {
          "type": [
            "number",
            "null"
          ],
          "description": "Mean rank over the points where the listing appears."
        },
        "average_rank_with_misses": {
          "type": [
            "number",
            "null"
          ],
          "description": "Mean rank with misses counted as 21."
        },
        "top3_points": {
          "type": "integer"
        },
        "found_points": {
          "type": "integer"
        }
      }
    },
    "Place": {
      "type": "object",
      "properties": {
        "place_id": {
          "type": "string"
        },
        "name": {
          "type": [
            "string",
            "null"
          ]
        },
        "address": {
          "type": [
            "string",
            "null"
          ]
        },
        "lat": {
          "type": "number"
        },
        "lng": {
          "type": "number"
        }
      }
    },
    "PreviousGrid": {
      "type": [
        "object",
        "null"
      ],
      "description": "Change since the previous grid of the same map (same listing, keyword, format, radius and center).",
      "properties": {
        "grid_id": {
          "type": "string",
          "format": "uuid"
        },
        "created_at": {
          "type": "string",
          "format": "date-time"
        },
        "average_rank": {
          "type": [
            "number",
            "null"
          ]
        },
        "top3_points": {
          "type": "integer"
        },
        "found_points": {
          "type": "integer"
        },
        "changes": {
          "type": "object",
          "properties": {
            "average_rank": {
              "type": [
                "number",
                "null"
              ],
              "description": "Negative = better."
            },
            "top3_points": {
              "type": "integer"
            },
            "found_points": {
              "type": "integer"
            }
          }
        },
        "ranks": {
          "type": "array",
          "items": {
            "type": "array",
            "items": {
              "type": [
                "integer",
                "null"
              ]
            }
          }
        },
        "rank_changes": {
          "type": "array",
          "items": {
            "type": "array",
            "items": {
              "type": [
                "integer",
                "null"
              ]
            }
          },
          "description": "Places gained per cell (positive = better, a miss counts as 21)."
        },
        "points": {
          "type": "object",
          "properties": {
            "improved": {
              "type": "integer"
            },
            "worsened": {
              "type": "integer"
            },
            "unchanged": {
              "type": "integer"
            }
          }
        }
      }
    },
    "TopListing": {
      "type": "object",
      "properties": {
        "rank": {
          "type": "integer"
        },
        "place_id": {
          "type": "string"
        },
        "name": {
          "type": "string"
        }
      }
    }
  }
}