Skip to main content
You can use 1Password SDKs to list vaults and items in a 1Password account. This is helpful if you need to get the unique identifier (ID) for an item or vault. Before you begin, follow the steps to get started with a 1Password SDK.
See the examples folder in the 1Password Go, JavaScript, or Python SDK GitHub repository for example code you can quickly clone and test in your project.

List vaults

The Vaults().List() method gets all vaults in an account.
// List vaults
vaults, err := client.Vaults().List(context.Background())
if err != nil {
	panic(err)
}
for _, vault := range vaults {
	fmt.Println("VAULT ID: ", vault.ID, "VAULT NAME: ", vault.Title)
}

List items

The Items().List() method gets all items in a vault and can return each item’s ID, title, category, state, and the ID of the vault where it’s stored. It only returns active items by default. The example below returns item IDs.To list items, specify a vault ID, or pass a vault ID from the results of an item or the results of Vaults().List().
overviews, err := client.Items().List(context.Background(), vaultID)
if err != nil {
	panic(err)
}
for _, overview := range overviews {
	fmt.Printf("%s %s\\n", overview.ID, overview.Title)
}

Filter listed items by state

You can filter listed items by their state: Active or Archived.
To filter listed items so only archived items are returned, use the ItemListFilter struct:
archivedOverviews, err := client.Items().List(context.Background(), vaultID,
	onepassword.NewItemListFilterTypeVariantByState(
		&onepassword.ItemListFilterByStateInner{
			Active:   false,
			Archived: true,
		},
	),
)
if err != nil {
	panic(err)
}
for _, overview := range archivedOverviews {
	fmt.Printf("%s %s\\n", overview.ID, overview.Title)
}

Learn more