### Restish Shell Setup and Completion Examples Source: https://github.com/rest-sh/restish/blob/main/site/content/en/docs/reference/shell-command.md Common examples for setting up the shell and generating completion scripts for different shells. ```bash restish shell setup zsh --dry-run ``` ```bash restish shell setup zsh ``` ```bash restish shell setup zsh --no-completion ``` ```bash restish shell completion zsh ``` ```bash restish shell completion bash ``` ```bash restish shell completion install fish ``` -------------------------------- ### Restish Shell Setup Examples Source: https://github.com/rest-sh/restish/blob/main/site/content/en/docs/reference/shell-command.md Examples for configuring your shell for Restish, including dry-run and skipping completion installation. ```bash restish shell setup zsh ``` ```bash restish shell setup fish --dry-run ``` ```bash restish shell setup bash --no-completion ``` -------------------------------- ### Verify Command Plugin Behavior Source: https://github.com/rest-sh/restish/blob/main/site/content/en/docs/plugins/install-and-use.md Examples of using command plugins. The first shows how to get help for a 'bulk' command plugin, and the second demonstrates serving an example with an 'mcp' plugin. ```bash restish bulk --help restish mcp serve example ``` -------------------------------- ### Run Live Example Smoke Tests Source: https://github.com/rest-sh/restish/blob/main/site/content/en/docs/contributing/docs-maintenance.md Execute example smoke tests in live mode, which connects to a public API and installs plugins. ```bash scripts/check-doc-examples.rb --mode live ``` -------------------------------- ### CI Setup for Docs Site Source: https://github.com/rest-sh/restish/blob/main/CLAUDE.md Install npm dependencies and build the documentation site for CI parity. Includes social image generation. ```bash # Full CI parity for the docs job (npm ci needed once; social-images parses # content front matter and can fail independently of Hugo) npm --prefix site ci npm --prefix site run social-images hugo --source site --quiet --gc --minify --cacheDir /tmp/hugo_cache ``` -------------------------------- ### Install and Use First-Party Plugins Source: https://github.com/rest-sh/restish/blob/main/site/content/en/docs/contributing/release-packaging.md Install a first-party plugin (e.g., 'csv') using the restish plugin command and verify its installation via Homebrew. Also shows how to install directly from a GitHub repository. ```bash restish plugin install rest-sh/restish csv --yes brew install rest-sh/tap/restish-csv restish plugin install restish-csv --yes ``` -------------------------------- ### Examples of Commands Failing Without Setup Source: https://github.com/rest-sh/restish/blob/main/site/content/en/docs/getting-started/shell-setup.md Demonstrates how commands might fail before Restish can parse them if shell setup is not performed, especially with special characters in URLs and filters. ```bash restish 'api.rest.sh/images?format=jpeg&limit=1' restish api.rest.sh/images --rsh-no-paginate -f 'body[0].self' restish post api.rest.sh/post 'tags[]: docs, tags[]: cli' ``` -------------------------------- ### Restish Shell Completion Examples Source: https://github.com/rest-sh/restish/blob/main/site/content/en/docs/reference/shell-command.md Examples for generating and installing shell completion scripts for Restish. ```bash restish shell completion zsh ``` ```bash restish shell completion bash > restish.bash ``` ```bash restish shell completion install zsh ``` -------------------------------- ### Build the Example CLI Source: https://github.com/rest-sh/restish/blob/main/examples/example-cli/README.md Build the example CLI from the repository root using the go build command. ```bash go build -o /tmp/example-cli ./examples/example-cli ``` -------------------------------- ### Configuration and Setup Commands Source: https://github.com/rest-sh/restish/blob/main/site/content/en/docs/reference/commands.md Use config and setup commands to manage local Restish state and shell integration. ```bash restish config show restish config set 'apis.example.profiles.default.headers[]: "X-Debug: true"' restish shell setup zsh --dry-run restish cache info ``` -------------------------------- ### Install Plugin from Local Path Source: https://github.com/rest-sh/restish/blob/main/site/content/en/docs/reference/plugin-command.md Install a plugin by providing its local file path. ```bash restish plugin install ./restish-csv ``` -------------------------------- ### CI Setup for Docs Site Source: https://github.com/rest-sh/restish/blob/main/AGENTS.md Installs npm dependencies and runs social-images for the docs site to ensure CI parity. Requires 'npm ci' to be run once initially. ```bash # Full CI parity for the docs job (npm ci needed once; social-images parses # content front matter and can fail independently of Hugo) npm --prefix site ci npm --prefix site run social-images ``` -------------------------------- ### Connect to Example API Source: https://github.com/rest-sh/restish/blob/main/site/content/en/docs/reference/example-api.md Configure the example API endpoint once to enable short, API-aware commands. This sets up the API host and an API key for authentication. ```bash restish api connect example api.rest.sh 'prompt.api_key: docs-key' restish example --help ``` -------------------------------- ### Install Restish via Go Install Source: https://github.com/rest-sh/restish/blob/main/site/content/en/docs/contributing/release-packaging.md Install the restish binary directly from the source repository using 'go install'. Ensure the installed binary reports the v2 version. ```bash go install github.com/rest-sh/restish/v2/cmd/restish@latest ``` -------------------------------- ### Run Example Smoke Tests Source: https://github.com/rest-sh/restish/blob/main/site/content/en/docs/contributing/docs-maintenance.md Execute example smoke tests to validate documentation examples. The default is local and non-networked. ```bash scripts/check-doc-examples.rb ``` -------------------------------- ### Install Restish using Go Source: https://github.com/rest-sh/restish/blob/main/site/content/en/blog/scripting-rest-apis-without-fragile-curl-loops.md Installs the Restish command-line tool using the Go build tools. Verifies the installation by displaying the help message. ```bash go install github.com/rest-sh/restish/v2/cmd/restish@latest restish --help ``` -------------------------------- ### V2 Shell Setup Command Source: https://github.com/rest-sh/restish/blob/main/docs/design/037-v2-command-surface-review.md Use this command to install shell integrations like the noglob alias and optional completion. The explicit object `shell` clarifies the workflow's purpose. ```text restish shell setup ``` -------------------------------- ### Install Plugin by Name Source: https://github.com/rest-sh/restish/blob/main/site/content/en/docs/reference/plugin-command.md Install a plugin using its registered name. ```bash restish plugin install restish-csv ``` -------------------------------- ### Build and Install a CSV Formatter Plugin Source: https://github.com/rest-sh/restish/blob/main/site/content/en/docs/plugins/quickstart.md Build a plugin from source and install it into Restish. Verify its discovery using `plugin list`. ```bash go build ./cmd/restish-csv restish plugin install ./restish-csv restish plugin list ``` -------------------------------- ### Install a Plugin Source: https://github.com/rest-sh/restish/blob/main/site/content/en/docs/reference/plugin-command.md Installs a plugin from a local path, PATH command, URL, or GitHub release. The `--yes` flag skips interactive confirmation. ```bash restish plugin install ./restish-example ``` ```bash restish plugin install restish-example ``` ```bash restish plugin install rest-sh/restish mcp ``` -------------------------------- ### Example Plugin Manifest Source: https://github.com/rest-sh/restish/blob/main/site/content/en/docs/reference/plugin-manifest.md A basic example of a plugin manifest file, demonstrating the core fields and their typical values. ```json { "name": "csv", "version": "0.1.0", "description": "Render array responses as CSV", "restish_api_version": 2, "hooks": ["formatter"], "formatter_names": ["csv"] } ``` -------------------------------- ### Install Plugin from URL Source: https://github.com/rest-sh/restish/blob/main/site/content/en/docs/plugins/install-and-use.md Installs a plugin directly from a provided URL. This is useful when your team publishes plugin archives to a custom location. ```bash restish plugin install https://downloads.example.com/restish-csv_darwin_arm64.tar.gz ``` -------------------------------- ### Minimal Theme Override Example Source: https://github.com/rest-sh/restish/blob/main/docs/design/009-response-normalization-and-output.md A minimal example showing how to override specific token styles like 'key' and 'status_2xx'. ```json { "key": "#ffffff", "status_2xx": "bold #00ff00" } ``` -------------------------------- ### Homebrew Install Core Source: https://github.com/rest-sh/restish/blob/main/docs/release-packaging.md Installs the primary v2 CLI from Homebrew core. Use this for the latest stable version. ```bash brew install restish ``` -------------------------------- ### Install Dependencies Source: https://github.com/rest-sh/restish/blob/main/site/README.md Installs project dependencies using npm. Run this command once after cloning the repository. ```bash npm ci ``` -------------------------------- ### Preview Shell Setup Changes Source: https://github.com/rest-sh/restish/blob/main/site/content/en/docs/getting-started/shell-setup.md Use the --dry-run flag to preview the changes that the shell setup command will make without actually applying them. ```bash restish shell setup zsh --dry-run ``` -------------------------------- ### Install Restish from Source with Go Source: https://github.com/rest-sh/restish/blob/main/README.md Install the latest v2 release of Restish directly from source using the Go toolchain. This method requires Go to be installed. Use 'restish --help' to see available commands. ```bash go install github.com/rest-sh/restish/v2/cmd/restish@latest ``` ```bash restish --help ``` -------------------------------- ### Verify Restish Installation Source: https://github.com/rest-sh/restish/blob/main/site/content/en/docs/getting-started/install.md Verify the install by checking the version and making a sample request. The request should return an echo-shaped JSON document. ```bash restish --version restish api.rest.sh/ ``` -------------------------------- ### Install Bundled Theme by Name Source: https://github.com/rest-sh/restish/blob/main/docs/design/009-response-normalization-and-output.md Install an official bundled theme by its name. This uses themes embedded within the Restish binary. ```bash restish config theme set one-dark-pro ``` -------------------------------- ### Install Local Plugin Build Source: https://github.com/rest-sh/restish/blob/main/site/content/en/docs/plugins/install-and-use.md Installs a plugin that has been built locally from its source repository. Ensure the plugin binary is executable and compatible with the v2 plugin protocol. ```bash go build ./cmd/restish-csv restish plugin install ./restish-csv ``` -------------------------------- ### Register API with a Short Name Source: https://github.com/rest-sh/restish/blob/main/site/content/en/docs/getting-started/tour.md Connect to an API using its URL and assign a short name for easier access. This example registers 'api.rest.sh' as 'example'. ```bash # Connect to the API and give it a short name `example`. restish api connect example api.rest.sh ``` ```bash # See the generated commands for the API. restish example --help ``` ```bash # See inputs, outputs, schemas, and examples for a generated command. restish example list-images --help ``` -------------------------------- ### Cache Examples Source: https://github.com/rest-sh/restish/blob/main/site/content/en/docs/reference/cache-command.md These examples demonstrate common ways to interact with the HTTP response cache. They include inspecting cache details and clearing all or specific cache entries. ```bash restish cache info ``` ```bash restish cache clear ``` ```bash restish cache clear demo ``` -------------------------------- ### Common Utility Command Examples Source: https://github.com/rest-sh/restish/blob/main/site/content/en/docs/reference/utility-commands.md Demonstrates basic usage of cert, links, and version commands. ```bash restish cert api.rest.sh restish cert api.rest.sh --warn-days 30 restish links api.rest.sh/images next restish version ``` -------------------------------- ### Example Shell Alias Configuration Source: https://github.com/rest-sh/restish/blob/main/docs/design/016-setup-and-completions.md An example of the alias that is appended to the shell rc file when using `restish shell setup` with the `noglob` option. This alias ensures that Restish commands are executed without shell globbing. ```text alias restish="noglob restish" ``` -------------------------------- ### Generate Fish Shell Completion Script Source: https://github.com/rest-sh/restish/blob/main/site/content/en/docs/reference/shell-command.md Generates the autocompletion script for fish and writes it to stdout. This is useful for package managers or manual shell setup. For managed installation, use `restish shell completion install fish`. ```bash restish shell completion fish > restish.fish ``` -------------------------------- ### Configure API Request Retries Source: https://github.com/rest-sh/restish/blob/main/site/content/en/docs/getting-started/tour.md Tune the number of retries for safe transient failures on GET and HEAD requests. This example retries twice. ```bash restish 'api.rest.sh/flaky?failures=1&key=tour' --rsh-retry 2 ``` -------------------------------- ### Use CommandClient Helpers Source: https://github.com/rest-sh/restish/blob/main/docs/plugin-quickstart.md These Go examples show how to use CommandClient helper methods for common host interactions like listing APIs, reading configuration, and prompting the user. Prefer these helpers over manual protocol messages. ```go apis, err := c.ListAPIs() profiles, err := c.ListProfiles("myapi") cfg, err := c.ConfigRead("myapi", "default", "hello-cmd") answer, err := c.Prompt("Label", false) ok, err := c.Confirm("Continue?") err = c.Response(200, nil, map[string]any{"configured": cfg.PluginConfig != nil}) ``` -------------------------------- ### Verify Formatter Plugin Behavior Source: https://github.com/rest-sh/restish/blob/main/site/content/en/docs/plugins/install-and-use.md Example of using a formatter plugin to output API results in CSV format. Ensure the 'csv' plugin is installed. ```bash restish api.rest.sh/images -o csv ``` -------------------------------- ### Connect to an Example API and List Images Source: https://github.com/rest-sh/restish/blob/main/site/content/en/blog/restish-v2-a-cli-for-rest-apis-rebuilt.md Connect Restish to an example API and then use the generated commands to list images, specifying output format and columns. This showcases API integration and command generation. ```bash restish api connect example api.rest.sh restish example --help restish example list-images -o table --rsh-columns name,format,self ``` -------------------------------- ### Make a Generic HTTP Request Source: https://github.com/rest-sh/restish/blob/main/README.md Make a direct HTTP request to a specified API endpoint. No additional setup is required beyond installing the CLI. ```bash restish api.rest.sh/types ``` -------------------------------- ### Install and Set Custom Themes Source: https://github.com/rest-sh/restish/blob/main/site/content/en/docs/getting-started/tour.md Load and apply custom themes from local files, URLs, or repositories. ```bash # Install and set custom themes from a local path, URL, or repo restish config theme set ./theme.json restish config theme set user/themes dark ``` -------------------------------- ### OpenAPI Specification for Petstore API Source: https://github.com/rest-sh/restish/blob/main/docs/design/007-api-command-generation.md An example OpenAPI JSON configuration defining the 'petstore' API with a base URL and a GET operation for retrieving pets. ```jsonc { "apis": { "petstore": { "base_url": "https://api.example.com" } } } ``` -------------------------------- ### Restish CLI Command Example Source: https://github.com/rest-sh/restish/blob/main/docs/design/002-config-and-profiles.md Demonstrates how to use the Restish CLI to make a GET request to a GitHub repository using a specific profile and overriding query parameters. ```bash restish --rsh-profile enterprise get github/repos/octo/example -q per_page=50 ``` -------------------------------- ### Run Development Server Source: https://github.com/rest-sh/restish/blob/main/site/README.md Starts the local development server for the documentation site. This command is used for previewing changes during development. ```bash npm run dev ``` -------------------------------- ### Build and Run Formatter Plugin Source: https://github.com/rest-sh/restish/blob/main/docs/plugin-quickstart.md Instructions for building the formatter plugin and running it with a Restish GET request. This demonstrates how to integrate and test the plugin. ```bash restish get https://httpbin.org/json -o hello ``` -------------------------------- ### RESTish Command for Paginated Get Source: https://github.com/rest-sh/restish/blob/main/docs/design/011-pagination-and-hypermedia.md Example command to fetch paginated items from an API using RESTish. The '-o json' option merges results into a single JSON document. ```bash restish get https://api.example.com/items -o json ``` -------------------------------- ### Example Release Archive Naming Convention Source: https://github.com/rest-sh/restish/blob/main/site/content/en/docs/contributing/release-packaging.md Illustrates the expected naming convention for release archives, including version and target platform. ```text restish-X.Y.Z-darwin-arm64.tar.gz restish-X.Y.Z-linux-amd64.tar.gz restish-X.Y.Z-windows-amd64.zip ``` -------------------------------- ### Use Generated API Commands Source: https://github.com/rest-sh/restish/blob/main/site/content/en/docs/getting-started/connect-to-an-api.md Execute generated commands for an API, which map to API-relative operations without requiring manual URL construction. This example shows listing images and getting a specific image. ```bash restish example list-images restish example get-image jpeg > dragonfly.jpg restish example get-status 404 --rsh-ignore-status-code ``` -------------------------------- ### Connect to an API and View Help Source: https://github.com/rest-sh/restish/blob/main/site/content/en/blog/restish-v2-a-cli-for-rest-apis-rebuilt.md Connect Restish to a local API using its OpenAPI description and then display the help information for the connected API. ```bash restish api connect example api.rest.sh restish example --help ``` -------------------------------- ### List Available Plugins Source: https://github.com/rest-sh/restish/blob/main/site/content/en/docs/plugins/install-and-use.md Run this command to see all installed plugins and their capabilities. This is useful when a required output format or command is missing. ```bash restish plugin list ``` -------------------------------- ### Install Restish with Homebrew Source: https://github.com/rest-sh/restish/blob/main/README.md Install the Restish CLI on macOS using Homebrew. Verify the installation by checking the version. ```bash brew install restish ``` ```bash restish --version ``` -------------------------------- ### Restish Bulk Init Command Help Source: https://github.com/rest-sh/restish/blob/main/site/content/en/docs/reference/bulk-command.md Provides help for initializing a new bulk checkout. It explains how to specify the list endpoint and use URL templates for resource construction. ```text Initialize a bulk checkout from a list endpoint that returns each resource URL and version. Use `-f` to project or filter the list response before URL extraction. Use `--url-template` when the list items contain IDs or fields that need to be turned into resource URLs. Usage: restish bulk init URL [flags] Examples: restish bulk init https://api.rest.sh/books restish bulk init https://api.example.com/users --url-template '/users/{id}' restish bulk status Flags: -f, --filter string Filter/project the list response before extracting url/version -h, --help help for init -j, --jobs int Maximum concurrent resource requests (default 4) --url-template string URL template to build resource links, e.g. /users/{id} ``` -------------------------------- ### Verify Homebrew Install Source: https://github.com/rest-sh/restish/blob/main/docs/release-packaging.md After installing or updating the Homebrew core formula, verify the installed version and test basic functionality. ```bash brew install restish restish --version restish api.rest.sh/ ``` -------------------------------- ### Setup Fish Shell Integration Source: https://github.com/rest-sh/restish/blob/main/docs/design/016-setup-and-completions.md For Fish shell, `shell setup fish` writes the completion script to the user's completions directory, respecting `XDG_CONFIG_HOME` or falling back to `~/.config/fish/completions`. ```bash restish shell setup fish ``` -------------------------------- ### Connect to API and List Plugins Source: https://github.com/rest-sh/restish/blob/main/site/content/en/docs/plugins/mcp.md Connect to a Restish API and list available plugins. Ensure the API is registered and has a usable spec before proceeding. ```bash restish api connect example api.rest.sh 'prompt.api_key: docs-key' restish plugin list ``` -------------------------------- ### Install Restish with Mise Source: https://github.com/rest-sh/restish/blob/main/README.md Install the latest tagged version of Restish using the mise package manager. Verify the installation by checking the version. ```bash mise use -g restish@latest ``` ```bash restish --version ``` -------------------------------- ### Connect to an API Source: https://github.com/rest-sh/restish/blob/main/site/content/en/docs/getting-started/set-up-profiles.md Connect to an API and set initial configuration, like an API key for documentation purposes. ```bash restish api connect example api.rest.sh 'prompt.api_key: docs-key' ``` -------------------------------- ### Homebrew Install v1 Formula Source: https://github.com/rest-sh/restish/blob/main/docs/release-packaging.md Installs the v1 release of restish using the legacy tap. This formula is keg-only to avoid conflicts with the core v2 installation. ```bash brew install rest-sh/tap/restish@1 ``` -------------------------------- ### Error Payload Example Source: https://github.com/rest-sh/restish/blob/main/site/content/en/docs/reference/example-api.md Provides an example of an `application/problem+json` error payload. ```APIDOC ## GET /problem ### Description This endpoint demonstrates `application/problem+json` error payloads. ### Method GET ### Endpoint `/problem` ``` -------------------------------- ### Response Decompression Examples Source: https://github.com/rest-sh/restish/blob/main/site/content/en/docs/reference/example-api.md Examples for response decompression using gzip, deflate, and brotli. ```APIDOC ## GET /gzip ### Description Example of receiving a gzipped response. ### Method GET ### Endpoint `/gzip` ``` ```APIDOC ## GET /deflate ### Description Example of receiving a deflate-compressed response. ### Method GET ### Endpoint `/deflate` ``` ```APIDOC ## GET /brotli ### Description Example of receiving a brotli-compressed response. ### Method GET ### Endpoint `/brotli` ``` -------------------------------- ### HTTP Verb Examples Source: https://github.com/rest-sh/restish/blob/main/site/content/en/docs/reference/example-api.md These endpoints provide focused examples for each of the common HTTP verbs. ```APIDOC ## GET /get ### Description Focused generic HTTP verb example for GET. ### Method GET ### Endpoint /get ``` ```APIDOC ## POST /post ### Description Focused generic HTTP verb example for POST. ### Method POST ### Endpoint /post ``` ```APIDOC ## PUT /put ### Description Focused generic HTTP verb example for PUT. ### Method PUT ### Endpoint /put ``` ```APIDOC ## PATCH /patch ### Description Focused generic HTTP verb example for PATCH. ### Method PATCH ### Endpoint /patch ``` ```APIDOC ## DELETE /delete ### Description Focused generic HTTP verb example for DELETE. ### Method DELETE ### Endpoint /delete ``` ```APIDOC ## HEAD /head ### Description Focused generic HTTP verb example for HEAD. ### Method HEAD ### Endpoint /head ``` ```APIDOC ## OPTIONS /options ### Description Focused generic HTTP verb example for OPTIONS. ### Method OPTIONS ### Endpoint /options ``` -------------------------------- ### Example JSON Payload Source: https://github.com/rest-sh/restish/blob/main/site/content/en/docs/recipes/post-json-from-a-file.md This is an example of a JSON payload file that can be sent as a request body. ```json {"name":"Alice","enabled":true} ``` -------------------------------- ### Install Restish with Homebrew Source: https://github.com/rest-sh/restish/blob/main/site/layouts/_partials/blog-footer-cta.html Use this command to install Restish using the Homebrew package manager. ```bash $ brew install restish ``` -------------------------------- ### Install Restish Plugins via Homebrew Source: https://github.com/rest-sh/restish/blob/main/docs/release-packaging.md Installs various Restish first-party plugins using Homebrew. ```bash brew install rest-sh/tap/restish-bulk brew install rest-sh/tap/restish-csv brew install rest-sh/tap/restish-mcp brew install rest-sh/tap/restish-pkcs11 ``` -------------------------------- ### Example CLI Usage (Desired) Source: https://github.com/rest-sh/restish/blob/main/docs/design/042-custom-cli-embedding-surface.md Illustrates the desired command structure for a custom CLI, where API operations are directly accessible at the root level. ```text acme list-users acme get-user 123 acme auth header acme cache clear ``` -------------------------------- ### Connect to an API and List Images with Restish Source: https://github.com/rest-sh/restish/blob/main/site/content/en/blog/scripting-rest-apis-without-fragile-curl-loops.md Demonstrates connecting to an API using its OpenAPI specification and then listing image resources using generated commands. Assumes OpenAPI connection is already established. ```bash restish api connect example api.rest.sh restish example list-images -f body.self -o lines ```