80trust / 100

Data Schema Validate

by API Acre in Onchain & crypto

x402 APIPassing, checked 14 min ago

Validate JSON data against a bounded JSON Schema Draft 2020-12 contract for nested objects, arrays, required properties, types, enums, formats, lengths, patterns, and numeric bounds; return deterministic instance and schema JSON Pointers, explicit error truncation, input hashes, and no remote reference resolution.

POST https://apiacre.com/v1/data/schema-validate

Last 30 days

All checks passedSome failedAll failedNot checked
Uptime
100%
Response time
83 ms typical, 83 ms slowest 5%
Last check
14 min ago
Next check
in 13 min

How to call it

# See the payment challenge (nothing is charged)
curl -i -X POST "https://apiacre.com/v1/data/schema-validate" \
  -H "content-type: application/json" \
  -d '{"check_formats":true,"instance":{"name":"Ada","score":"98"},"max_errors":25,"schema":{"$schema":"https://json-schema.org/draft/2020-12/schema","additionalProperties":false,"properties":{"name":{"minLength":1,"type":"string"},"score":{"minimum":0,"type":"integer"}},"required":["name","score"],"type":"object"}}'
import { wrapFetchWithPayment } from "@x402/fetch";
import { x402Client } from "@x402/core/client";
import { ExactEvmScheme } from "@x402/evm/exact/client";
import { privateKeyToAccount } from "viem/accounts";

const client = new x402Client().register(
  "eip155:8453",
  new ExactEvmScheme(privateKeyToAccount(process.env.AGENT_KEY)),
);
const pay = wrapFetchWithPayment(fetch, client);

// Not sure it's safe to pay? Preflight it first for $0.005:
// GET https://toolvet.app/api/v1/check?url=https%3A%2F%2Fapiacre.com%2Fv1%2Fdata%2Fschema-validate
const res = await pay("https://apiacre.com/v1/data/schema-validate", {
  method: "POST",
  headers: { "content-type": "application/json" },
  body: JSON.stringify({"check_formats":true,"instance":{"name":"Ada","score":"98"},"max_errors":25,"schema":{"$schema":"https://json-schema.org/draft/2020-12/schema","additionalProperties":false,"properties":{"name":{"minLength":1,"type":"string"},"score":{"minimum":0,"type":"integer"}},"required":["name","score"],"type":"object"}}),
});
console.log(await res.json());

Example input

{
  "check_formats": true,
  "instance": {
    "name": "Ada",
    "score": "98"
  },
  "max_errors": 25,
  "schema": {
    "$schema": "https://json-schema.org/draft/2020-12/schema",
    "additionalProperties": false,
    "properties": {
      "name": {
        "minLength": 1,
        "type": "string"
      },
      "score": {
        "minimum": 0,
        "type": "integer"
      }
    },
    "required": [
      "name",
      "score"
    ],
    "type": "object"
  }
}

Example output

{
  "data": {
    "errorCount": 1,
    "errorCountExact": true,
    "errors": [
      {
        "instancePath": "/score",
        "keyword": "type",
        "kind": "instance",
        "message": "'98' is not of type 'integer'",
        "schemaPath": "/properties/score/type"
      }
    ],
    "errorsReturned": 1,
    "errorsTruncated": false,
    "instance": {
      "sha256": "43d117eb76b608a0d05820c70320889a6577ff85446e00412b6e6487c1559149",
      "utf8Bytes": 27
    },
    "instanceValid": false,
    "schema": {
      "declaredDialect": "https://json-schema.org/draft/2020-12/schema",
      "dialect": "https://json-schema.org/draft/2020-12/schema",
      "remoteReferencesAllowed": false,
      "sha256": "9565a3dfc9aaadfaf2b3163f433b954d7d91246b6c225c11a8c16fe42ae841e4",
      "utf8Bytes": 224
    },
    "schemaValid": true,
    "valid": false,
    "validation": {
      "draft": "2020-12",
      "engine": "python-jsonschema",
      "engineVersion": "4.26.0",
      "formatChecking": true,
      "maxErrors": 25
    }
  },
  "meta": {
    "cached": false,
    "duration_ms": 42,
    "next_actions": [
      {
        "method": "POST",
        "path": "/v1/data/schema",
        "reason": "Infer the rejected instance's observed Draft 2020-12 shape for comparison wit...",
        "service": "data.schema",
        "title": "JSON Schema generator"
      }
    ],
    "sources": [],
    "warnings": []
  },
  "request_id": "018f1f54-7f38-7ba2-8dc3-5f90272d9f1a",
  "service": "data.schema-validate",
  "version": "1"
}

Security scan

  • No findings. We scan names, descriptions and tool definitions for hidden instructions and other prompt-injection patterns.

Recent checks

WhenResultHTTPTimePrice
14 min agoPassed40283 ms$0.01
5 h agoPassed402162 ms$0.01