Guides

Explore publications

This query returns a list of publications based on the top collected or top comments. It randomizes it so it is never the same content you see twice similar to how Instagram works when you refresh their explore section.

For now, this uses basic explore logic on basic data the protocol has. We will be greatly increasing this when we start doing AI on the explore feeds and endpoints. If you integrate this API into your application you will be inheriting all of these improvements with no code changes.

πŸ“˜

Did You Know...

The publication id is not unique in the smart contract its a counter per each profile. So if @josh posts a publication that will be publication 1 for his profile and then if @jane posts a publication that will be publication 1 for her profile. Our backend generates what we call an InternalPublicationId which is built up from {profileId}-{publicationId} creating a unique ID that can be queried against our database. You will see that InternalPublicationId is used on all our responses and also used in any request you which to do.

Request

ExplorePublicationRequest

Invocation

import { ExplorePublicationsOrderByType } from "@lens-protocol/client";

const result = await client.explore.publications({
  orderBy: ExplorePublicationsOrderByType.Latest,
});
query ExplorePublications($request: ExplorePublicationRequest!) {
  explorePublications(request: $request) {
    items {
      ... on Post {
        ...Post
      }
      ... on Quote {
        ...Quote
      }
    }
    pageInfo {
      prev
      next
    }
  }
}

Response

Paginated result with Post or Quote

Full GraphQL API Example

πŸ“˜

Explore Publications: GraphQL API Full Example