Skip to content

Guides

Turn traffic into API docs

Capture an API's traffic, build an endpoint catalog in Insights, export OpenAPI, import it into the API client, and generate HTML documentation.

An undocumented API is easier to describe once you’ve watched it run. This guide captures an API’s traffic, lets Insights group it into an endpoint catalog, exports an OpenAPI document, imports it into the API client as a collection and editable spec, and generates HTML documentation from it.

Cloak Proxy capturing the API, with HTTPS decrypted The catalog and OpenAPI export read decrypted requests
A thorough session covering the endpoints you want documented Each endpoint needs at least one captured call
  1. Turn on capture and decrypt the API’s host (see SSL Proxying).

  2. Exercise each endpoint at least once, with realistic parameters. Hit the same endpoint with different IDs so Cloak Proxy can tell the variable part of the path from the fixed part.

Open Insights (<kbd>⌥</kbd> <kbd>⌘</kbd> <kbd>I</kbd>) and select the Endpoints tab. Cloak Proxy groups the traffic into endpoint templates, so /users/1 and /users/2 become one /users/{id}.

The API catalog: endpoints with calls, error rate, latency and size.

  1. Filter endpoints
  2. Export OpenAPI
  3. Templated paths like /v1/reviews/{id}
  4. Calls, errors, p50/p95, avg size
The Insights Endpoints tab listing method, host, path template, calls, errors, p50, p95 and average size, with an Export OpenAPI button
  1. Read the table: method, host, path template, call count, error rate, p50/p95 and average response size. IDs, UUIDs, hashes and dates in paths are collapsed into {id}, {uuid}, and so on.

  2. Select an endpoint to see its status codes, query parameters, content types and callers — the raw material for documentation.

  1. Click Export OpenAPI… on the Endpoints tab to export every catalogued endpoint, or export a selection of requests with Export Request → OpenAPI (YAML)… from the traffic list’s right-click menu.

  2. The export templates paths, infers request and response schemas from the captured JSON, lists query and path parameters with examples, and records the servers it saw. Save the .yaml file.

  1. In the API Client (<kbd>⇧</kbd> <kbd>⌘</kbd> <kbd>O</kbd>), click Import, choose Choose Files…, and pick the exported YAML (or paste it).

    Import the OpenAPI file as a collection and a linked spec.

    1. Choose Files, or paste below
    2. Import
    The Import sheet listing Postman, OpenAPI/Swagger, HAR, Insomnia and cURL as supported inputs

    Importing an OpenAPI document creates a collection (requests with example bodies) and adds the document to Specs.

  2. Open the Specs view to edit the document. The linter flags missing descriptions, security and schemas, so you can see what to fill in.

    The Specs editor with live linting and Sync Collection.

    1. Specs section
    2. Sync Collection keeps the collection in step
    3. Preview Docs
    4. Lint problems to fix
    The Specs view with an OpenAPI editor, a Sync Collection button, and a Problems list of lint findings
  3. Add summaries, descriptions, security and missing schemas in the editor. Click Sync Collection to update the linked collection from the spec (your tests, scripts, auth and examples are kept). See Specs.

  1. From the Specs editor, click Preview Docs to render the documentation in your browser.

  2. To save a shareable file, open the collection and choose Export API Documentation (HTML)… from its More menu, or generate it from the command line:

    Terminal
    cloakctl docs Petstore --out docs.html

    The HTML is a single self-contained file with code samples and the collection’s branding.

  1. Turn off capture and SSL Proxying for the API if you only needed the documentation pass.

  2. Commit the collection and spec to Git if you want to keep them (the workspace is a folder of JSON files). See Workspace and Git.