API & integrations
Python connector
11min
description the python client is used to interact with the passwork password management system api it ensures secure storage, retrieval, and management of passwords with support for client side encryption requirements python 3 10+ requests >= 2 31 0 python dotenv >= 1 0 0 cryptography >= 42 0 0 pbkdf2 >= 1 3 installation the package can be installed directly from github shell pip install git+ssh //git\@github com\ passwork me/passwork python git alternatively, install via https shell pip install git+https //github com/passwork me/passwork python git features client side encryption with master password support; automatic token refresh; encrypted session storage and restoration; multi layer encryption (pbkdf2, rsa, aes); attachment management; user and role management; vault (storage) management; password sharing via inbox; support for custom fields; tag system advanced usage session management save and restore sessions to avoid repeated authorization python # save session to file (encrypted) encryption key = client save session("session file", none, true) \# restore session client = passworkclient("https //your passwork instance com", true) client load session("session file", encryption key) password management create a password with custom fields, tags, and attachments python password = { "name" "service name", "login" "username", "password" "secure password", "vaultid" vault id, "folderid" folder id, # optional "description" "description text", "url" "https //service url com", "tags" \["tag1", "tag2"], "customs" \[ { "name" "additional login", "value" "second username", "type" "text" }, { "name" "recovery code", "value" "recovery code value", "type" "password" }, { "name" "totp", "value" "jbswy3dpehpk3pxp", "type" "totp" } ], "attachments" \[ { "path" "path/to/file png", "name" "file png" } ] } password id = client create password(password) update an existing password python update data = { "login" "new username", "password" "new password", "vaultid" vault id } client update password(password id, update data) delete a password python bin item id = client delete password(password id) user management create a new user python # retrieve available user roles user roles = client get user roles({"includeuserrole" true, "isonlymanageable" true}) user role = \[role for role in user roles\["items"] if role\["code"] == "user"]\[0] \# create user data = { "login" "new user", "userroleid" user role\["id"], "usergroupids" \[] } new user = client create user(data) \# returns user id, password, and master password sharing passwords share a password with another user via inbox python # share password with read permissions inbox id = client create inbox password(password id, recipient user id, "read") \# recipient accesses the password inbox password = client get inbox password(inbox id) direct api calls for operations not covered by helper methods python # direct api call response = client call("delete", f"/api/v1/folders/{folder id}") documentation detailed examples are available in the examples directory of the repository