A simple Python wrapper for the Bitwarden CLI — programmatically read and update passwords stored in your Bitwarden vault.
bitwarden-py calls the official bw binary under the hood, so you must have it installed and available in your PATH.
Install it by following the official guide:
👉 https://bitwarden.com/help/cli/#download-and-install
Quick install options:
# macOS (Homebrew)
brew install bitwarden-cli
# Windows (Chocolatey)
choco install bitwarden-cli
# npm (cross-platform)
npm install -g @bitwarden/cliAfter installation, verify it works:
bw --versionpip install bitwarden-pyOr with uv:
uv add bitwarden-pyfrom bitwarden_py import Bitwarden
bw = Bitwarden(
email="your@email.com",
password="your_master_password",
)
# Fetch a password by item name
db_password = bw.get_password("My Database")
print(db_password) # → "s3cr3t!"
# Update the password of an item
bw.set_password("My Database", "n3wp4ssw0rd")By default the library points to https://vault.bitwarden.eu.
Pass server_url to connect to a different instance:
bw = Bitwarden(
email="your@email.com",
password="your_master_password",
server_url="https://bitwarden.yourcompany.com",
)For the full Bitwarden CLI documentation, see 👉 https://bitwarden.com/help/cli/
Creates a new client and authenticates with the vault.
| Parameter | Type | Default | Description |
|---|---|---|---|
email |
str |
— | Your Bitwarden account email |
password |
str |
— | Your master password |
server_url |
str |
"https://vault.bitwarden.eu" |
Bitwarden server URL |
Creates a new vault item. Use bw.get_template("item") to obtain the base structure.
template = bw.get_template("item")
template["name"] = "My Login"
template["login"]["username"] = "user@example.com"
template["login"]["password"] = "s3cr3t"
new_item = bw.create_item(template)Creates a new folder. Use bw.get_template("folder") to obtain the base structure.
template = bw.get_template("folder")
template["name"] = "Work"
new_folder = bw.create_folder(template)Attaches a file to an existing vault item.
bw.create_attachment("./secret.txt", "16b15b89-65b3-4639-ad2a-95052a6d8f66")Returns the password of the vault item matching item_name.
Returns the full vault item object matching the given ID or name.
Returns the username of the vault item matching the given ID or name.
Returns the notes of the vault item matching the given ID or name.
Returns the URI of the vault item matching the given ID or name.
Returns the current TOTP code for the vault item matching the given ID or name.
Returns the JSON template for the given object type. Useful for constructing objects to pass to create_* and edit_* methods.
Supported types: item, item.field, item.login, item.login.uri, item.card, item.identity, item.securenote, folder, collection, item-collections, org-collection.
Returns a list of vault items. All parameters are optional and act as filters.
| Parameter | Type | Description |
|---|---|---|
search |
str |
Filter by search term |
folder_id |
str |
Filter by folder ID (null / notnull) |
collection_id |
str |
Filter by collection ID |
organization_id |
str |
Filter by organization ID |
url |
str |
Filter by URI |
trash |
bool |
If True, list items in the trash |
Returns a list of folders, optionally filtered by search.
Returns a list of collections, optionally filtered by organization ID or search term.
Returns a list of organizations, optionally filtered by search.
Updates the password of the vault item matching item_name.
Replaces a vault item with the provided dict. Fetch the current item with get_item first, modify it, then pass it here.
item = bw.get_item("7ac9cae8-5067-4faf-b6ab-acfd00e2c328")
item["login"]["password"] = "newp@ssw0rd"
bw.edit_item(item["id"], item)Replaces a folder with the provided dict.
Sends an item to the trash. Pass permanent=True to delete it immediately without going through trash.
Deletes a folder. Pass permanent=True to skip trash.
Deletes an attachment from a vault item.