{"openapi":"3.1.0","info":{"title":"Source Maintainability Index API","version":"1.0.0","description":"Score caller-supplied JavaScript, TypeScript, Python, or Go, or a caller-supplied AST, for cyclomatic complexity, cognitive load, nesting depth, and structural duplication. The snippet is parsed in memory and is not executed or stored. Paid with x402 exact USDC on Base. No account is required.","contact":{"email":"support@brainiac.software"},"x-guidance":"BRAINIAC.software is a pay-per-call API for software agents. No account or API key is required.\nPayment uses the x402 protocol with exact USDC on Base (chain id 8453). Each POST operation has a fixed USD price.\nHow to call an operation:\n1. POST JSON matching the requestBody. Invalid input returns 400 with no payment challenge.\n2. A valid unpaid call returns 402 with the exact amount and payTo.\n3. Pay and retry with payment-signature. Payment settles only if the operation returns 2xx. A 4xx/5xx is not charged.\nInclude an Idempotency-Key header of 64 hex characters from 32 random bytes. Reuse that key only for retries of the same operation and request body.\nAll outputs are compliance prechecks, drafts, or data lookups for human review. They are not official determinations, legal advice, identity confirmation, or certified filings. Verify time-sensitive or official data with the cited source before acting."},"servers":[{"url":"https://www.brainiac.software"}],"paths":{"/api/v1/code/maintainability-index":{"post":{"operationId":"index_source_maintainability","summary":"Index source maintainability","description":"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.","tags":["code"],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$schema":"https://json-schema.org/draft/2020-12/schema","type":"object","properties":{"language":{"type":"string","enum":["javascript","typescript","python","go"]},"source":{"type":"string","minLength":1,"maxLength":100000},"ast":{"$ref":"#/$defs/__schema0"}},"additionalProperties":false,"$defs":{"__schema0":{"type":"object","properties":{"type":{"type":"string","pattern":"^[a-z][a-z0-9_-]{0,39}$"},"name":{"type":"string","minLength":1,"maxLength":80},"children":{"maxItems":200,"type":"array","items":{"$ref":"#/$defs/__schema0"}}},"required":["type"],"additionalProperties":false}}},"example":{"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"}}}},"parameters":[{"name":"Idempotency-Key","in":"header","required":true,"description":"Fresh random 32-byte value encoded as 64 hexadecimal characters. Reuse unchanged only for retries of the same operation and request.","schema":{"type":"string","pattern":"^[0-9a-fA-F]{64}$"}}],"responses":{"200":{"description":"Illustrative endpoint-specific JSON response shape. Conditional fields depend on the result and data-source availability.","content":{"application/json":{"schema":{"type":"object","properties":{"maintainability_score":{"type":"number"},"cognitive_load_index":{"type":"number"},"technical_debt_estimate_hours":{"type":"number"},"audit_receipt":{"type":"string"}},"additionalProperties":true},"example":{"maintainability_score":40,"cognitive_load_index":38,"technical_debt_estimate_hours":0.75,"audit_receipt":"sha256:cf03e0c1a32b0737eb97627b5b20a8417532be3c944cd89c9200400c13870f09"}}}},"400":{"description":"Invalid JSON or request schema."},"402":{"description":"Payment required. The JSON body is the x402 PaymentRequired object: x402Version, resource with the operation description, accepts with the price and network, and extensions.bazaar with the input schema, input example, output schema, and output example."},"409":{"description":"Idempotency conflict, in-progress payment, or expired result cache. Reusing the key cannot trigger a second charge."},"413":{"description":"Request body exceeds the 24 MB limit."},"500":{"description":"Operation failed before settlement, so no payment is taken. Reuse the same idempotency key to retrieve the stored error without paying again."},"503":{"description":"Payment or retry-safe result storage is unavailable; the operation is not run."}},"x-payment-info":{"price":{"mode":"fixed","currency":"USD","amount":"0.04"},"protocols":[{"x402":{"facilitator":"https://api.cdp.coinbase.com/platform/v2/x402"}}],"facilitator":"https://api.cdp.coinbase.com/platform/v2/x402"}}}},"components":{"schemas":{"ApiError":{"type":"object","required":["error"],"properties":{"error":{"type":"object","required":["code","message"],"properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{}}}}}}}}