List and filter through all Groups

Usage

import { PinataSDK } from "pinata";

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

const groups = await pinata.groups
  .list()

Returns

type GroupListResponse = {
  groups: GroupResponseItem[];
  next_page_token: string;
};

type GroupResponseItem = {
    id: string;
    is_public: boolean;
    name: string;
    created_at: string;
};

Parameters

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

name

  • Type: string

Filters groups based the group name

const groups = await pinata.groups
    .list()
    .name("SDK")

isPublic

  • Type: boolean

Filters groups based on whether they are public or not

const groups = await pinata.groups
    .list()
    .isPublic(true)

limit

  • Type: number

Limits the number of results

const groups = await pinata.groups
    .list()
    .limit(10)

pageToken

  • Type: string

Paginates through groups based on a provided page token

const groups = await pinata.groups
  .list()
  .pageToken("MDE5MWIzZWYtM2U0Zi03YTY5LWE3OTQtOTRhZDE5NjQxMTk0")

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);
}