Documentation Index
Fetch the complete documentation index at: https://www.1password.dev/llms.txt
Use this file to discover all available pages before exploring further.
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 get started
Before you begin, follow the steps to get started with a 1Password SDK. The examples on this page assume you have an initialized client instance. For example:
package main
import (
"context"
"github.com/1password/onepassword-sdk-go"
)
func main() {
// TODO: Initialize client using your preferred authentication method (see Overview > Get started)
client, err := onepassword.NewClient(context.Background(),
)
if err != nil {
panic(err)
}
// Your code here
}
import sdk from "@1password/sdk";
async function main() {
const client = await sdk.createClient({
// TODO: Initialize client using your preferred authentication method (see Overview > Get started)
});
// Your code here
}
main().catch(console.error);
const sdk = require("@1password/sdk");
async function main() {
const client = await sdk.createClient({
// TODO: Initialize client using your preferred authentication method (see Overview > Get started)
});
// Your code here
}
main().catch(console.error);
import asyncio
from onepassword import Client # Also import DesktopAuth for desktop app authentication.
async def main():
# TODO: Initialize client using your preferred authentication method (see Overview > Get started)
client = await Client.authenticate(...)
# Your code here
asyncio.run(main())
See the examples folder in the 1Password Go, JavaScript, or Python SDK GitHub repository for full 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)
}
The vaults.list() method gets all vaults in an account.// List vaults
const vaults = await client.vaults.list({ decryptDetails: true });
for await (const vault of vaults) {
console.log(JSON.stringify(vault, null, 2));
}
The vaults.list() method gets all vaults in an account.# List vaults
vaults = await client.vaults.list()
for vault in vaults:
print(f"{vault.title} ({vault.id})")
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)
}
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().const overviews = await client.items.list(vaultId);
for (const overview of overviews) {
console.log(overview.id + " " + overview.title);
}
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().# List items
overviews = await client.items.list("your-vault-id")
for overview in overviews:
print(f"{overview.title} ({overview.id})")
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)
}
To filter listed items so only archived items are returned, use the ItemListFilter type:const archivedOverviews = await client.items.list(vaultId, {
type: "ByState",
content: { active: false, archived: true },
});
for (const overview of archivedOverviews) {
console.log(overview.id + " " + overview.title);
}
To filter listed items so only archived items are returned, use the ItemListFilter class:from onepassword import ItemListFilterByState, ItemListFilterByStateInner
# List items using item filters
archived_overviews = await client.items.list(
"your-vault-id",
ItemListFilterByState(
content=ItemListFilterByStateInner(active=False, archived=True)
),
)
for overview in archived_overviews:
print(f"{overview.title} ({overview.id})")
Learn more