### Install Docker and Start Snapchain Node Source: https://docs.neynar.com/llms-full.txt Installs Docker and then bootstraps the Snapchain node by downloading and executing a setup script. Ensure you are in the desired directory before running. ```bash # Install docker curl -fsSL https://get.docker.com -o get-docker.sh chmod +x get-docker.sh ./get-docker.sh # Start Snapchain mkdir snapchain && cd snapchain curl -sSL https://raw.githubusercontent.com/farcasterxyz/snapchain/refs/heads/main/scripts/snapchain-bootstrap.sh | bash ``` -------------------------------- ### Neynar API Quickstart Source: https://docs.neynar.com/reference/quickstart This section outlines the initial steps to get started with the Neynar API, including obtaining an API key and making your first request. ```APIDOC ## Getting Started with Neynar API ### Description This guide helps you set up and make your first API call to Neynar. ### Steps 1. **Obtain an API Key**: Sign up on the Neynar website to get your API key. This key is essential for authenticating your requests. 2. **Make a Test Request**: Use a tool like `curl` or Postman to send a request to one of our endpoints. For example, fetching user information. ### Example Request (curl) ```bash curl -X GET \ 'https://api.neynar.com/v2/fun/alameda/get_user_by_fids?fids=1,2,3' \ -H 'accept: application/json' \ -H 'api_key: YOUR_API_KEY' ``` ### Important Notes - Replace `YOUR_API_KEY` with your actual Neynar API key. - The `fids` parameter accepts a comma-separated list of Farcaster User IDs (FIDs). - Ensure you have the latest version of `curl` installed. ### Next Steps - Explore the [REST API Reference](https://docs.neynar.com/reference) for a comprehensive list of available endpoints. - Refer to the [Rate Limits](https://docs.neynar.com/reference/what-are-the-rate-limits-on-neynar-apis) documentation to understand usage constraints. ``` -------------------------------- ### Install Docker and Start Snapchain Source: https://docs.neynar.com/snapchain/guides/running-a-node This script installs Docker, makes the installer executable, runs it, and then creates a directory for Snapchain and navigates into it. ```shell # Install docker curl -fsSL https://get.docker.com -o get-docker.sh chmod +x get-docker.sh ./get-docker.sh # Start Snapchain mkdir snapchain && cd snapchain ``` -------------------------------- ### Programmatic Webhook Setup Example Source: https://docs.neynar.com/farcaster/learn/contributing/overview Example demonstrating how to programmatically set up webhooks for receiving real-time Farcaster protocol events using the Neynar API. ```javascript import { NeynarAPIClient } from "@neynar/nodejs-sdk"; const neynarClient = new NeynarAPIClient(process.env.NEYNAR_API_KEY); async function setupWebhook() { const response = await neynarClient.createWebhook({ url: "https://your-app.com/webhooks/farcaster", eventType: "cast", // or "mention", "follow", etc. }); console.log(response); } setupWebhook(); ``` -------------------------------- ### Example API Call to Query Signups Source: https://docs.neynar.com/farcaster/developers/guides/advanced/query-signups Demonstrates how to make a GET request to the `/farcaster/user/signups` endpoint to retrieve signup data. Includes example parameters and expected response structure. ```javascript import { NeynarAPIClient } from "@neynar/nodejs-sdk"; const client = new NeynarAPIClient(process.env.NEYNAR_API_KEY); async function getSignups() { const response = await client.fetchCasts( "/farcaster/user/signups", { viewerFid: 100000, } ); console.log(response.data); } getSignups(); ``` -------------------------------- ### Clone and Run Example App Source: https://docs.neynar.com/docs/how-writes-to-farcaster-work-with-neynar-managed-signers Clone the example repository for managed signers and run the development server. This provides a quick start for integrating Neynar signers. ```bash npx degit https://github.com/neynarxyz/farcaster-examples/tree/main/managed-signers managed-signers cd managed-signers yarn yarn dev ``` -------------------------------- ### JavaScript Example Source: https://docs.neynar.com/reference/quickstart An example demonstrating how to make a GET request to the Neynar API using JavaScript's fetch API, including the required authentication header. ```APIDOC ## Examples ### JavaScript ```javascript fetch('https://api.neynar.com/v2/farcaster/user/bulk?fids=1', { method: 'GET', headers: { 'x-api-key': 'NEYNAR_API_KEY' } }) ``` ``` -------------------------------- ### Fetch Signers Example (Node.js) Source: https://docs.neynar.com/reference/fetch-signers This example demonstrates how to fetch signer information using the Neynar SDK in a Node.js environment. It includes setup for GitHub API requests and file system utilities. ```javascript require("fs"); const path = require("path"); /* ---------- Config ---------- */ const LOCAL_SDK_DIR = path.resolve(__dirname, "../../nodejs-sdk/src/api/apis"); const OUT_DIR = path.resolve(__dirname, "../nodejs-sdk"); const DOCS_JSON_PATH = path.resolve(__dirname, "../docs.json"); const GH_ROOT = "/repos/neynarxyz/nodejs-sdk/contents/src/api/apis"; /* ---------- HTTP helpers ---------- */ function ghHeaders() { const h = { "User-Agent": "nodejs", Accept: "application/vnd.github.v3+json", }; if (process.env.GITHUB_TOKEN) h.Authorization = `token ${process.env.GITHUB_TOKEN}`; return h; } function githubApiRequest(apiPath) { return new Promise((resolve, reject) => { https .get( { hostname: "api.github.com", path: apiPath, headers: ghHeaders() }, (res) => { let data = ""; res.on("data", (c) => (data += c)); res.on("end", () => { if (res.statusCode === 200) { try { resolve(JSON.parse(data)); } catch (e) { reject(e); } } else reject(new Error(`GitHub API error: ${res.statusCode} ${data}`)); }); } ) .on("error", reject); }); } function githubRawRequest(url) { return new Promise((resolve, reject) => { https .get(url, { headers: ghHeaders() }, (res) => { let data = ""; res.on("data", (c) => (data += c)); res.on("end", () => { if (res.statusCode === 200) resolve(data); else reject(new Error(`GitHub raw error: ${res.statusCode} ${data}`)); }); }) .on("error", reject); }); } async function checkRateLimit() { try { const resp = await new Promise((resolve, reject) => { https .get( "https://api.github.com/rate_limit", { headers: ghHeaders() }, (res) => { let data = ""; res.on("data", (c) => (data += c)); res.on("end", () => { try { resolve(JSON.parse(data)); } catch (e) { reject(e); } }); } ) .on("error", reject); }); const remaining = resp.rate?.remaining ?? 0; const reset = resp.rate?.reset ? new Date(resp.rate.reset * 1000) : null; return { remaining, reset }; } catch { return { remaining: 9999, reset: null }; } } /* ---------- FS utils ---------- */ function ensureDir(dir) { fs.mkdirSync(dir, { recursive: true }); } function hasLocalSdk() { try { return fs.statSync(LOCAL_SDK_DIR).isDirectory(); } catch { return false; } } function readLocalFilesRecursively(dir) { const out = []; for (const it of fs.readdirSync(dir, { withFileTypes: true })) { const p = path.join(dir, it.name); if (it.isDirectory()) out.push(...readLocalFilesRecursively(p)); else if (it.isFile() && p.endsWith(".ts")) out.push({ path: p, __local: true }); } return out; } async function fetchApiFilesFromGithub() { const out = []; async function recurse(apiPath) { const items = await githubApiRequest(apiPath); for (const it of items) { if (it.type === "dir") await recurse(`/repos/neynarxyz/nodejs-sdk/contents/${it.path}`); else if (it.type === "file" && it.name.endsWith(".ts")) out.push(it); } } await recurse(GH_ROOT); return out; } async function getFileContent(file) { return file.__local ? fs.readFileSync(file.path, "utf-8") : githubRawRequest(file.download_url); } /* ---------- tiny helpers ---------- */ const capitalize = (s) => (s ? s.charAt(0).toUpperCase() + s.slice(1) : s); const safeSlug = (s) => String(s) .toLowerCase() .replace(/[^a-z0-9]+/g, "-") .replace(/(^-|-$)/g, ""); const mdCode = (code, lang = "ts") => { const maxTicks = Math.max( 3, ...(code.match(/`+/g) || []).map((t) => t.length) ); return `${"`".repeat(maxTicks + 1)}${lang} ${code} ${"`".repeat( maxTicks + 1 )}`; }; /* ---------- Cross-linking helpers ---------- */ function camelCaseToKebabCase(str) { return str.replace(/[A-Z]/g, (match) => `-${match.toLowerCase()}`); } function findApiReferenceLink(methodName) { const kebabCase = camelCaseToKebabCase(methodName); const referencePath = path.resolve(__dirname, "../reference"); // Try exact match first const exactMatch = `${kebabCase}.mdx`; if (fs.existsSync(path.join(referencePath, exactMatch))) { return `/reference/${kebabCase}`; } // Try common variations const variations = [ kebabCase, kebabCase.replace(/^fetch-/, ''), kebabCase.replace(/^lookup-/, ''), kebabCase.replace(/^publish-/, ''), kebabCase.replace(/^delete-/, ''), kebabCase.replace(/^update-/, ''), kebabCase.replace(/^create-/, ''), ]; for (const variation of ``` -------------------------------- ### Fetch Nonce Example Source: https://docs.neynar.com/reference/fetch-nonce Demonstrates how to make a GET request to fetch a nonce. Ensure you have the correct API endpoint URL. ```javascript fetch("https://api.neynar.com/v2/fun/get-nonce?api_key=YOUR_API_KEY") .then(response => { if (!response.ok) { throw new Error(`HTTP error! status: ${response.status}`); } return response.json(); }) .then(data => { console.log("Nonce fetched successfully:", data.nonce); }) .catch(error => { console.error("Error fetching nonce:", error); }); ``` -------------------------------- ### Other SDKs - Go SDK Source: https://docs.neynar.com/snapchain/getting-started Getting started guide for the Go SDK. ```APIDOC ## Other SDKs - Go SDK ### Description Guide to getting started with the Go SDK for interacting with Neynar APIs. ### Documentation Link - `reference/getting-started-with-go-sdk` ``` -------------------------------- ### Initialize Project and Install SDK Source: https://docs.neynar.com/docs/how-to-create-webhooks-on-the-go-using-the-sdk Set up a new project directory and install the necessary Neynar Node.js SDK package using Bun. ```powershell mkdir webhooks-sdk cd webhooks-sdk bun init ``` ```powershell bun add @neynar/nodejs-sdk ``` -------------------------------- ### Other SDKs - Rust SDK Source: https://docs.neynar.com/snapchain/getting-started Getting started guide for the Rust SDK. ```APIDOC ## Other SDKs - Rust SDK ### Description Guide to getting started with the Rust SDK for interacting with Neynar APIs. ### Documentation Link - `reference/getting-started-with-rust-sdk` ``` -------------------------------- ### Setup Project Directory Source: https://docs.neynar.com/docs/auth-address-signature-generation Create and navigate into a new directory for your project. This is an optional step if you already have a project set up. ```shellscript mkdir signed-key-request cd signed-key-request ``` -------------------------------- ### Batch Get Token Metadata Example Source: https://docs.neynar.com/reference/batch-get-token-metadata This example demonstrates how to use the Batch Get Token Metadata API to retrieve information for a list of token IDs. Ensure you have the necessary API key and client setup. ```javascript require("fs"); const path = require("path"); /* ---------- Config ---------- */ const LOCAL_SDK_DIR = path.resolve(__dirname, "../../nodejs-sdk/src/api/apis"); const OUT_DIR = path.resolve(__dirname, "../nodejs-sdk"); const DOCS_JSON_PATH = path.resolve(__dirname, "../docs.json"); const GH_ROOT = "/repos/neynarxyz/nodejs-sdk/contents/src/api/apis"; /* ---------- HTTP helpers ---------- */ function ghHeaders() { const h = { "User-Agent": "nodejs", Accept: "application/vnd.github.v3+json", }; if (process.env.GITHUB_TOKEN) h.Authorization = `token ${process.env.GITHUB_TOKEN}`; return h; } function githubApiRequest(apiPath) { return new Promise((resolve, reject) => { https .get( { hostname: "api.github.com", path: apiPath, headers: ghHeaders() }, (res) => { let data = ""; res.on("data", (c) => (data += c)); res.on("end", () => { if (res.statusCode === 200) { try { resolve(JSON.parse(data)); } catch (e) { reject(e); } } else reject(new Error(`GitHub API error: ${res.statusCode} ${data}`)); }); } ) .on("error", reject); }); } function githubRawRequest(url) { return new Promise((resolve, reject) => { https .get(url, { headers: ghHeaders() }, (res) => { let data = ""; res.on("data", (c) => (data += c)); res.on("end", () => { if (res.statusCode === 200) resolve(data); else reject(new Error(`GitHub raw error: ${res.statusCode} ${data}`)); }); }) .on("error", reject); }); } async function checkRateLimit() { try { const resp = await new Promise((resolve, reject) => { https .get( "https://api.github.com/rate_limit", { headers: ghHeaders() }, (res) => { let data = ""; res.on("data", (c) => (data += c)); res.on("end", () => { try { resolve(JSON.parse(data)); } catch (e) { reject(e); } }); } ) .on("error", reject); }); const remaining = resp.rate?.remaining ?? 0; const reset = resp.rate?.reset ? new Date(resp.rate.reset * 1000) : null; return { remaining, reset }; } catch { return { remaining: 9999, reset: null }; } } /* ---------- FS utils ---------- */ function ensureDir(dir) { fs.mkdirSync(dir, { recursive: true }); } function hasLocalSdk() { try { return fs.statSync(LOCAL_SDK_DIR).isDirectory(); } catch { return false; } } function readLocalFilesRecursively(dir) { const out = []; for (const it of fs.readdirSync(dir, { withFileTypes: true })) { const p = path.join(dir, it.name); if (it.isDirectory()) out.push(...readLocalFilesRecursively(p)); else if (it.isFile() && p.endsWith(".ts")) out.push({ path: p, __local: true }); } return out; } async function fetchApiFilesFromGithub() { const out = []; async function recurse(apiPath) { const items = await githubApiRequest(apiPath); for (const it of items) { if (it.type === "dir") await recurse(`/repos/neynarxyz/nodejs-sdk/contents/${it.path}`); else if (it.type === "file" && it.name.endsWith(".ts")) out.push(it); } } await recurse(GH_ROOT); return out; } async function getFileContent(file) { return file.__local ? fs.readFileSync(file.path, "utf-8") : githubRawRequest(file.download_url); } /* ---------- tiny helpers ---------- */ const capitalize = (s) => (s ? s.charAt(0).toUpperCase() + s.slice(1) : s); const safeSlug = (s) => String(s) .toLowerCase() .replace(/[^a-z0-9]+/g, "-") .replace(/(^-|-$)/g, ""); const mdCode = (code, lang = "ts") => { const maxTicks = Math.max( 3, ...(code.match(/`+/g) || []).map((t) => t.length) ); return `${"`".repeat(maxTicks + 1)}${lang} ${code} ${"`".repeat( maxTicks + 1 )}`; }; /* ---------- Cross-linking helpers ---------- */ function camelCaseToKebabCase(str) { return str.replace(/[A-Z]/g, (match) => `-${match.toLowerCase()}`); } function findApiReferenceLink(methodName) { const kebabCase = camelCaseToKebabCase(methodName); const referencePath = path.resolve(__dirname, "../reference"); // Try exact match first const exactMatch = `${kebabCase}.mdx`; if (fs.existsSync(path.join(referencePath, exactMatch))) { return `/reference/${kebabCase}`; } // Try common variations const variations = [ kebabCase, kebabCase.replace(/^fetch-/, ''), kebabCase.replace(/^lookup-/, ''), kebabCase.replace(/^publish-/, ''), kebabCase.replace(/^delete-/, ''), kebabCase.replace(/^update-/, ''), kebabCase.replace(/^create-/, ''), ]; for (const variation of ``` -------------------------------- ### Start the server using npm, yarn, or pnpm Source: https://docs.neynar.com/docs/sign-in-with-neynar-react-native-implementation After setting up your environment variables, start the development server using your preferred package manager. This command initiates the application and makes it ready for testing. ```text npm run start ``` ```text yarn start ``` ```text pnpm start ``` -------------------------------- ### Clone the React Native Sign in with Neynar Example Source: https://docs.neynar.com/docs/sign-in-with-neynar-react-native-implementation Clone the official example repository to get started with the React Native implementation of Sign in with Neynar. This repository contains all the necessary code and configurations. ```shellscript git clone https://github.com/neynarxyz/farcaster-examples/tree/main/wownar-react-native cd react-native-siwn ``` -------------------------------- ### Full Farcaster Account Key Creation Example Source: https://docs.neynar.com/farcaster/developers/guides/accounts/create-account-key A comprehensive example demonstrating the setup of Viem clients, local accounts, and the complete process of registering an app FID and adding an account key for a user. ```typescript import * as ed from '@noble/ed25519'; import { ID_GATEWAY_ADDRESS, ID_REGISTRY_ADDRESS, ViemLocalEip712Signer, idGatewayABI, idRegistryABI, NobleEd25519Signer, KEY_GATEWAY_ADDRESS, keyGatewayABI, } from '@farcaster/hub-nodejs'; import { bytesToHex, createPublicClient, createWalletClient, http } from 'viem'; import { privateKeyToAccount } from 'viem/accounts'; import { optimism } from 'viem/chains'; const APP_PRIVATE_KEY = '0x00'; const ALICE_PRIVATE_KEY = '0x00'; /******************************************************************************* * Setup - Create local accounts, Viem clients, helpers, and constants. *******************************************************************************/ /** * Create Viem public (read) and wallet (write) clients. */ const publicClient = createPublicClient({ chain: optimism, transport: http(), }); const walletClient = createWalletClient({ chain: optimism, transport: http(), }); /** * A local account representing your app. You'll * use this to sign key metadata and send * transactions on behalf of users. */ const app = privateKeyToAccount(APP_PRIVATE_KEY); const appAccountKey = new ViemLocalEip712Signer(app as any); console.log('App:', app.address); /** * A local account representing Alice, a user. */ const alice = privateKeyToAccount(ALICE_PRIVATE_KEY); const aliceAccountKey = new ViemLocalEip712Signer(alice as any); console.log('Alice:', alice.address); /** * Generate a deadline timestamp one hour from now. * All Farcaster EIP-712 signatures include a deadline, a block timestamp * after which the signature is no longer valid. */ const deadline = BigInt(Math.floor(Date.now() / 1000) + 3600); // Set the signatures' deadline to 1 hour from now const FARCASTER_RECOVERY_PROXY = '0x00000000FcB080a4D6c39a9354dA9EB9bC104cd7'; /******************************************************************************* * IdGateway - register - Register an app FID. *******************************************************************************/ /** * Get the current price to register. We're not going to register any * extra storage, so we pass 0n as the only argument. */ const price = await publicClient.readContract({ address: ID_GATEWAY_ADDRESS, abi: idGatewayABI, functionName: 'price', args: [0n], }); /** * Call `register` to register an FID to the app account. */ const { request } = await publicClient.simulateContract({ account: app, address: ID_GATEWAY_ADDRESS, abi: idGatewayABI, functionName: 'register', args: [FARCASTER_RECOVERY_PROXY, 0n], value: price, }); await walletClient.writeContract(request); /** * Read the app FID from the Id Registry contract. */ const APP_FID = await publicClient.readContract({ address: ID_REGISTRY_ADDRESS, abi: idRegistryABI, functionName: 'idOf', args: [app.address], }); /******************************************************************************* * KeyGateway - addFor - Add an account key to Alice's FID. *******************************************************************************/ /** * To add an account key to Alice's FID, we need to follow four steps: * * 1. Create a new account key pair for Alice. * 2. Use our app account to create a Signed Key Request. * 3. Collect Alice's `Add` signature. * 4. Call the contract to add the key onchain. */ ``` -------------------------------- ### Mini Apps Source: https://docs.neynar.com/snapchain/httpapi/message Documentation for building and distributing Mini Apps on the Farcaster platform, covering introduction, getting started, and various guides. ```APIDOC ## Why Mini Apps? ### Description Learn about the benefits and purpose of building Mini Apps for Farcaster users. ### Content This section explains why developers should consider building Mini Apps and the value they bring to the Farcaster ecosystem. ### Related Pages - Getting Started - Guides ``` ```APIDOC ## Getting Started with Mini Apps ### Description Provides the initial steps and requirements for developers to begin building Mini Apps. ### Content This guide covers the essential setup and prerequisites for developing Farcaster Mini Apps. ### Related Pages - Why Mini Apps? - Guides ``` ```APIDOC ## Loading Your Mini App ### Description Guide on how to implement a smooth loading experience for your Mini App, including splash screens. ### Content Learn techniques to ensure users have a seamless transition from the Farcaster interface into your Mini App. ### Related Pages - Getting Started - Sharing Your App ``` ```APIDOC ## Sharing Your Mini App ### Description Instructions on how to make your Mini App easily shareable within Farcaster social feeds. ### Content This guide focuses on optimizing your Mini App for social sharing and discoverability. ### Related Pages - Loading Your App - Publishing Your App ``` ```APIDOC ## Interacting with Ethereum Wallets ### Description Guidance on how your Mini App can seamlessly interact with a user's Ethereum wallet. ### Content Learn the necessary steps and best practices for integrating Ethereum wallet functionalities into your Mini App. ### Related Pages - Solana Wallets - Getting Started ``` ```APIDOC ## Interacting with Solana Wallets ### Description Guidance on how your Mini App can seamlessly interact with a user's Solana wallet. ### Content Learn the necessary steps and best practices for integrating Solana wallet functionalities into your Mini App. ### Related Pages - Ethereum Wallets - Getting Started ``` ```APIDOC ## Publishing Your Mini App ### Description A comprehensive guide to the process of publishing your Farcaster Mini App. ### Content This section details the steps, requirements, and considerations for making your Mini App available to Farcaster users. ### Related Pages - Sharing Your App - App Discovery & Distribution ``` -------------------------------- ### SIWN Integration Guide Source: https://docs.neynar.com/docs/how-to-let-users-connect-farcaster-accounts-with-write-access-for-free-using-sign-in-with-neynar-siwn Provides a guide on how to integrate SIWN, including an example integration with a sample application on GitHub and a live demo. It also details the initial setup required in the Neynar developer portal. ```mdx ## How to integrate SIWN? ### Example integration Check out this sample application ([github](https://github.com/neynarxyz/farcaster-examples/tree/main/wownar)) that integrates Sign in with Neynar and allows users to cast. A live demo of this exact code has been deployed at [https://demo.neynar.com](https://demo.neynar.com) ### Step 0: Set up your app in the Neynar developer portal Go to the [Neynar Developer Portal](https://dev.neynar.com) settings tab and update the following 1. **Name -** Displayed to the user in Step 3. 2. **Logo URL** - Displayed to the user in Step 3. Use a PNG or SVG format. 3. **Authorized origins** - Authorized origins are the HTTP origins that host your web application. e.g. ``` -------------------------------- ### Set up Viem Clients and Account Key Source: https://docs.neynar.com/farcaster/developers/guides/accounts/create-account-key This snippet demonstrates setting up Viem clients and an account key. It uses Viem local accounts and account keys, but can be adapted to use ViemWalletEip712Signer for connecting to a user's wallet. ```typescript import { createWalletClient, http, Hex } from "viem"; import { privateKeyToAccount } from "viem/accounts"; import { optimism } from "viem/chains"; const privateKey = process.env.PRIVATE_KEY as Hex; const rpcUrl = process.env.RPC_URL as string; const account = privateKeyToAccount(privateKey); const client = createWalletClient({ account, chain: optimism, transport: http(rpcUrl), }); console.log("Client created:", client); ``` -------------------------------- ### Farcaster Developers - Create Mini Apps Source: https://docs.neynar.com/farcaster/developers/index This section provides links to resources for building mini apps on Farcaster. It includes an introduction and a getting started guide. ```javascript if (!Heading) _missingMdxReference("Heading", true);\n if (!Tip) _missingMdxReference("Tip", true);\n return _jsxs(_Fragment, {\n children: [_jsx(Tip, {\n children: _jsxs(_components.p, {\n children: [_jsx(_components.strong, {\n children: \ ``` -------------------------------- ### Initialize Neynar Client Source: https://docs.neynar.com/docs/getting-storage-units-allocation-of-farcaster-user Initialize the Neynar client with your API key. Ensure you have followed the 'Getting Started' guide to set up your environment and obtain an API key. ```javascript import { NeynarAPIClient } from "@neynar/nodejs-sdk"; const client = new NeynarAPIClient(process.env.NEYNAR_API_KEY); async function getStorageAllocation(fid) { const storageAllocation = await client.lookupUserStorageAllocations(fid); return storageAllocation; } const fid = 12345; // Replace with the target user's FID getStorageAllocation(fid).then(console.log); ``` -------------------------------- ### Initialize Project Directory with Go Modules Source: https://docs.neynar.com/llms-full.txt Sets up a new Go project directory and initializes it with go modules. Ensure Go is installed before running. ```bash mkdir get-started-with-neynar-go-sdk cd get-started-with-neynar-go-sdk go mod init getting_started ``` -------------------------------- ### Fetch Trending Fungibles Example Source: https://docs.neynar.com/nodejs-sdk/onchain-apis/fetchTrendingFungibles Demonstrates how to call the `fetchTrendingFungibles` method to get a list of trending fungible tokens. Ensure you have the necessary SDK setup and authentication. ```javascript import { NeynarAPIClient } from "@neynar/nodejs-sdk"; const client = new NeynarAPIClient(process.env.NEYNAR_API_KEY); async function getTrendingFungibles() { const response = await client.fetchTrendingFungibles({ // Optional: Specify a fid to get personalized trending data // viewerFid: 12345, }); console.log(response.data.result.tokens); } getTrendingFungibles(); ``` -------------------------------- ### Initialize Project Source: https://docs.neynar.com/docs/auth-address-signature-generation Creates a new project directory and initializes npm. ```bash mkdir signed-key-request cd signed-key-request npm init -y ``` -------------------------------- ### Setup Clients and Account Keys Source: https://docs.neynar.com/farcaster/developers/guides/writing/verify-address Initializes necessary clients and account keys for signing verification messages. Requires importing specific modules from `@farcaster/hub-nodejs` and `viem`. ```typescript import { NobleEd25519Signer, ViemLocalEip712Signer, FarcasterNetwork, makeVerificationAddEthAddress, } from '@farcaster/hub-nodejs'; import { createPublicClient, http } from 'viem'; import { privateKeyToAccount } from 'viem/accounts'; import { optimism } from 'viem/chains'; const publicClient = createPublicClient({ chain: optimism, transport: http(), }); const alice = privateKeyToAccount('0xab..12'); const eip712Signer = new ViemLocalEip712Signer(alice); const ed25519Signer = new NobleEd25519Signer('0xcd..34'); ``` -------------------------------- ### Batch Get Token Metadata with Neynar Node.js SDK Source: https://docs.neynar.com/nodejs-sdk/onchain-apis/batchGetTokenMetadata Import the NeynarAPIClient and Configuration, then instantiate the client to make requests. This example shows the basic setup for batch token metadata retrieval. ```typescript import { NeynarAPIClient, Configuration } from "@neynar/nodejs-sdk"; const configuration = new Configuration({ apiKey: "YOUR_API_KEY", }); const client = new NeynarAPIClient(configuration); const response = await client.batchGetTokenMetadata({ // Required: Array of token IDs to fetch metadata for. tokenIds: ["1-0x123", "1-0x456"], // Optional: Specify the viewer's FID to respect mutes/blocks and include viewer context. viewerFid: 12345, }); console.log(response); ``` -------------------------------- ### Running the Application with Different Package Managers Source: https://docs.neynar.com/docs/sign-in-with-neynar-react-native-implementation These commands show how to start your application using yarn, pnpm, or bun. Ensure you have the respective package manager installed. ```text yarn start ``` ```text pnpm run start ``` ```text bun run start ``` -------------------------------- ### Get Transaction Pay Frame Example Source: https://docs.neynar.com/reference/get-transaction-pay-frame This snippet demonstrates how to call the `getTransactionPayFrame` method. It requires a `txHash` and optionally accepts `viewerFid` for personalized context. Ensure you have the necessary SDK or client setup. ```javascript import { NeynarAPIClient } from "@neynar/nodejs-sdk"; const client = new NeynarAPIClient(process.env.NEYNAR_API_KEY); async function getPayFrame() { const txHash = "0x..."; // Replace with your transaction hash const viewerFid = 123; // Optional: Replace with viewer's FID try { const response = await client.fetchTransactionPayFrame(txHash, { viewerFid: viewerFid, }); console.log(response); return response; } catch (error) { console.error("Error fetching transaction pay frame:", error); throw error; } } getPayFrame(); ``` -------------------------------- ### Install Quick Auth Library for Backend Source: https://docs.neynar.com/miniapps/sdk/quick-auth Install the Quick Auth library into your backend using npm. ```bash npm install @farcaster/quick-auth ``` -------------------------------- ### Getting Started with Go SDK Source: https://docs.neynar.com/farcaster/reference Provides instructions and guidance on how to get started with the Go SDK for Farcaster development. ```APIDOC ## Go SDK - Getting Started ### Description Provides instructions and guidance on how to get started with the Go SDK for Farcaster development. ### Usage Refer to the official documentation for detailed setup and usage examples. ``` -------------------------------- ### Initialize Project Directory Source: https://docs.neynar.com/llms-full.txt Create a new directory for your project and navigate into it. This is the first step in setting up your development environment. ```bash mkdir get-started-with-neynar-sdk cd get-started-with-neynar-sdk ``` -------------------------------- ### Start the Server Source: https://docs.neynar.com/docs/sign-in-with-neynar-react-native-implementation Start the server process using your package manager. This command initiates the backend service for the application. ```text npm run start ``` ```text yarn start ``` ```text pnpm run start ``` ```text bun run start ``` -------------------------------- ### Getting Started with Rust SDK Source: https://docs.neynar.com/farcaster/reference Provides instructions and guidance on how to get started with the Rust SDK for Farcaster development. ```APIDOC ## Rust SDK - Getting Started ### Description Provides instructions and guidance on how to get started with the Rust SDK for Farcaster development. ### Usage Refer to the official documentation for detailed setup and usage examples. ``` -------------------------------- ### Get Channel Restricted Users Response Example Source: https://docs.neynar.com/llms-full.txt This JSON structure illustrates an example response for the GET /fc/channel-restricted-users endpoint, listing users restricted from channel invites. ```json { "result": { "restrictedUsers": [ { "fid": 1234, "channelId": "welcome", "restrictedAt": 1727767637 }, ... ] }, "next": { "cursor": "..." } } ``` -------------------------------- ### Start Video Recording with Permissions Source: https://docs.neynar.com/llms-full.txt This example demonstrates how to first request camera and microphone permissions, then use `navigator.mediaDevices.getUserMedia` to access the stream for video recording. It includes specific error handling for permission denials. ```typescript import { sdk } from '@farcaster/miniapp-sdk' async function startVideoRecording() { try { // Request permissions first await sdk.actions.requestCameraAndMicrophoneAccess() // Now you can access getUserMedia const stream = await navigator.mediaDevices.getUserMedia({ video: true, audio: true }) // Use the stream for video recording const videoElement = document.querySelector('video') if (videoElement) { videoElement.srcObject = stream } } catch (error) { if (error instanceof Error && error.name === 'NotAllowedError') { // Permissions were denied alert('Camera and microphone access is required for video recording') } else { console.error('Failed to start recording:', error) } } } ``` -------------------------------- ### Get Cast Moderation Actions Response Example Source: https://docs.neynar.com/llms-full.txt This JSON structure shows an example response for the GET /fc/moderated-casts endpoint, detailing moderation actions applied to casts. ```json { "result": { "moderationActions": [ { "castHash": "0x6b2253105ef8c1d1b984a5df87182b105a1f0b3a", "channelId": "welcome", "action": "hide", "moderatedAt": 1727767637 }, ... ] }, "next": { "cursor": "..." } } ``` -------------------------------- ### Initialize Mini App SDK Source: https://docs.neynar.com/docs/convert-web-app-to-mini-app Alternatively, you can install the Mini App SDK directly and initialize it by calling `sdk.actions.ready()`. This provides a more direct integration if you don't need the full @neynar/react package. ```javascript import { sdk } from "@farcaster/miniapp-sdk"; // ... await sdk.actions.ready(); ``` -------------------------------- ### Batch Get Token Metadata Example Source: https://docs.neynar.com/nodejs-sdk/onchain-apis/batchGetTokenMetadata Example of how to use the batchGetTokenMetadata API to fetch metadata for multiple ERC-721 tokens. ```APIDOC ## GET /v2/farcaster/token/metadata/batch ### Description Retrieves metadata for a list of ERC-721 tokens. ### Method GET ### Endpoint /v2/farcaster/token/metadata/batch ### Parameters #### Query Parameters - **token_ids** (string) - Required - Comma-separated list of token IDs. - **address** (string) - Required - The contract address of the ERC-721 token. ### Request Example ``` GET /v2/farcaster/token/metadata/batch?address=0x1a0c23111571733071763a212732340000000000&token_ids=1,2,3 ``` ### Response #### Success Response (200) - **result** (object) - Contains the metadata for the requested tokens. - **tokens** (array) - An array of token metadata objects. - **tokenId** (string) - The ID of the token. - **name** (string) - The name of the token. - **symbol** (string) - The symbol of the token. - **attributes** (array) - An array of token attributes. - **trait_type** (string) - The type of the attribute. - **value** (string) - The value of the attribute. - **imageUrl** (string) - The URL of the token's image. - **originalContent** (object) - The original content of the token metadata. - **contentUrl** (string) - The URL of the original content. #### Response Example ```json { "result": { "tokens": [ { "tokenId": "1", "name": "My NFT 1", "symbol": "MNFT", "attributes": [ { "trait_type": "Color", "value": "Red" } ], "imageUrl": "https://example.com/image1.png", "originalContent": { "contentUrl": "https://example.com/metadata1.json" } }, { "tokenId": "2", "name": "My NFT 2", "symbol": "MNFT", "attributes": [ { "trait_type": "Color", "value": "Blue" } ], "imageUrl": "https://example.com/image2.png", "originalContent": { "contentUrl": "https://example.com/metadata2.json" } } ] } } ``` ``` -------------------------------- ### Setup Clients and Account Keys Source: https://docs.neynar.com/farcaster/developers/guides/writing/verify-address Initialize necessary signers and clients for creating a verification message. Ensure you have write access to a Snapchain instance and the private key of a registered account. ```typescript import { NobleEd25519Signer, ViemLocalEip712Signer, FarcasterNetwork, makeVerificationAddEthAddress, } from '@farcaster/hub-nodejs'; import { createPublicClient, http } from 'viem'; import { privateKeyToAccount } from 'viem/accounts'; import { optimism } from 'viem/chains'; const publicClient = createPublicClient({ chain: optimism, transport: http(), }); const alice = privateKeyToAccount('0xab..12'); const eip712Signer = new ViemLocalEip712Signer(alice); const ed25519Signer = new NobleEd25519Signer('0xcd..34'); ```