Stainless Documentation

website·Indexed 38 days ago

https://www.stainless.com/docs

A platform for generating production-ready client SDKs and command line interfaces from OpenAPI specifications. Stainless provides tools for SDK design, a dedicated Docs Platform for authoritative API reference and documentation, and integrations with third-party frameworks like Bump.sh, GitBook, Mintlify, and ReadMe.

Tokens
120.7K
Snippets
574
Records
896
Agent score
70%

What's inside Stainless

  1. Overview of Stainless OpenAPI transforms

    Transforms allow you to modify your OpenAPI specification during SDK generation. They are defined in stainless.yaml under openapi.transforms and are applied in order. Stainless uses JSONPath Plus for targeting nodes within the spec. All values are deep-cloned to prevent shared references, and transforms fail loudly if paths do not exist or operations conflict.
    openapi:
      transforms:
        - command: update    # Command name
          reason: "Why this transform exists"
          args:
            target: "$.path.to.field"
            value: "new value"
  2. Overview of the Stainless Docs Platform

    The Stainless Docs Platform is a documentation framework that automates the generation of API and SDK reference pages based on an OpenAPI specification and Stainless configuration. It uses a docs-as-code workflow, generating a standalone Astro project that can be hosted by Stainless (via Cloudflare) or on any static hosting provider. The platform supports language-specific SDK documentation, interactive HTTP references with curl snippets, and long-form content authored in MDX or Markdoc.
  3. Overview of Stainless Docs Platform

    The Stainless Docs Platform is the recommended solution for API and SDK documentation. It provides automatic API/SDK reference generation, language-specific documentation with accurate types, and a developer-friendly workflow using the Astro framework. It supports both Stainless-managed hosting and self-hosting on static site hosts.
  4. Overview of Stainless API generation tools

    Stainless is a platform that uses an OpenAPI specification as a foundation to automatically generate a suite of developer tools and services, including idiomatic SDKs, API reference documentation, production-ready command line interfaces (CLIs), Model Context Protocol (MCP) servers, and Terraform providers.
  5. Overview of Stainless preview builds

    Preview builds automatically generate SDKs and codegen targets based on OpenAPI spec changes in pull or merge requests. This allows developers to validate changes before merging, with build status and links posted directly as comments on the pull request. Once merged, the final release build is based on the most recent preview build.
  6. Overview of Stainless Studio capabilities

    Stainless Studio (or "Studio") is the web-based user interface used to manage the lifecycle of a Stainless project. It provides tools to upload OpenAPI specifications, modify Stainless configuration files, resolve diagnostics, monitor build progress, and preview the generated API reference in real-time.
  7. Overview of Stainless SDK pagination helpers and auto-iterators

    Configuring pagination in Stainless generates two primary tools for SDK users: a helper to manually fetch the next page and an auto-iterator. The auto-iterator allows developers to loop through paginated API results using a standard loop (e.g., for await...of), automatically fetching subsequent pages as the loop progresses.
    const iter: OffsetPage<Account> = await client.accounts.list()
    
    for await (const account of iter) {
      if (account.name === 'Michael') {
        console.log(account.id)
      }
    }
  8. Overview of the Stainless CLI

    The Stainless CLI (stl) is a command-line tool used to create, configure, manage, and debug projects, OpenAPI specifications, and Stainless configurations. While currently experimental, it provides a direct interface for interacting with the Stainless platform.
  9. Overview of Stainless development tools

    Stainless provides a suite of tools to create, configure, manage, and debug projects, OpenAPI specifications, and Stainless configurations:

    • Stainless Studio: A web-based UI for project management and debugging.
    • Stainless CLI (stl): A command-line interface providing functionality similar to the Studio for terminal-based workflows.
    • Stainless Language Server: Provides real-time diagnostics, intelligent completions, and navigation for Stainless config and OpenAPI specs within supported editors.
    • GitHub member sync: Synchronizes GitHub members with Stainless in real-time.
  10. Overview of Stainless SQL generator

    The Stainless SQL generator (experimental) creates PostgreSQL extensions that wrap a REST API as typed SQL functions. This allows developers to query an API directly from PostgreSQL using standard SQL. The generator maps OpenAPI specifications to PostgreSQL as follows:

    • API resources $\rightarrow$ PostgreSQL schemas
    • API objects $\rightarrow$ composite types
    • API operations $\rightarrow$ SQL functions (retrieve, list, create, update, delete)
    • Pagination $\rightarrow$ handled via set-returning functions.
    -- Load the PL/Python dependency (required)
    CREATE EXTENSION IF NOT EXISTS plpython3u;
    
    -- Load the extension
    CREATE EXTENSION my_api;
    
    -- Configure your API key (requires a new session to take effect)
    ALTER DATABASE mydb SET my_api.api_key = 'sk-my-api-key';
    
    -- List users
    SELECT * FROM users.list();
    
    -- Retrieve a single user
    SELECT * FROM users.retrieve('user_123');
    
    -- Create a new user
    SELECT * FROM users.create(name := 'Alice', email := 'alice@example.com');
  11. Generate a documentation site with Stainless

    Stainless provides a complete documentation platform built on Astro that generates API references and SDK references. Unlike basic API reference generators, Stainless supports a 'docs-as-code' workflow where the documentation is managed via a repository, allowing for custom prose content, custom CSS, and the integration of React, Vue, or Svelte components. The resulting site can be self-hosted on any static host such as Vercel, Netlify, or Cloudflare Pages, providing full control over branding and navigation.
  12. Use OpenAPI specifications with Stainless

    Stainless supports OpenAPI 3.X formats, including versions 3.0 and 3.1. The configuration process uses specific OpenAPI fields to generate initial guesses for the Stainless configuration, though these are not read again after the initial setup.