> ## 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.

# List vaults and items using 1Password SDKs

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)](/sdks/concepts#unique-identifiers) for an item or vault.

## Before you get started

Before you begin, [follow the steps to get started](/sdks#get-started) with a 1Password SDK. The examples on this page assume you have an initialized `client` instance. For example:

<Tabs groupId="sdks">
  <Tab value="go" title="Go">
    {/* markdownlint-disable MD046 */}

    ```go theme={null}
    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
    }

    ```
  </Tab>

  <Tab value="js" title="JavaScript">
    {/* markdownlint-disable MD046 */}

    <Tabs groupId="sdk-before-start-js">
      <Tab value="esm" title="ES Modules">
        ```javascript theme={null}
        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);

        ```
      </Tab>

      <Tab value="cjs" title="CommonJS">
        ```javascript theme={null}
        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);

        ```
      </Tab>
    </Tabs>
  </Tab>

  <Tab value="python" title="Python">
    {/* markdownlint-disable MD046 */}

    ```python theme={null}
    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())

    ```
  </Tab>
</Tabs>

<Tip>
  See the examples folder in the 1Password [Go](https://github.com/1Password/onepassword-sdk-go/tree/main/example), [JavaScript](https://github.com/1Password/onepassword-sdk-js/tree/main/examples), or [Python](https://github.com/1Password/onepassword-sdk-python/tree/main/example) SDK GitHub repository for full example code you can quickly clone and test in your project.
</Tip>

## List vaults

<Tabs groupId="sdks">
  <Tab value="go" title="Go">
    The [`Vaults().List()`](https://github.com/1Password/onepassword-sdk-go/blob/main/vaults.go#L66) method gets all vaults in an account.

    ```go theme={null}
    // 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)
    }
    ```
  </Tab>

  <Tab value="js" title="JavaScript">
    The [`vaults.list()`](https://github.com/1Password/onepassword-sdk-js/blob/main/client/src/vaults.ts#L100) method gets all vaults in an account.

    ```js theme={null}
    // List vaults
    const vaults = await client.vaults.list({ decryptDetails: true });
    for await (const vault of vaults) {
      console.log(JSON.stringify(vault, null, 2));
    }
    ```
  </Tab>

  <Tab value="python" title="Python">
    The [`vaults.list()`](https://github.com/1Password/onepassword-sdk-python/blob/main/src/onepassword/vaults.py#L49) method gets all vaults in an account.

    ```python theme={null}
    # List vaults
    vaults = await client.vaults.list()
    for vault in vaults:
        print(f"{vault.title} ({vault.id})")
    ```
  </Tab>
</Tabs>

## List items

<Tabs groupId="sdks">
  <Tab value="go" title="Go">
    The [`Items().List()`](https://github.com/1Password/onepassword-sdk-go/blob/main/items.go#L181) 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-vaults).

    ```go theme={null}
    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)
    }
    ```
  </Tab>

  <Tab value="js" title="JavaScript">
    The [`items.list()`](https://github.com/1Password/onepassword-sdk-js/blob/main/client/src/items.ts#L70) 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-vaults).

    ```js theme={null}
    const overviews = await client.items.list(vaultId);
    for (const overview of overviews) {
      console.log(overview.id + " " + overview.title);
    }
    ```
  </Tab>

  <Tab value="python" title="Python">
    The [`items.list()`](https://github.com/1Password/onepassword-sdk-python/blob/main/src/onepassword/items.py#L188) 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-vaults).

    ```python theme={null}
    # List items
    overviews = await client.items.list("your-vault-id")
    for overview in overviews:
        print(f"{overview.title} ({overview.id})")
    ```
  </Tab>
</Tabs>

### Filter listed items by state

You can filter listed items by their [state](/sdks/concepts#item-states): `Active` or `Archived`.

<Tabs groupId="sdks">
  <Tab value="go" title="Go">
    To filter listed items so only archived items are returned, use the [`ItemListFilter`](https://github.com/1Password/onepassword-sdk-go/blob/main/types.go#L1082) struct:

    ```go theme={null}
    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)
    }
    ```
  </Tab>

  <Tab value="js" title="JavaScript">
    To filter listed items so only archived items are returned, use the [`ItemListFilter`](https://github.com/1Password/onepassword-sdk-js/blob/main/client/src/types.ts#L630) type:

    ```js theme={null}
    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);
    }
    ```
  </Tab>

  <Tab value="python" title="Python">
    To filter listed items so only archived items are returned, use the [`ItemListFilter`](https://github.com/1Password/onepassword-sdk-python/blob/main/src/onepassword/types.py#L1393) class:

    ```python theme={null}
    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})")
    ```
  </Tab>
</Tabs>

## Learn more

* [Secret reference syntax](/cli/secret-reference-syntax/)
* [Load secrets using 1Password SDKs](/sdks/load-secrets/)
* [Manage items using 1Password SDKs](/sdks/manage-items/)
* [Share items using 1Password SDKs](/sdks/share-items/)
* [Workflow: Build integrations with 1Password](/get-started/build-integrations)
* [Workflow: Secure your developer secrets](/get-started/secure-developer-secrets)
