{"uid":"cap_rkLxbq1Watg11YS7Otrvp","slug":"apiacre-com-code-metrics-b686536c","name":"apiacre.com Code Metrics","description":"Measure caller-supplied source code with Python AST analysis or a deterministic lexical fallback, including per-function complexity, a SHA-256 fingerprint, density ratios, syntax status, and actionable maintainability signals without retaining or forwarding the code.","url":"https://apiacre.com/v1/developer/code-metrics","method":"POST","headers":{},"bodySchema":{"type":"object","properties":{"code":{"type":"string"},"language":{"type":"string"}}},"responseSchema":{"type":"json","example":{"data":{"lines":{"code":2,"blank":0,"total":2,"comments":0},"source":{"sha256":"d588756864c1c6b9016a1829ea9283915950ef23e5b1c04018413ed71...","utf8Bytes":43,"characters":43},"syntax":{"error":null,"valid":true,"engine":"python-ast"},"classes":0,"analysis":{"method":"Python AST with deterministic lexical metrics","version":"apiacre-code-metrics/3","limitations":["AST complexity is a static heuristic, not a runtime or co...","Comment counts include comment-only lines, not inline com..."]},"language":"python","functions":1,"branchPoints":0,"longLineCount":0,"reviewSignals":[],"commentDensity":0,"functionMetrics":[{"kind":"function","line":1,"name":"greet","endLine":2}],"workMarkerCount":0,"blankLineDensity":0,"averageLineLength":21,"maximumLineLength":26,"functionsTruncated":false,"complexityPerFunction":1,"maintainabilitySignal":95,"maximumFunctionComplexity":1,"estimatedCyclomaticComplexity":1},"meta":{"cached":false,"sources":[],"warnings":[],"duration_ms":42,"next_actions":[{"title":"Code change review","method":"POST","reason":"Compare the measured source with a caller-supplied baseli...","service":"developer.code-change-review"}]},"service":"developer.code-metrics","version":"1","request_id":"018f1f54-7f38-7ba2-8dc3-5f90272d9f1a"}},"example":null,"exampleRequest":null,"tags":["x402"],"displayCostAmount":"0.025","displayCostAsset":"USDC","priceDynamic":false,"priceHint":null,"priceStatus":"priced","priceSource":"probe","requiresHandshake":false,"reviewCount":0,"rating":{"score":"0.00","successRate":"0.00","reviews":0,"stars":null,"state":"unrated"},"availabilityStatus":"unknown","priceObserved":null,"sessionDeposit":null,"pricing":{"kind":"static","summary":"$0.025/call","primary":{"kind":"static","protocol":"x402","network":"base","amountUsd":"0.025","per":"call","confidence":"exact"},"accepted":[{"kind":"static","protocol":"x402","network":"base","amountUsd":"0.025","per":"call","confidence":"exact"}]},"paymentMethods":[{"uid":"pm_nXgVs2auyZcnI5zzFRCPP","protocol":"x402","methodType":"crypto","chain":"base","mode":"charge","costAmount":"0.025","costPer":"request","priority":0,"asset":"0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913","unit":"request","depositMicros":null,"planRef":null}],"brandName":null,"brandSlug":null,"brandBaseUrl":null,"brandDocsUrl":null,"whatItDoes":"Measures code size, complexity, and maintainability signals for a given code snippet or file.","exampleAgentPrompt":"Can you analyze this JavaScript function and give me its cyclomatic complexity, lines of code, and maintainability score so I know how risky it is to refactor?","exampleUseCases":[{"title":"Pre-refactor complexity audit","prompt":"I'm about to refactor this Python class — can you run code metrics on it and tell me the cyclomatic complexity and maintainability index so I know where to focus first?"},{"title":"CI gate for complexity threshold","prompt":"Check this new TypeScript module and tell me if any functions exceed a cyclomatic complexity of 10 — I want to fail the build if they do."},{"title":"Code review complexity report","prompt":"We're doing a code review on this Java method. Can you give me the size, complexity, and maintainability signals so we have objective numbers to discuss?"}],"resultDescription":"Returns computed code metrics including lines of code (total, code, comment, blank), cyclomatic complexity, and maintainability index or similar signals indicating how complex and maintainable the submitted code is.","failureModes":["Unsupported programming language returns an error or empty metrics","Malformed or non-parseable code may cause parsing failure","Extremely large code inputs may be rejected or time out","Missing required fields (e.g. no code body provided) returns a validation error"],"whenToPreferThis":"Choose this endpoint when you need objective, quantitative code quality signals (size, complexity, maintainability) for a specific snippet without setting up a local static analysis tool. Ideal for CI pipelines, code review automation, or agent-driven refactoring workflows where a quick per-call metric computation is needed at low cost.","instructions":null,"reviewSummary":null,"reviewSummaryHighlights":null,"reviewSummaryConcerns":null,"reviewSummaryGeneratedAt":null,"activationCount":0,"lastUsedAt":null,"lastSuccessfullyRanAt":null,"lastHealthCheckAt":"2026-09-15T12:58:31.443Z","isFirstParty":false}