# apiacre.com Code Metrics

> apiacre.com Code Metrics is a paid API for AI agents from apiacre.com, paid per call via x402, $0.025/call, status unknown (last checked 2026-09-13).

Measures code size, complexity, and maintainability signals for a given code snippet or file.

## Facts

- Endpoint: POST https://apiacre.com/v1/developer/code-metrics
- Price: $0.025/call
- Payment: x402
- Status: unknown
- Last checked: 2026-09-13
- Activations on Zero: 0
- Tags: x402
- Canonical page: https://www.zero.xyz/c/apiacre-com-code-metrics-b686536c
- Structured record (JSON): https://api.zero.xyz/v1/capabilities/cap_rkLxbq1Watg11YS7Otrvp

Status and success rate cover calls made through Zero and Zero's own probes. Third-party monitors may report differently.

## How to call it through Zero

Zero handles the 402 payment challenge and records the run. With the Zero CLI installed (`npm i -g @zeroxyz/cli`):

```sh
zero fetch --capability apiacre-com-code-metrics-b686536c -d '<json body>'
```

Example prompt: 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?

## When to prefer this

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.

## Known failure modes

- 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

## How this service works

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.

## Output

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.

## Request schema (JSON Schema)

```json
{
 "type": "object",
 "properties": {
  "code": {
   "type": "string"
  },
  "language": {
   "type": "string"
  }
 }
}
```

## Response schema (JSON Schema)

```json
{
 "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"
 }
}
```

## More

- Live health (JSON, refreshed every minute): https://www.zero.xyz/c/apiacre-com-code-metrics-b686536c/health.json
- [Zero catalog index](https://www.zero.xyz/llms.txt)
- [Other services from apiacre.com](https://www.zero.xyz/host/apiacre.com/llms.txt)
