How to Use Bruno API Client: A Beginner's Guide
What is Bruno API Client?
Bruno is a Git-friendly, open-source API client designed to simplify API interactions for developers. Unlike cloud-based alternatives, Bruno operates entirely offline, making it a secure choice for handling sensitive API requests. Its minimalist design focuses on essential features that developers need most, without the bloat that often accompanies other API tools.
Key features that make Bruno stand out include:
- Git integration: Store your API collections directly in your project repositories
- Fully offline operation: No account required, works without an internet connection
- Open-source: Free to use with an active community of contributors
- Developer-focused: Clean interface with minimal distractions
Installing Bruno API Client
Getting started with Bruno is straightforward. The application is available for Windows, macOS, and Linux:
Windows Installation
- Using Chocolatey:
choco install bruno - Using Winget:
winget install bruno.bruno - Alternatively, download the installer from the official website
macOS Installation
- Using Homebrew:
brew install bruno - Alternatively, download the DMG file from the official website
Linux Installation
- Download the appropriate package (.deb for Debian/Ubuntu or .rpm for Fedora/CentOS)
- Install using your package manager
Understanding the Bruno Interface
After launching Bruno, you'll be presented with a clean, intuitive interface designed to help you manage your API requests efficiently:
- Collections Panel: Located on the left side, this is where you organize your API requests into collections and folders
- Request Builder: The central area where you create and configure API requests
- Response Viewer: Displays the results of your API requests
- Environment Selector: Located in the top right, allows you to switch between different environments
Building Your First API Request in Bruno
Let's walk through creating a simple API request to understand the basics:
Step 1: Create a Collection
Collections help you organize related API requests. To create one:
- Click on "New Collection" in the left panel
- Give your collection a descriptive name (e.g., "Weather API Requests")
- Optionally, add a description to provide context
Step 2: Add a New Request
Now, let's add a request to your collection:
- Right-click on your collection and select "New Request"
- Name your request (e.g., "Get Current Weather")
- Choose the HTTP method from the dropdown (GET, POST, PUT, DELETE, etc.)
- Enter the endpoint URL (e.g.,
https://api.example.com/weather)
Step 3: Configure Request Parameters
Depending on the API, you might need to add:
Headers
- Click on the "Headers" tab
- Add key-value pairs for required headers (e.g.,
Content-Type: application/json)
Query Parameters
- Click on the "Query" tab
- Add parameters that will be appended to your URL (e.g.,
city=London)
Request Body (for POST/PUT requests)
- Click on the "Body" tab
- Select the format (JSON, form data, etc.)
- Enter your request payload
Step 4: Send Your Request
Click the "Send" button or press Ctrl+Enter to execute your request. The response will appear in the panel below, showing:
- Status code (200 OK, 404 Not Found, etc.)
- Response time
- Response headers
- Response body (formatted for readability)
Working with Environments in Bruno
Environments allow you to use the same requests with different configurations (development, staging, production). This is particularly useful when you need to switch between different API endpoints or credentials.
Creating an Environment
- Click on the environment dropdown in the top-right corner
- Select "Configure Environments"
- Click "Add Environment" and give it a name (e.g., "Development")
- Add variables as key-value pairs:
baseUrl:https://dev-api.example.comapiKey:your-dev-api-key
Using Environment Variables
Once you've set up your environment, you can use variables in your requests:
- In the URL field, use double curly braces:
{{baseUrl}}/weather - In headers:
Authorization: Bearer {{apiKey}}
This approach makes it easy to switch between environments without modifying your requests.
Advanced Features in Bruno
As you become more comfortable with Bruno, you can explore its advanced capabilities:
Pre-request Scripts
Pre-request scripts allow you to execute JavaScript code before your request is sent. This is useful for:
- Generating dynamic values (timestamps, UUIDs)
- Calculating authentication signatures
- Setting up environment variables
To add a pre-request script:
- Click on the "Script" tab
- Write your JavaScript code
- Use the
reqobject to modify your request
For example, to add a basic authentication header:
const btoa = require("btoa");
const auth = btoa(bru.getEnvVar("username") + ":" + bru.getEnvVar("password"));
req.setHeader("Authorization", "Basic " + auth);
Post-request Scripts
Post-request scripts run after receiving a response, allowing you to:
- Extract data from responses for use in other requests
- Validate response data
- Perform automated testing
To save a value from a response:
// Save the access token from the response
bru.setEnvVar("accessToken", res.body.access_token);
Collection Variables
Bruno also supports collection-level variables that can be shared across requests within the same collection. These are particularly useful for values that change during a session but are used by multiple requests.
Organizing API Workflows
For complex API interactions, organizing your requests into logical workflows can save time and reduce errors:
Folders and Subfolders
Group related requests into folders:
- Right-click on your collection
- Select "New Folder"
- Organize requests into these folders (e.g., "Authentication", "User Management", "Reports")
Request Sequence
If your API workflow requires a specific sequence of requests (like authentication before data retrieval), you can:
- Number your requests to indicate order
- Use post-request scripts to extract data needed for subsequent requests
- Document dependencies in request descriptions
Collaborative Work with Bruno
As Bruno is Git-friendly, sharing and collaborating on API collections is straightforward:
- Store your Bruno collections directly in your project repository
- Collections are saved as plain text files, making them easy to version control
- Team members can pull the latest changes and work with the same collections
Apidog: A Better Alternative to Bruno
While Bruno offers a solid foundation for API testing and development, Apidog provides a more comprehensive solution with advanced features that address the needs of modern development teams.
Why Consider Apidog Over Bruno
All-in-One Platform
Apidog combines multiple tools into a single platform:
- API Design: Visual OpenAPI specification editor
- API Testing: Powerful request builder with automated testing
- API Documentation: Auto-generated, customizable documentation
- API Mocking: Smart mock servers without writing code
- Team Collaboration: Real-time collaboration features
Superior Testing Capabilities
Apidog excels in testing with features that Bruno lacks:
- Visual Test Builder: Create complex test scenarios without code
- Automated Testing: Generate tests directly from API specifications
- Performance Testing: Run load tests with a single click
- CI/CD Integration: Seamlessly integrate with your deployment pipeline
Enhanced Collaboration Features
For teams working on APIs together, Apidog offers:
- Team Workspaces: Dedicated spaces for team collaboration
- Role-Based Access Control: Granular permissions management
- Real-Time Updates: See changes as they happen
- Comment & Feedback System: Discuss API design within the tool
Streamlined API Development Workflow
Apidog implements a true API design-first approach:
- Design APIs visually
- Generate requests and examples automatically
- Create documentation as you build
- Test against specifications
Smart Mocking
While Bruno requires manual setup for mock servers, Apidog offers:
- Intelligent Mock Data: Generates realistic data based on field names
- Cloud-Based Mocking: Share mock endpoints with your team
- Custom Response Rules: Configure specific responses for different scenarios
Versatile Documentation
Documentation in Apidog is:
- Automatically Generated: Based on your API design
- Customizable: Mix markdown with API specifications
- Shareable: Publish to custom domains or share securely
- Interactive: Allows users to try APIs directly from the docs
Making the Transition from Bruno to Apidog
If you're currently using Bruno and want to upgrade to Apidog, the transition is straightforward:
- Import Collections: Apidog can import API definitions from various formats
- Set Up Environments: Configure your development, staging, and production environments
- Enhance Your Tests: Leverage Apidog's advanced testing features
- Collaborate: Invite team members to your workspace
Conclusion
Bruno API client offers a solid, minimalist approach to API testing and development, particularly appealing to developers who prefer offline tools with Git integration. Its straightforward interface and focus on essential features make it a good starting point for those new to API clients.
However, as your API development needs grow more complex, Apidog presents a more comprehensive solution with its all-in-one platform approach. The additional features for testing, documentation, mocking, and team collaboration make it a superior choice for teams working on sophisticated API projects.
Whether you choose Bruno for its simplicity or Apidog for its comprehensive feature set, having a dedicated API client will significantly improve your development workflow and help you build better, more reliable APIs. As APIs continue to be central to modern software development, investing time in mastering these tools will pay dividends in your development journey.
