Index source maintainability API

Build a structural AST from a caller-supplied JavaScript, TypeScript, Python, or Go snippet, or from a caller-supplied AST, and score cyclomatic complexity, cognitive load, nesting depth, and duplicated function structure. The snippet is not executed or stored.

The Index source maintainability operation is part of the Source Maintainability Index API on BRAINIAC.software. Build a structural AST from a caller-supplied JavaScript, TypeScript, Python, or Go snippet, or from a caller-supplied AST, and score cyclomatic complexity, cognitive load, nesting depth, and duplicated function structure. The snippet is not executed or stored. It is exposed as POST /api/v1/code/maintainability-index and priced at $0.04 USDC on Base. Payment uses the x402 exact scheme: an unpaid call returns HTTP 402 with payment requirements; after paying the exact USDC amount, retry the same request with a payment-signature header and Idempotency-Key. No account and no API key are required. Data sources for this product: Caller-supplied source text or AST processed locally Limitations: The parser builds a structural AST for these metrics. It is not a compiler and it does not run the code. JavaScript, TypeScript, and Go are read from braces and keywords. Python is read from indentation. Strings, comments, and the insides of template literals are not scored as logic. A branch without braces is scored from its condition. The following statement is not treated as nested. Duplication compares the structure of functions. It is not a line-by-line clone detector. The hour figure is calculated from complexity, depth, and duplication. It is not a delivery quote. Outputs are compliance prechecks, drafts, or data lookups for human review. They are not official determinations, legal advice, identity confirmation, or certified filings. Related operations in this group include the other resources on the product page. Open the group documentation for the full request schema, field notes, and response examples before integrating.

POST$0.04 USDC
/api/v1/code/maintainability-index

Example request

curl -i -X POST "https://www.brainiac.software/api/v1/code/maintainability-index" \
  -H 'content-type: application/json' \
  -H 'Idempotency-Key: <fresh-64-character-random-hex-key>' \
  --data-binary @- <<'JSON'
{
  "language": "javascript",
  "source": "function price(order) {\n  if (order.rush && order.total > 100) {\n    if (order.member) {\n      return order.total * 0.9\n    } else {\n      return order.total * 0.95\n    }\n  }\n  if (order.rush) {\n    return order.total * 1.1\n  }\n  return order.total\n}\n\nfunction priceCopy(order) {\n  if (order.rush && order.total > 100) {\n    if (order.member) {\n      return order.total * 0.9\n    } else {\n      return order.total * 0.95\n    }\n  }\n  if (order.rush) {\n    return order.total * 1.1\n  }\n  return order.total\n}\n"
}
JSON

An unpaid probe returns HTTP 402 with x402 payment requirements. After paying the exact USDC amount on Base, retry the identical request with a payment-signature header.

FAQ

  • Do I need an API key? No. Pay the listed USDC amount with x402.
  • What network? Base (eip155:8453), USDC.
  • Is this an official determination? No. Results are for human review against the cited sources.

    Related APIs

    Source Maintainability Index APIFull docsHow it works