Help & Support

Fetch Groups

This guide will help you with fetching Groups from Lens API.

Get a Group

Use the fetchGroup function to fetch a single Group by address or by transaction hash.

Fetching a Group by transaction hash is extremely useful when building a user experience where a user creates a Group and needs it presented back to them.

import { evmAddress } from "@lens-protocol/client";import { fetchGroup } from "@lens-protocol/client/actions";
import { client } from "./client";
const result = await fetchGroup(client, {  group: evmAddress("0x1234…"),});
if (result.isErr()) {  return console.error(result.error);}
const group = result.value;

List Groups

Use the paginated fetchGroups function to fetch a list of Groups based on the provided filters.

import { fetchGroups } from "@lens-protocol/client/actions";import { client } from "./client";
const result = await fetchGroups(client, {  filter: {    searchQuery: "group",  }});
if (result.isErr()) {  return console.error(result.error);}
// items: Array<Group>const { items, pageInfo } = result.value;

See the Pagination guide for more information on how to handle paginated results.