> ## Documentation Index
> Fetch the complete documentation index at: https://bazable.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# bazable extract

> Scan code and extract API endpoints

Scans your codebase for API calls and adds any undocumented endpoints to the contract.

## Usage

```bash theme={null}
bazable extract [options]
```

## Options

<ParamField query="-r, --payloads" type="boolean">
  Also infer request payload schemas.
</ParamField>

<ParamField query="-s, --preset" type="string">
  Use a pre-configured extraction pattern. One of `py`, `php`, `go`, `rb`, `js`, `ax`.
</ParamField>

<ParamField query="--pattern" type="regex">
  Custom regex for URL extraction.
</ParamField>

<ParamField query="--ext" type="string[]">
  File extensions to scan (for example, `.py .rb`).
</ParamField>

<ParamField query="--ignore" type="string[]">
  Glob patterns to ignore (for example, `venv dist`).
</ParamField>

<ParamField query="--wrapper" type="string[]">
  Custom API wrapper function names.
</ParamField>

## Examples

<CodeGroup>
  ```bash Standard theme={null}
  bazable extract -r
  ```

  ```bash Python theme={null}
  bazable extract -s py
  ```

  ```bash Custom regex theme={null}
  bazable extract --pattern 'requests\.get\("([^"]+)"' --ext .py
  ```
</CodeGroup>

## Provenance and inference metadata

Every extraction records **provenance** (the file, line, and column of each call site) and **field-level metadata** (inferred vs confirmed, source value, and confidence) on the endpoint entry:

```json bazable.config.json theme={null}
{
  "endpoints": {
    "POST https://api.example.com/v1/users": {
      "request": { "email": "string", "age": "number" },
      "request_meta": {
        "email": { "inferred": true, "confidence": "high", "source_value": "user@example.com" },
        "age":   { "inferred": true, "confidence": "high", "source_value": 30 }
      },
      "provenance": [
        { "file": "src/pages/signup.tsx", "line": 42, "column": 18 }
      ]
    }
  }
}
```

Use [`bazable review`](/commands/review) to render this as a human-readable audit report with flags for fields that need confirmation.

### Accuracy notes

* **HTML script blocks:** line numbers in `provenance` are computed against the whole HTML file, not the inner `<script>` block, so they point straight to the call site in your editor.
* **Cross-block variables:** payloads declared as a variable in one `<script>` block and used in another are resolved. Bazable collects variable definitions across all blocks in a file before matching them to API calls.
* **New endpoints** are seeded with `schema_status: "unverified"` so they show up in [`bazable inspect`](/commands/inspect) until you confirm the schema.

<Tip>
  Run [`bazable inspect`](/commands/inspect) after extraction to validate that your code still matches the contract, and [`bazable review`](/commands/review) to audit which inferred fields are low confidence.
</Tip>


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.