The Enterprise Plus Edition features a REST API: This interface can be used to “address Password Safe externally” in order to, for example, read data for other programs.
The API is available for C# and JavaScript.

In the JavaScript version of the API, all enums can be found under the global object “PsrApiEnums”.

Requirements and download

The API is exclusively available in the Enterprise Plus Edition. The API client for the desired programming language can be downloaded from the Customer Information System. In order to use the API, web services must have been activated on the AdminClient in the WebClient module.

Using the API

The central object is “PsrApi”. It contains various “managers” that contain the entire business logic. First a “PsrApi” object must be created. The only transfer parameter of this class is the endpoint of the Password Safe WebServices. If the WebClient is in use, “call-des-webclient/api” can be used as the endpoint. Otherwise the Password Safe Server, i.e. “ip-des-servers:11016”, must be used directly.

C#

var psrApi = new PsrApi(„passwordsafe.company.com/api“);

JavaScript

const psrApi = new PsrApi(„passwordsafe.company.com/api“)

Login

If you do not log in to the system in advance, it is not possible to use the API. The first parameter for the login method is the desired database, followed by the user name and password. It is important to note that all methods for running the API that initiate a server call are implemented asynchronously. “Task” objects are returned in C# and “Promise” objects are returned in JavaScript.

C#

await psrApi.AuthenticationManager.Login(„Company“, „username“, „password“);

JavaScript

await psrApi.authenticationManager.login(„Company“, „username“, „password“)

Methods

All methods for the API can then be used. For example, you can search for records and decrypt a password:

C#

// Passwörter, Formulare und Dokumente sind alle Container
var conMan = psrApi.ContainerManager;

// Call up the standard filter for passwords
var passwordListFilter = await conMan.GetContainerListFilter(PsrContainerType.Password, true);

var contentFilter = passwordListFilter.FilterGroups.OfType<PsrListFilterGroupContent>().FirstOrDefault()?.SearchList.FirstOrDefault();
if (contentFilter != null)
{
    // Search for passwords that contain “mateso”
    contentFilter.Search = "mateso";
    contentFilter.FilterActive = true;
}

// Call up all passwords that match the filter
var passwords = await conMan.GetContainerList(PsrContainerType.Password, passwordListFilter);

// Search the password form field
var passwordItem = passwords.FirstOrDefault(p => p.Items.Any(i => i.ContainerItemType == PsrContainerItemType.ContainerItemPassword))?.Items.FirstOrDefault(i => i.ContainerItemType == PsrContainerItemType.ContainerItemPassword);
if (passwordItem != null)
{
    // Decrypting the value of a form field
    var plainText = await conMan.DecryptContainerItem(passwordItem);
    Console.WriteLine("Plaintext value of the container item: " + plainText);
}

// Don’t forget to logout after completing the task to prevent dead sessions
await psrApi.AuthenticationManager.Logout();

JavaScript

// Passwörter, Formulare und Dokumente sind alle Container
const conMan = psrApi.containerManager

// Call up the standard filter for passwords
const passwordListFilter = await conMan.getContainerListFilter(PsrApiEnums.PsrContainerType.Password, true)

const contentFilter = passwordListFilter.FilterGroups.find(fg => 'SearchList' in fg).SearchList[0]
if (contentFilter) {
  // Search for passwords that contain “mateso”
  contentFilter.Search = 'mateso'
  contentFilter.FilterActive = true
}

// Call up all passwords that match the filter
const passwords = await conMan.getContainerList(PsrApiEnums.PsrContainerType.Password, passwordListFilter)

// Search the password form field
const passwordItem = passwords
  .find(p => p.Items.some(i => i.ContainerItemType === PsrApiEnums.PsrContainerItemType.ContainerItemPassword)).Items
  .find(i => i.ContainerItemType === PsrApiEnums.PsrContainerItemType.ContainerItemPassword)
if (passwordItem) {
  // Decrypting the value of a form field
  const plainText = await conMan.decryptContainerItem(passwordItem)
  console.log('Plaintext value of the container item: ' + plainText)
}

// Don’t forget to logout after completing the task to prevent dead sessions
await psrApi.authenticationManager.logout()

Technical documentation

You can find the complete technical documentation for the API under the following link: Password Safe API

Was this helpful?

Yes No
You indicated this topic was not helpful to you ...
Could you please leave a comment telling us why? Thank you!
Thanks for your feedback.