SDKs overview
BitWarden offers developers tools and resources to integrate its password management and secrets capabilities into various applications and workflows. The primary interface for programmatic interaction is the BitWarden API, which the official SDKs and the BitWarden Command Line Interface (CLI) are built upon. This allows for automation of tasks such as retrieving credentials, managing vault items, and interacting with BitWarden organizations.
The official SDKs are designed to provide type-safe and idiomatic access to the BitWarden API in specific programming languages. These libraries abstract away the complexities of direct HTTP requests, authentication, and response parsing, enabling developers to focus on application logic. Beyond the official offerings, a vibrant community contributes additional libraries and wrappers, expanding BitWarden's reach into more programming languages and specialized use cases.
The BitWarden CLI (bw) serves as a versatile tool for scripting and automation, accessible from various shell environments. It provides a comprehensive set of commands that mirror the functionality available through the API, making it suitable for CI/CD pipelines, server-side automation, and local development scripts.
Official SDKs by language
BitWarden maintains official SDKs and a CLI that provide direct access to its services. These tools are recommended for robust and supported integrations. The core functionality often revolves around authenticating with a BitWarden server, managing vault items (logins, secure notes, cards, identities), and interacting with organizational secrets.
The following table outlines the key official developer tools:
| Language/Tool | Package/Name | Primary Use | Maturity |
|---|---|---|---|
| C# | Bitwarden.SDK |
Integrating into .NET applications | Stable |
| TypeScript/JavaScript | @bitwarden/sdk |
Node.js applications, web environments | Stable |
| Command Line Interface (CLI) | bw |
Scripting, automation, CI/CD | Stable |
The BitWarden CLI is particularly versatile, available as a standalone executable and often used as the backbone for community-driven integrations in other languages. Detailed documentation for the CLI, including all available commands and options, can be found on the BitWarden CLI documentation page.
Installation
Installation methods vary depending on the chosen SDK or tool. The BitWarden CLI is available across multiple platforms and is often the first tool developers integrate for automation.
BitWarden CLI
The BitWarden CLI can be installed via npm, as a standalone executable, or through package managers. For example, using npm:
npm install -g @bitwarden/cli
For alternative installation methods, such as direct download for Windows, macOS, or Linux, refer to the BitWarden CLI installation guide.
C# SDK
The C# SDK is distributed as a NuGet package. It can be added to a .NET project using the NuGet Package Manager or the .NET CLI:
dotnet add package Bitwarden.SDK
Further details on integrating the C# SDK can be found within the BitWarden API documentation.
TypeScript/JavaScript SDK
The TypeScript SDK is available via npm and can be added to Node.js projects:
npm install @bitwarden/sdk
This package provides typings for TypeScript projects and can be used in JavaScript environments. For usage examples, consult the BitWarden developer portal.
Quickstart example
This quickstart demonstrates logging into the BitWarden CLI, unlocking the vault, and retrieving a specific login item. This pattern is fundamental for automating credential access in scripts or applications.
BitWarden CLI Quickstart
First, log in to your BitWarden account. This command will prompt for your email and master password:
bw login
Once logged in, your session needs to be unlocked to access vault items. You can unlock the vault using your master password:
bw unlock <YOUR_MASTER_PASSWORD>
The unlock command returns a session key. Store this key in an environment variable for subsequent commands:
export BW_SESSION="<YOUR_SESSION_KEY>"
Now, you can retrieve a specific login item by its name. For instance, to get details for an item named "My Website Login":
bw get item "My Website Login"
This command outputs the JSON representation of the vault item, including username, password, and other fields. For more advanced queries, such as filtering by URI or type, refer to the BitWarden CLI 'get' command documentation.
Remember to log out and clear the session when done, especially in shared environments:
bw logout
Community libraries
The open-source nature of BitWarden has fostered a community that develops and maintains additional libraries and integrations, extending its reach beyond the officially supported SDKs. These community-driven projects often provide wrappers for the BitWarden CLI in various programming languages, or implement direct API clients where official SDKs do not exist.
While not officially supported by BitWarden, these libraries can be valuable for developers working in specific ecosystems. They typically leverage the existing BitWarden API or the CLI's capabilities to offer similar functionality. Examples might include Python wrappers for the CLI, Go language clients, or even integrations with specific developer tools.
Developers interested in community libraries should search platforms like GitHub or package repositories (e.g., PyPI for Python, Go Modules for Go) for "BitWarden client" or "BitWarden API" in their preferred language. When using community libraries, it is advisable to review their source code, check their maintenance status, and understand their security implications, as their support and security posture are dependent on their respective maintainers. The Mozilla Developer Network's definition of open source provides context on community-driven software development practices.
For example, a Python wrapper might simplify CLI interactions like this:
import subprocess
import json
def bw_cli_command(command_args):
process = subprocess.run(['bw'] + command_args, capture_output=True, text=True)
if process.returncode != 0:
raise Exception(f"BitWarden CLI error: {process.stderr}")
return process.stdout.strip()
def bw_login(email, password):
output = bw_cli_command(['login', email, password])
# Handle login output, session key extraction, etc.
return output
def bw_unlock(master_password):
output = bw_cli_command(['unlock', master_password])
session_key_line = [line for line in output.split('\n') if 'BW_SESSION' in line][0]
session_key = session_key_line.split('=')[1].strip()
return session_key
def bw_get_item(item_name, session_key):
result = bw_cli_command(['get', 'item', item_name, '--session', session_key])
return json.loads(result)
# Example usage (simplified)
# email = "[email protected]"
# master_password = "your_master_password"
#
# # session_output = bw_login(email, master_password) # Requires interactive input or specific flags
# session_key = bw_unlock(master_password)
#
# if session_key:
# item_data = bw_get_item("My Website Login", session_key)
# print(f"Username: {item_data['login']['username']}")
# print(f"Password: {item_data['login']['password']}")
#
# bw_cli_command(['logout']) # Always log out
This Python example illustrates how a community library might wrap the underlying bw CLI calls, providing a more programmatic interface within a different language environment. Developers should always refer to the specific documentation of any third-party library they choose to use.