Neynar

Products

Connect Farcaster

MCP server

npx @mintlify/mcp@latest add neynar

MCP setup guide & llms.txt are here

APIs

Integrate seamlessly with Farcaster using APIs, SDKs, hubs, and embedding tools for efficient development.

Backend APIs & SDKs\
Full suite of read and write APIs for easier application development

Embedded Conversations\
Show relevant casts and threads on webpages and in your apps

Fetch Social Graphs\
Fetch full list of followers and following users

Fetch user by address\
Fetches all users based on multiple Ethereum or Solana addresses

Snapchain Nodes\
Get raw data from Snapchain directly without needing to set up your own node

Accounts & auth

Streamline onboarding by creating accounts and enabling secure, easy-to-implement sign-in solutions.

// generate-required-parameters.js --> Filename

const {
  ID_REGISTRY_ADDRESS,
  ViemLocalEip712Signer,
  idRegistryABI,
} = require('@farcaster/hub-nodejs');

const { bytesToHex, createPublicClient, http } = require('viem');
const { mnemonicToAccount } = require('viem/accounts');
const { optimism } = require('viem/chains');

const publicClient = createPublicClient({
  chain: optimism,
  transport: http(),
});

const FID = 'FID_TO_COLLECT_SIGNATURE_FOR'; // fid returned from GET - /v2/farcaster/user/fid
const MNEMONIC = 'NEW_ACCOUNT_MNEMONIC';

const getDeadline = () => {
  const now = Math.floor(Date.now() / 1000);
  const oneHour = 60 * 60;
  return BigInt(now + oneHour);
};

(async () => {
  const deadline = getDeadline();
  console.log('\ndeadline: ', parseInt(deadline));
  const requestedUserAccount = mnemonicToAccount(MNEMONIC);

const requestedUserAccountSigner = new ViemLocalEip712Signer(
    requestedUserAccount
  );

let requestedUserNonce = await publicClient.readContract({
    address: ID_REGISTRY_ADDRESS,
    abi: idRegistryABI,
    functionName: 'nonces',
    args: [requestedUserAccount.address],
  });

let requestedUserSignature = await requestedUserAccountSigner.signTransfer({
    fid: BigInt(FID),
    to: requestedUserAccount.address,
    nonce: requestedUserNonce,
    deadline,
  });

console.log('\nsignature: ', bytesToHex(requestedUserSignature.value), '\n');
})();

AI agents

Streamline onboarding by creating accounts and enabling secure, easy-to-implement sign-in solutions.

Create AI agent

// notify.ts
import { NeynarClient } from '@neynar/nodejs-sdk';

const client = new NeynarClient(process.env.NEYNAR_API_KEY!);
const targetFids: number[] = []; // empty = all users who enabled notifications
const filters = {
  exclude_fids: [420, 69],
  following_fid: 3,
  minimum_user_score: 0.5,
};
const notification = {
  title: "Today's winner",
  body: "Tap to see the auction results",
  target_url: "https://your-frame.com/winner",
};
await client.publishFrameNotifications({ targetFids, filters, notification });

Data services

Access real-time data, stream events, and manage databases for advanced analytics and integrations.

SELECT
   ROW_NUMBER() OVER (ORDER BY COUNT(c.id) DESC) AS ranking,
   f.fid,
   'https://warpcast.com/' || fn.fname AS fname_link,
   COUNT(c.id) AS cast_count,
   pwa.verified_addresses,
   nus.score AS neynar_score
FROM
   fids f
LEFT JOIN
   casts c ON f.fid = c.fid AND c.deleted_at IS NULL
LEFT JOIN
   fnames fn ON f.fid = fn.fid
LEFT JOIN
   profile_with_addresses pwa ON f.fid = pwa.fid
LEFT JOIN LATERAL (
   SELECT score
   FROM neynar_user_scores
   WHERE fid = f.fid AND deleted_at IS NULL
   ORDER BY updated_at DESC
   LIMIT 1
) nus ON true
WHERE
   f.created_at >= CURRENT_DATE - INTERVAL '30' DAY
GROUP BY
   f.fid, fn.fname, pwa.verified_addresses, nus.score
ORDER BY
   cast_count DESC;

Webhooks

Deliver real-time notifications to your backend for dynamic and responsive applications.

Webhooks\
Get real-time Farcaster events delivered to your backend

UI Components

Plug and play social components

// Example installation
yarn add @neynar/react
import { NeynarProfileCard } from "@neynar/react";
<NeynarProfileCard fid={1} viewerFid={1} />;

Onchain social APIs

Enable blockchain features like verified addresses, token balances, and user scoring for secure onchain interactions.

Friends with the same token\
For any token contract, see most relevant holders for any user


Mini apps

Create mini-apps (formerly known as Farcaster frames) and keep users engaged with Push Notifications.

// Example initialization
npx @neynar/create-farcaster-mini-app