❜embed SDK Quickstart
What you'll learn
The ❜embed SDK makes it easy to integrate real-time, personalized Web3 feeds into your app—without worrying about rate limits, retries, or boilerplate. You get access to the same powerful models that power discovery and ranking in the most advanced crypto-social experiences.
Let’s walk through how to install the SDK, fetch your first For You feed, and render it in your app.
Example
bun install @embed-ai/sdk
Now on the server side (think API Routes in case you're using NextJS) you can get your first feed with the SDK.
Before we call to get the feed, we'll create a client that exposes all the embed API functions we will need.
To get an API Key use the Console as described here: Getting started - your first feed
import { getClient } from "@embed-ai/sdk"
// using the API_KEY_EMBED environment variable
const key = process.env.API_KEY_EMBED!;
// get the embed sdk client with your API Key
const client = getClient(key);
The client allows you to call the API with the tedious work done for you. It has built in Error Handling and retries, so if a call fails it will retry automatically. To learn how to configure it, check the advanced tutorials. For now it's got that built in for you. No need to worry about one call failing and it not rendering a feed for your users.
Now using the client we can get a ForYou Feed. To get one we can choose between two SDK functions feed.byUserId
or feed.byWalletAddress
depending on us identifying users by wallet or Farcaster ID in our app. We'll go with Farcaster ID (FID).
Let's call that to get 10 recommended items for our for you feed.
import { getClient } from "@embed-ai/sdk"
// using the API_KEY_EMBED environment variable
const key = process.env.API_KEY_EMBED!;
// get the embed sdk client with your API Key
const client = getClient(key);
const feed = await client.feed.byUserId("16085", { top_k: 10 });
console.log(feed);
Output
In the console when running this sample you'll see something like:
{
item_id: "0x090100aef1befea80131644f4141e4a721ba795f",
popular_score: 17.577342335736414,
trending_score: 2.8533513701969966,
affinity_score: 0.36925925925925923,
following_engagement: [Object ...],
social_proof: [
[Object ...], [Object ...], [Object ...], [Object ...], [Object ...], [Object ...], [Object ...], [Object ...], [Object ...]
],
score: 0.36925925925925923,
source_feed: "main",
metadata: [Object ...],
},
This is one Feed Item. Since the feed returns an array of feed items you can iterate over the response and render the feed or feed it to an AI agent. Of course any other post processing is also possible. You get the raw scores of the recommendation engine to show the confidence interval that it's a great fit for your user in the score
property.
Going further
Now let's build a full scale application with a For You Feed:
Choose between building an AI Agent Develop AI Agents that leverage recommendations or a Farcaster Mini App Render a Feed in a Farcaster Mini App using React.
Updated 1 day ago