List and filter through all Groups

Usage

import { PinataSDK } from "pinata-web3";

const pinata = new PinataSDK({
  pinataJwt: process.env.PINATA_JWT!,
  pinataGateway: "example-gateway.mypinata.cloud",
});

const groups = await pinata.groups
  .list()
  .name("Greetings");

Returns

type GroupResponseItem = {
  id: string;
  user_id: string;
  name: string;
  updatedAt: string;
  createdAt: string;
};

Parameters

Filter response with the following additional methods. All filters are optional.

name

  • Type: string

Filter by name, uses “contains” matching

const groups = await pinata.groups
  .list()
  .name("Greetings");

limit

  • Type: number

Limit the number of results

const groups = await pinata.groups
  .list()
  .limit(5);

offset

  • Type: number

Offset the number of groups returned to paginate

const groups = await pinata.groups
  .list()
  .offset(10);

Auto Paginate

The list method has an auto pagination feature that is triggered when used inside a for await iterator

for await (const item of pinata.gateways.list()) {
  console.log(item.name);
}