Command Options
Bruno CLI provides a variety of command options to help you customize your API testing and execution process. These options allow you to specify environments, configure reports, handle security, and much more. Below is a comprehensive list of available options:
Bruno version
To check the current version of your Bruno CLI installation, use the following command:
bru --version
This will display the version number of the Bruno CLI you have installed. It’s a helpful command for ensuring you’re working with the latest version or for troubleshooting version-specific issues.
Getting Started
Navigate to the directory where your API collection resides, and run the following command:
bru run
This will run all the requests in your collection. If you want to run a single request, specify its filename:
bru run request.bru
Running Requests in a Folder
To run all the requests within a folder, use:
bru run folder
Using Environments
If you need to use a specific environment, you can pass it with the --env
option:
bru run folder --env Local
Passing Environment Variables
Variables marked as secrets in Bruno app are not accessible via the CLI. Pass them directly as command-line arguments.
bru run folder --env Local --env-var JWT_TOKEN=1234
Multiple Environment Variables
You can override multiple environment variables by using additional --env-var
flags:
bru run folder --env Local --env-var JWT_TOKEN=1234 --env-var API_KEY=abcd1234
Each --env-var
flag adds or overrides a single environment variable, and you can chain as many as needed.
Adding Delay
If you need to add a delay between requests during the execution of your API collection, you can use the --delay
option.
Example:
bru run --delay 1000
Using Client Certificates for API Requests
If your API requests require client certificates for authentication, you can specify using the --client-cert-config
option. The configuration should be provided in a JSON file. Here’s an example of how to use this option:
bru run folder --client-cert-config /path/to/client-cert-config.json
The client-cert-config.json file should contain the following fields:
{
"enabled": true,
"certs": [
{
"domain": "usebruno.com",
"type": "cert",
"certFilePath": "certs/server_1.crt",
"keyFilePath": "private/server_1.key",
"passphrase": "Iu$eBrun0_#Secure!"
},
{
"domain": "the-example.com",
"type": "pfx",
"pfxFilePath": "pfx/server_3.pfx",
"passphrase": "L!ghT_Y@g@mi_2024!"
}
]
}
Importing OpenAPI Specifications
Bruno CLI allows you to import OpenAPI specifications directly into Bruno collection from the command line, which can be integrated into CI/CD pipelines whenever API changes are committed.
Option 1: Import to Bruno Collection
This will import the OpenAPI specification (supports both YAML and JSON formats) and generate a Bruno collection in the specified output directory.
bru import openapi --source <your-openapi.yaml> --output <preferred-location> --collection-name "Petstore API"
Where:
<your-openapi.yaml>
: Path to your OpenAPI specification file (can be either YAML or JSON format)<preferred-location>
: Directory where you want to save the collection
Option 2: Import to Single JSON File
This will import the OpenAPI specification and generate a Bruno collection as a single JSON file at the specified location.
bru import openapi --source <your-openapi.yaml> --output-file <preferred-location>.json --collection-name "Petstore API"
Where:
<your-openapi.yaml>
: Path to your OpenAPI specification file (can be either YAML or JSON format)<preferred-location>
: Base path and filename for your JSON output
Options
Option | Details |
---|---|
-h , --help | Show help |
--version | Show version number |
-r | Indicates a recursive run (default: false) |
--cacert [string] | CA certificate to verify peer against |
--env [string] | Specify environment to run with |
--env-var [string] | Overwrite a single environment variable, multiple usages possible |
-o , --output [string] | [DEPRECATED] Path to write file results to. Use reporter options instead |
-f , --format [string] | [DEPRECATED] Format of the file results. Use reporter options instead |
--reporter-json [string] | Path to generate a JSON report |
--reporter-junit [string] | Path to generate a JUnit report |
--reporter-html [string] | Path to generate an HTML report |
--insecure | Allow insecure server connections |
--tests-only | Only run requests that have tests |
--bail | Stop execution after a failure of a request, test, or assertion |
--csv-file-path | CSV file to run the collection with |
--reporter--skip-all-headers | Skip all headers in the report |
--reporter-skip-headers | Skip specific headers in the report |
--client-cert-config | Client certificate configuration by passing a JSON file |
--delay [number] | Add delay to each request |
--source [string] | Path to the OpenAPI specification file (YAML or JSON) |
--output-file [string] | Output file to export as Bruno collection in JSON format |
--collection-name [string] | Name for the imported collection from OpenAPI |
Demo
Adding “Fetch in Bruno” Button to Your Documentation
You can add a “Fetch in Bruno” button to your website or documentation to allow users to directly import your Bruno collection with a single click. This is particularly useful for sharing collections hosted on GitHub.
Add the following HTML to your website:
<div class="bruno-fetch-button" data-bruno-collection-url="https://github.com/your-username/your-collection"></div>
<script src="https://fetch.usebruno.com/button.js"></script>
Replace https://github.com/your-username/your-collection
with the URL to your Bruno collection on GitHub.
Example
Here’s a live example of the “Fetch in Bruno” button for the Bruno Starter Guide:
When users click this button, Bruno will automatically clone the repository and import the collection.
Support
If you encounter any issues or have any feedback or suggestions, please raise them on our GitHub repository