Guides

Third Party APIs and Recommendation Algorithms

One of the powerful things about web3 social protocols like Lens is that, because all of the data and interaction history is public, developers and teams can build their own custom recommendation and ranking algorithms based on on-chain data.

While Lens offers an array of APIs through the Lens GraphQL API, there are also other options that you can choose to incorporate in your application.

Karma3

Karma3 is an open protocol that enables developers to curate ranking and recommendation systems for their apps based on on-chain data. This can power personalized search, discovery and recommendation for Lens apps.

Karma3 Lens Documentation

Karma3 API Explorer

Profile APIs

All profiles in the Lens ecosystem are scored and ranked every hour. The scores and rankings are then made available through different APIs that clients can call depending on their use case.

These APIs are based on 4 different scoring strategies.

Followship - This strategy emphasizes on social engagements as attestations, combining follows, mirrors and comments. The more engagements a profile receives for their posts and profiles, this will result in higher profile scores.

Engagement - This strategy emphasizes on social engagements as attestations, combining follows, mirrors and comments. The more engagements a profile receives for their posts and profiles, this will result in higher profile scores.

Influencer - Similar to the engagement strategy, combining follows, mirrors and comments interactions (or attestations) between profiles, but adds another datapoint where posts can be turned into NFT collections by influencers. When these NFTs are collected by others, these are strong signals of a reputable profile.

Creator - Similar to the influencer strategy, we add another datapoint where NFT collections that carry a price tag. These become another strong indicator where an influencer has gained a strong following that NFT mints of posts reflect popular amongst a fan base in a creator economy.

The available Profile APIs are available here.

Content APIs

There are also a collection of feed algorithms which are designed to provide users with relevant and personalized content suggestions. You can choose the algorithms that best fit your needs and audience.

There are two types of feed algorithms:

Global Feed

Retrieve general purpose global content feed, using several strategies

  • /feed/recent to choose the Recent algorithm.
  • /feed/popular to explicitly choose the Popular algorithm.
  • /feed/recommended to choose the Recommended algorithm.
  • /feed/crowdsourced to choose the Crowdsourced algorithm.

Personalized Feed

Personalized content feed algorithms are meant to generate lists of posts that are most relevant to each user. These algorithms crawl a user's social graph and activity when recommending posts. There's a time decay element in this as well.

  • /feed/personal/{profile}/ following which uses the Following algorithm.

The available content APIs are available here.

Airstack

Airstack is an API provider for blockchain and web3 applications.

With Airstack you can access things like general on-chain transactions, dapp-specific events, and NFT marketplace data as well as simultaneously query and combine on-chain and off-chain data.

Airstack leverages GraphQL which allows you to get only the data you require in single query vs traditional REST endpoints which return a predefined set of data.

Developers can get started with Airstack by following the quickstart guide here.

To use the Airstack API, you must first get and API key. You also mush include the api key in the header for authorization. You can view your Airstack API key here.

APIs

Recommendation Engines

This API allows you to get recommended followers for Lens profiles based on on-chain insights from token transfers, POAPs, NFTS, and token holder combinations.

Universal Resolver

The Airstack Universal Resolver allows you to universally resolve and reverse resolve Lens Profiles to other web3 identities (Farcaster, ENS, Ethereum address). For instance, you can get Lens Profiles from a given user, or get the Ethereum address, Farcaster, and ENS from a given Lens profile.

Identity API

The Airstack Identity API allows you to use a Lens profile to query for on-chain data, aggregations, and transactions.

Tokens in common

The Tokens in Common API enables you to fetch ERC20, NFTs, or POAPs in common from two Lens users.

Has XMTP

The Has XMTP API allows you to check if Lens profiles have XMTP enabled on their account or not.

Tokenbound ERC6551 Accounts

The Tokenbound ERC6551 Accounts API allows you to get ERC6551 Accounts owned By Lens profile(s) and get assets owned by ERC6551 Accounts of a Lens profile.

Token Gating

This API enables users to access certain features only if they have a Lens profile or a combination of Lens + other criteria such as a specific POAP or NFT.

MadFi

Based on their ML tagging, get a list of recommended profiles for the given profile to follow.

To use the MadFi API, you must first get and API key. You also must include the api key in the header for x-api-key

APIs

Suggested Follows API. For a given profileId, return a list of recommended profiles that have the same ML tags.

  • https://api.madfinance.xyz/suggested_follows?profileId=0x123

MadFI API Key

For an API key, email them at [email protected]