Build a Frame with Dune API
How to build a Farcaster Frame using Frog and Dune API
This guide provides a step-by-step process on using typescript and Dune API to create a user recommendation frame for Farcaster. You can find a live example of the frame here. The youtube video below walks through it in detail:
Set up your environment with the example repo
Fork this repo and then run npm install -g frog
and npm install
to get all your packages. If you don’t have npm set up, then go download node js first. Once installations are finished, try running npm run dev
and it should take you to a localhost environment at http://localhost:5173/api.
Next, you’ll need to get a Dune API key from your user settings and set it in an .env
file. With that done, you’ll be able to run the frame - click “See From Your Followers” in your localhost environment.
Explaining the Dune API function
We call the Dune API in the /api/dune.ts
file in the getRecommendations(fid)
function defined here.
Below is the main API call, which makes a FILTER call on an existing result set. Using filters, we get our results in 20-30ms instead of reruning the whole query (which may take 10-20 seconds).
You can write your own aggregation queries in the same format, and then use filters to make the API fast enough for app/frame development. Good luck!
Was this page helpful?