Installation
Your Python version should be 3.10 or higher
pip install git+https://github.com/passwork-me/pip-connector
Credentials
The following credentials are required:
- host — API server address, e.g.
https://.../api/v4; - api_key — Your API key for authentication (Settings and users→ API Settings);
- master_password — Client encryption key. Specify only if client encryption is enabled.
The login() method in an instance of the PassworkAPI class is used to get a temporary API token. The received API token is stored as an instance variable named session_options inside the PassworkAPI class and then sent in an HTTP header.
This token is valid for the duration of the session, i.e. as long as requests to the API are made. When the token expires, you need to log in again to generate a new one. The validity period of the API token can be configured in Passwork settings.
Action examples
Creating a session (common step for all operations)
Create an instance of the API connection and open a session:
from passwork.passwork_api import PassworkAPI
api = PassworkAPI(
host="https://.../api/v4",
api_key="aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
master_password="master_password"
)
Password search
search_params = {
"query": "test",
"tags": [],
"colors": [],
"vaultId": None,
"includeShared": False,
"includeShortcuts": False,
}
from passwork.password_crud import search_password
found_passwords = search_password(api, search_params)
Getting full password information
download_attachments_path is not a required argument, without it attachments will be saved in the downloaded_attachments/{password_id} folder.
from passwork.password_crud import get_inbox_password
inbox_password_id = "0123456789abcdefghijklmn"
download_attachments_path = f"example_folder/{inbox_password_id}"
inbox_password_full_info = get_inbox_password(
api=api,
inbox_password_id=inbox_password_id,
download_attachments_path=download_attachments_path,
log_pretty_data=False,
)
Adding a password
If vault_id is specified, the password_id variable can be empty. Parameter description — add_password
password_adding_fields = {...}
from passwork.password_crud import add_password
vault_id = "0123456789abcdefghijklmn"
added_password_info = add_password(
api=api,
password_adding_fields=password_adding_fields,
vault_id=vault_id,
)
Deleting a password
from passwork.password_crud import delete_password
password_id = "0123456789abcdefghijklmn"
delete_password(api=api, password_id=password_id)