Guides

Recommended Profiles

Fetch recommended profiles to follow.

This method leverages the Lens Protocol ML engine to provide a list of recommended profiles to follow. You can disable ML by using the disableML parameter to receive a basic list of curated profiles.

Fetch Recommended Profiles

Request

  • for: ProfileId (required)
    • The profile id to fetch recommendations for
  • limit: number (optional)
    • The maximum number of profiles to fetch
  • cursor: number (optional)
    • The number of profiles to skip before fetching the first profile
  • disableML: boolean (optional)
    • Whether to disable the ML engine. Defaults to false.
  • shuffle: boolean (optional)
    • Whether to shuffle the results. Defaults to false.

Invocation

const result = await lensClient.profile.recommendations({
  for: "PROFILE_ID",
})
query ProfileRecommendations {
  profileRecommendations(request: { for: "PROFILE_ID" }) {
    items {
      ...Profile
    }
    pageInfo {
      ...PaginatedResultInfo
    }
  }
}

Response

A paginated result is returned where the items is an array of Profile.

{
  "items": [
    // list of Profiles
    {
      // Profile
    }
  ],
  "pageInfo": {
    // ...PaginatedResultInfo
  }
}

Dismiss Profile Recommendations

You can dismiss one or more profile recommendations to permanently omit a recommendation from the profile recommendations list.

Request

  • dismiss: ProfileId[] (required)
    • The profile ids to dismiss

Invocation

const result = await lensClient.profile.dismissRecommended({
  dismiss: ["PROFILE_ID"],
})
mutation DismissRecommendedProfiles {
  dismissRecommendedProfiles(request: { dismiss: ["PROFILE_ID"] })
}

Response

No response.


Full LensClient Example

// fetch recommendations for a profile id
const recommendedProfiles = await lensClient.profile.recommendations({
  for: "PROFILE_ID",
})

console.log(
  `Recommended profiles: `,
  recommendedProfiles.items.map((i) => ({ id: i.id, handle: i.handle }))
)

//  dismiss one of the recommendations
const recommendedProfileToDismiss = recommendedProfiles.items[0]
console.log(
  `Dismissing recommendation of profile: ${recommendedProfileToDismiss.id}`
)

await lensClient.profile.dismissRecommended({
  dismiss: [recommendedProfileToDismiss.id],
})

// and fetch recommendations again
const newRecommendedProfiles = await lensClient.profile.recommendations({
  for: "PROFILE_ID",
})

console.log(
  `Recommended profiles after dismissing: `,
  newRecommendedProfiles.items.map((i) => ({ id: i.id, handle: i.handle }))
)

Full GraphQL API Example

πŸ“˜

Profiles Recommendations: GraphQL API Full Example