Validate GeoJSON against RFC 7946 and get back a structured list of problems, not a bare b
Validate GeoJSON against RFC 7946 and get back a structured list of problems, not a bare boolean. Checks structure, coordinate range, ring closure, ring winding order, consecutive duplicate vertices, self-intersections, and hole nesting. Every issue carries the feature, geometry, ring and position index it sits on, so a 500-feature collection is actionable rather than merely condemned. Reach for it before paying for an operation on data you did not author, and to find out why /v1/geometry, /v1/h3/polyfill or /v1/pip refused a document: those endpoints reject unclosed rings and out-of-range coordinates rather than guessing. Errors make a document invalid; warnings -- duplicate vertices, the crs member RFC 7946 removed -- do not, and are reported separately. One price per call whatever the document: a single Point costs exactly what a 1 MiB FeatureCollection costs, so send the whole collection rather than a document at a time. That is measured rather than assumed -- a Point is about 0.0015 ms of compute on this runtime and a 1 MiB collection about 10 ms, a spread far below what it costs to settle one payment -- which is why there is no size tier here to choose between and no bulk sibling to look for. Nothing is modified here: POST /v1/geojson/repair is the endpoint that rewrites. Limits: 1 MiB request body, and a self-intersection budget of 2000000 segment-pair comparisons per request, enough for any ring under about 1400 vertices. Rings past the budget are listed in checksSkipped with the reason, never silently passed as clean.
Provider
api.geoprimitives.dev · discovered, not yet claimed by its owner
Payment (x402 accepts[])
[
{
"scheme": "exact",
"network": "eip155:8453",
"payTo": "0x76A51b5Dd3729950B3b60c17f19252d221968FCe",
"asset": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
"amount": "5000",
"maxTimeoutSeconds": 300
}
]Output schema
{
"bazaar": {
"info": {
"input": {
"body": {
"coordinates": [
[
[
0,
0
],
[
0,
1
],
[
0,
1
],
[
1,
1
],
[
1,
0
],
[
0,
0
]
]
],
"type": "Polygon"
},
"bodyType": "json",
"method": "POST",
"type": "http"
},
"output": {
"example": {
"checksSkipped": [],
"errorCount": 1,
"errors": [
{
"code": "ring_winding",
"message": "Exterior ring is clockwise. RFC 7946 requires exterior rings to be counterclockwise.",
"path": "$.coordinates[0]",
"ringIndex": 0,
"severity": "error"
},
{
"code": "duplicate_vertex",
"message": "Position 2 repeats position 1.",
"path": "$.coordinates[0][2]",
"positionIndex": 2,
"ringIndex": 0,
"severity": "warning"
}
],
"valid": false,
"warningCount": 1
},
"type": "json"
}
},
"schema": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"properties": {
"input": {
"additionalProperties": false,
"properties": {
"body": {
"additionalProperties": true,
"properties": {
"coordinates": {
"description": "Present on a bare Geometry other than GeometryCollection.",
"type": "array"
},
"features": {
"description": "Present when type is FeatureCollection.",
"items": {
"type": "object"
},
"type": "array"
},
"geometries": {
"description": "Present when type is GeometryCollection.",
"items": {
"type": "object"
},
"type": "array"
},
"geometry": {
"description": "Present when type is Feature. May be null.",
"type": "object"
},
"type": {
"description": "GeoJSON type. Post the document itself: a Feature, a FeatureCollection, or a bare Geometry.",
"enum": [
"FeatureCollection",
"Feature",
"Point",
"MultiPoint",
"LineString",
"MultiLineString",
"Polygon",
"MultiPolygon",
"GeometryCollection"
],
"type": "string"
}
},
"required": [
"type"
],
"type": "object"
},
"bodyType": {
"enum": [
"json",
"form-data",
"text"
],
"type": "string"
},
"method": {
"enum": [
"POST"
],
"type": "string"
},
"type": {
"const": "http",
"type": "string"
}
},
"required": [
"type",
"method",
"bodyType",
"body"
],
"type": "object"
},
"output": {
"properties": {
"example": {
"type": "object"
},
"type": {
"type": "string"
}
},
"required": [
"type"
],
"type": "object"
}
},
"required": [
"input"
],
"type": "object"
}
}
}Use it
curl
curl "https://api.geoprimitives.dev/v1/geojson/validate" # -> 402 Payment Required, accepts[] lists how to pay # retry with a PAYMENT-SIGNATURE (or PAYMENT header) once paid
JavaScript
const res = await fetch("https://api.geoprimitives.dev/v1/geojson/validate");
if (res.status === 402) {
const { accepts } = await res.json();
// pay one of accepts[] via an x402 client, then retry with the payment header
}Python
import httpx
res = httpx.get("https://api.geoprimitives.dev/v1/geojson/validate")
if res.status_code == 402:
accepts = res.json()["accepts"]
# pay one of accepts[] via an x402 client, then retry with the payment headerMachine-readable
Everything on this page is also available as clean JSON at /resources/6764.json, and this resource appears in /discovery/resources and /discovery/search.