{
  "openapi": "3.1.1",
  "info": {
    "title": "Geo Data Visualizer API",
    "version": "1.0.0",
    "summary": "Map CSV coordinates or GeoJSON as points, proportional circles, hex-bin heatmaps or choropleths.",
    "description": "Every endpoint performs the same calculation as the human page and returns inputs, result, units, assumptions, sources, warnings and computedAt. MCP endpoint: /mcp."
  },
  "servers": [
    {
      "url": "https://geodatavisualizer.usefulweb.site"
    }
  ],
  "paths": {
    "/api/v1/calculate": {
      "post": {
        "operationId": "calculate",
        "summary": "Map CSV coordinates or GeoJSON as points, proportional circles, hex-bin heatmaps or choropleths.",
        "description": "Upload a CSV/XLSX with latitude/longitude (plus optional value and label) or a country-code column, or a GeoJSON file with points, lines and polygons. Get an SVG map over bundled Natural Earth country outlines in the Equal Earth, Mercator or equirectangular projection – as points, proportional symbols, a hexagonal-bin heatmap or a choropleth – zoomed to your data, with SVG/PNG downloads.\n\nMethodology:\n- Input detection: text starting with \"{\" is read as GeoJSON (FeatureCollection, Feature or bare geometry; Point, MultiPoint, LineString, MultiLineString, Polygon, MultiPolygon, GeometryCollection). Anything else is a table (CSV/TSV/XLSX); lat/lon and country columns are found by name unless you name them.\n- Coordinates must be WGS 84 decimal degrees (longitude −180…180, latitude −90…90); rows outside the range or without numbers are skipped and counted.\n- Projections: equirectangular x = λ, y = φ; Mercator y = ln tan(π/4 + φ/2) (clipped at ±85°); Equal Earth (Šavrič, Patterson & Jenny 2018), an equal-area projection suitable for world maps and for comparing densities.\n- Auto zoom fits the bounding box of the data plus 20 % margin (at least 4° × 3°); views wider than 300° of longitude show the whole world.\n- Hex-bin heatmap: points are projected, assigned to pointy-top hexagons of the chosen pixel size (cube-coordinate rounding) and coloured by count, or by the sum of the value column, on a colour-blind-safe viridis-like ramp.\n- Proportional circles: circle area is proportional to |value| (radius ∝ √value, largest 26 px); larger circles are drawn first so small ones stay visible. Choropleth: country codes/names are matched to the bundled outlines and shaded in up to five quantile classes; unmatched entries are listed.\n- Country outlines are Natural Earth 1:110m (public domain): small countries and islands such as Singapore, Malta or Andorra are not part of this scale and cannot be shaded. Borders follow Natural Earth’s de facto conventions and are not a statement on disputed territories.",
        "tags": [
          "charts"
        ],
        "x-mcp-tool": "geo_data_visualizer",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/GeoDataVisualizerInput"
              },
              "examples": {
                "example1": {
                  "summary": "Offices as proportional circles (staff, example data)",
                  "value": {
                    "data": "office,lat,lon,staff\nTokyo,35.68,139.69,42\nDelhi,28.61,77.21,18\nShanghai,31.23,121.47,25\nSão Paulo,-23.55,-46.63,12\nMexico City,19.43,-99.13,9\nCairo,30.04,31.24,6\nMumbai,19.08,72.88,21\nNairobi,-1.29,36.82,7\nNew York,40.71,-74.01,55\nLagos,6.52,3.38,8\nParis,48.86,2.35,31\nLondon,51.51,-0.13,47\nBerlin,52.52,13.40,26\nToronto,43.65,-79.38,14\nSydney,-33.87,151.21,11",
                    "mode": "proportional",
                    "valueColumn": "staff",
                    "labelColumn": "office",
                    "zoom": "world",
                    "title": "Staff per office (example data)"
                  }
                },
                "example2": {
                  "summary": "Choropleth by ISO code or country name",
                  "value": {
                    "data": "country,customers\nUS,420\nDE,310\nFR,180\nGB,220\nES,95\nIT,120\nNL,85\nPL,60\nSE,45\nBR,70\nMX,40\nCA,110\nJP,130\nIN,75\nAU,65\nZA,20\nKE,12\nNorway,30\nCzechia,25\nPRT,33",
                    "mode": "choropleth",
                    "title": "Customers by country (example data)",
                    "png": false
                  }
                },
                "example3": {
                  "summary": "GeoJSON points, a route and an area (Mercator)",
                  "value": {
                    "data": "{\"type\":\"FeatureCollection\",\"features\":[{\"type\":\"Feature\",\"properties\":{\"name\":\"Lisbon\"},\"geometry\":{\"type\":\"Point\",\"coordinates\":[-9.14,38.72]}},{\"type\":\"Feature\",\"properties\":{\"name\":\"Madrid\"},\"geometry\":{\"type\":\"Point\",\"coordinates\":[-3.7,40.42]}},{\"type\":\"Feature\",\"properties\":{\"name\":\"Barcelona\"},\"geometry\":{\"type\":\"Point\",\"coordinates\":[2.17,41.39]}},{\"type\":\"Feature\",\"properties\":{\"name\":\"Route\"},\"geometry\":{\"type\":\"LineString\",\"coordinates\":[[-9.14,38.72],[-3.7,40.42],[2.17,41.39]]}},{\"type\":\"Feature\",\"properties\":{\"name\":\"Study area\"},\"geometry\":{\"type\":\"Polygon\",\"coordinates\":[[[-6,37],[-2,37],[-2,39.5],[-6,39.5],[-6,37]]]}}]}",
                    "projection": "mercator",
                    "png": false
                  }
                },
                "example4": {
                  "summary": "Hex-bin density of the same offices",
                  "value": {
                    "data": "office,lat,lon,staff\nTokyo,35.68,139.69,42\nDelhi,28.61,77.21,18\nShanghai,31.23,121.47,25\nSão Paulo,-23.55,-46.63,12\nMexico City,19.43,-99.13,9\nCairo,30.04,31.24,6\nMumbai,19.08,72.88,21\nNairobi,-1.29,36.82,7\nNew York,40.71,-74.01,55\nLagos,6.52,3.38,8\nParis,48.86,2.35,31\nLondon,51.51,-0.13,47\nBerlin,52.52,13.40,26\nToronto,43.65,-79.38,14\nSydney,-33.87,151.21,11",
                    "mode": "hexbin",
                    "hexRadius": 20,
                    "zoom": "world",
                    "png": false
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Calculation result envelope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GeoDataVisualizerResult"
                }
              }
            }
          },
          "400": {
            "description": "Malformed JSON body.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "422": {
            "description": "Invalid input (see errors[]).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded (see Retry-After).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/tool": {
      "get": {
        "operationId": "getToolDefinition",
        "summary": "Inputs, output schema and examples for this tool",
        "responses": {
          "200": {
            "description": "Tool definition.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "Problem": {
        "type": "object",
        "description": "RFC 9457 problem details. 422 responses include per-field `errors`.",
        "required": [
          "type",
          "title",
          "status",
          "detail"
        ],
        "properties": {
          "type": {
            "type": "string"
          },
          "title": {
            "type": "string"
          },
          "status": {
            "type": "integer"
          },
          "detail": {
            "type": "string"
          },
          "code": {
            "type": "string"
          },
          "errors": {
            "type": "array",
            "items": {
              "type": "object",
              "required": [
                "field",
                "message"
              ],
              "properties": {
                "field": {
                  "type": "string"
                },
                "message": {
                  "type": "string"
                }
              }
            }
          }
        }
      },
      "GeoDataVisualizerInput": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "file": {
            "title": "CSV, Excel or GeoJSON file",
            "description": "Max 20 MB. CSV/XLSX: lat/lon columns or a country column (ISO code or English name). GeoJSON: Point, LineString, Polygon (and Multi-) geometries. Upload as {filename, contentType?, contentBase64}. Max 20480 KiB. Accepts .csv,.tsv,.txt,.xlsx,.geojson,.json,text/csv,application/geo+json,application/json,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.",
            "type": "object",
            "additionalProperties": false,
            "required": [
              "filename",
              "contentBase64"
            ],
            "properties": {
              "filename": {
                "type": "string"
              },
              "contentType": {
                "type": "string"
              },
              "contentBase64": {
                "type": "string"
              }
            }
          },
          "data": {
            "title": "Or paste data",
            "description": "CSV with a header row, or GeoJSON.",
            "type": "string",
            "maxLength": 2000000
          },
          "mode": {
            "title": "Map type",
            "type": "string",
            "enum": [
              "auto",
              "points",
              "proportional",
              "hexbin",
              "choropleth"
            ],
            "default": "auto"
          },
          "projection": {
            "title": "Projection",
            "type": "string",
            "enum": [
              "equal-earth",
              "mercator",
              "equirectangular"
            ],
            "default": "equal-earth"
          },
          "latColumn": {
            "title": "Latitude column",
            "description": "Empty: a column named lat/latitude.",
            "type": "string",
            "maxLength": 200
          },
          "lonColumn": {
            "title": "Longitude column",
            "description": "Empty: a column named lon/lng/longitude.",
            "type": "string",
            "maxLength": 200
          },
          "valueColumn": {
            "title": "Value column / property",
            "description": "Numbers for circle size, hex sums or choropleth shading. Empty: the first numeric column (or a \"value\" property in GeoJSON).",
            "type": "string",
            "maxLength": 200
          },
          "labelColumn": {
            "title": "Label column / property",
            "type": "string",
            "maxLength": 200
          },
          "countryColumn": {
            "title": "Country column (choropleth)",
            "description": "ISO 3166 alpha-2/alpha-3 codes or English country names.",
            "type": "string",
            "maxLength": 200
          },
          "zoom": {
            "title": "Extent",
            "type": "string",
            "enum": [
              "auto",
              "world"
            ],
            "default": "auto"
          },
          "hexRadius": {
            "title": "Hexagon size",
            "type": "integer",
            "minimum": 4,
            "maximum": 60,
            "default": 14,
            "x-unit": "px"
          },
          "title": {
            "title": "Map title",
            "type": "string",
            "maxLength": 140
          },
          "png": {
            "title": "Also create a PNG image",
            "type": "boolean",
            "default": true
          }
        },
        "required": []
      },
      "GeoDataVisualizerResult": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "schemaVersion",
          "tool",
          "computedAt",
          "inputs",
          "summary",
          "result",
          "units",
          "assumptions",
          "sources",
          "warnings",
          "presentation",
          "links"
        ],
        "properties": {
          "schemaVersion": {
            "type": "string",
            "const": "1.0"
          },
          "tool": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "id",
              "name",
              "version"
            ],
            "properties": {
              "id": {
                "type": "string"
              },
              "name": {
                "type": "string"
              },
              "version": {
                "type": "string"
              }
            }
          },
          "computedAt": {
            "type": "string",
            "format": "date-time"
          },
          "inputs": {
            "type": "object",
            "description": "Normalised inputs actually used, including applied defaults."
          },
          "summary": {
            "type": "string"
          },
          "result": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "mode",
              "projection",
              "view",
              "points",
              "lines",
              "polygons",
              "countriesMatched",
              "unmatched",
              "invalidRows",
              "hexbins",
              "classes",
              "width",
              "height",
              "svg",
              "png"
            ],
            "properties": {
              "mode": {
                "type": "string"
              },
              "projection": {
                "type": "string"
              },
              "view": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "west",
                  "south",
                  "east",
                  "north"
                ],
                "properties": {
                  "west": {
                    "type": "number"
                  },
                  "south": {
                    "type": "number"
                  },
                  "east": {
                    "type": "number"
                  },
                  "north": {
                    "type": "number"
                  }
                }
              },
              "points": {
                "type": "integer"
              },
              "lines": {
                "type": "integer"
              },
              "polygons": {
                "type": "integer"
              },
              "countriesMatched": {
                "type": "integer"
              },
              "unmatched": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "invalidRows": {
                "type": "integer"
              },
              "hexbins": {
                "type": "integer"
              },
              "classes": {
                "type": "array",
                "items": {
                  "type": "object",
                  "additionalProperties": false,
                  "required": [
                    "from",
                    "to",
                    "color",
                    "countries"
                  ],
                  "properties": {
                    "from": {
                      "type": "number"
                    },
                    "to": {
                      "type": "number"
                    },
                    "color": {
                      "type": "string"
                    },
                    "countries": {
                      "type": "integer"
                    }
                  }
                }
              },
              "width": {
                "type": "integer"
              },
              "height": {
                "type": "integer"
              },
              "svg": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "artifactId",
                  "filename",
                  "mime",
                  "bytes",
                  "sha256",
                  "path"
                ],
                "properties": {
                  "artifactId": {
                    "type": "string"
                  },
                  "filename": {
                    "type": "string"
                  },
                  "mime": {
                    "type": "string"
                  },
                  "bytes": {
                    "type": "integer"
                  },
                  "sha256": {
                    "type": "string"
                  },
                  "path": {
                    "type": "string",
                    "description": "Download path on the same site (valid for about 2 hours)."
                  }
                }
              },
              "png": {
                "anyOf": [
                  {
                    "type": "object",
                    "additionalProperties": false,
                    "required": [
                      "artifactId",
                      "filename",
                      "mime",
                      "bytes",
                      "sha256",
                      "path"
                    ],
                    "properties": {
                      "artifactId": {
                        "type": "string"
                      },
                      "filename": {
                        "type": "string"
                      },
                      "mime": {
                        "type": "string"
                      },
                      "bytes": {
                        "type": "integer"
                      },
                      "sha256": {
                        "type": "string"
                      },
                      "path": {
                        "type": "string",
                        "description": "Download path on the same site (valid for about 2 hours)."
                      }
                    }
                  },
                  {
                    "type": "null"
                  }
                ]
              }
            }
          },
          "units": {
            "type": "object",
            "additionalProperties": {
              "type": "string"
            }
          },
          "assumptions": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "sources": {
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": false,
              "required": [
                "title"
              ],
              "properties": {
                "title": {
                  "type": "string"
                },
                "url": {
                  "type": "string"
                },
                "publisher": {
                  "type": "string"
                },
                "retrievedAt": {
                  "type": "string"
                },
                "note": {
                  "type": "string"
                }
              }
            }
          },
          "warnings": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "presentation": {
            "type": "array",
            "items": {
              "type": "object"
            },
            "description": "Display blocks used by the human page (same data)."
          },
          "links": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "human",
              "api",
              "openapi",
              "methodology"
            ],
            "properties": {
              "human": {
                "type": "string",
                "format": "uri"
              },
              "api": {
                "type": "string",
                "format": "uri"
              },
              "openapi": {
                "type": "string",
                "format": "uri"
              },
              "methodology": {
                "type": "string",
                "format": "uri"
              }
            }
          }
        }
      }
    }
  }
}