Farcaster Skill (Neynar v2)
All scripts use the Neynar v2 REST API. Requires curl and jq.
Setup
Set these env vars (or pass --api-key / --signer flags):
CODEBLOCK0
Alternatively, put credentials in a JSON file and source them:
CODEBLOCK1
Scripts
fc_cast.sh — Post a Cast
Post text, with optional embeds, channel, or reply-to.
CODEBLOCK2
Output: JSON {success, hash}.
fc_feed.sh — Read Feeds
CODEBLOCK3
Output: JSON array of casts with {hash, author, text, timestamp, embeds, reactions, replies}.
fc_user.sh — User Lookup
CODEBLOCK4
Output: JSON user object(s) with {fid, username, display_name, bio, follower_count, following_count, verified_addresses}.
fc_search.sh — Search Casts
CODEBLOCK5
Output: JSON array of matching casts.
fc_react.sh — Like / Recast
CODEBLOCK6
fc_delete.sh — Delete a Cast
CODEBLOCK7
fc_channels.sh — List and Search Channels
CODEBLOCK8
Common Patterns
Thread a multi-cast announcement
CODEBLOCK9
Monitor mentions (poll loop)
CODEBLOCK10
Post with media (upload first, then embed)
CODEBLOCK11
Free vs Paid Tier
Not all endpoints are available on Neynar's free plan.
| Feature | Script | Free? |
|---|
| Post cast | fccast.sh | ✅ |
| User casts feed |
fcfeed.sh --fid | ✅ |
| User lookup (username/FID/address) | fc_user.sh | ✅ |
| Like / recast | fc_react.sh | ✅ |
| Following feed | fc_feed.sh --following | ✅ |
| Channel feed | fc_feed.sh --channel | ❌ Paid |
| Cast search | fc_search.sh | ❌ Paid |
| Channel search/details/trending | fc_channels.sh | ❌ Paid |
| Delete cast | fc_delete.sh | ❌ Paid |
| Thread/conversation | fc_feed.sh --thread | ✅ |
Scripts that hit paid endpoints will exit non-zero with a clear 402 PaymentRequired error.
Error Handling
All scripts exit 0 on success, non-zero on failure. Errors print to stderr as JSON:
CODEBLOCK12
Common errors:
- -
401 — Invalid API key - INLINECODE9 — Feature requires paid Neynar plan
- INLINECODE10 — Signer not approved or not paired with API key
- INLINECODE11 — Cast/user/channel not found
- INLINECODE12 — Rate limited (Neynar free tier: 300 req/min)
API Reference
See references/neynar_endpoints.md for the full endpoint list and parameter docs.
Farcaster 技能(Neynar v2)
所有脚本均使用 Neynar v2 REST API。需要 curl 和 jq。
设置
设置以下环境变量(或传递 --api-key / --signer 参数):
bash
export NEYNARAPIKEY=your-api-key
export NEYNARSIGNERUUID=your-signer-uuid # 写操作必需
或者,将凭据放入 JSON 文件并引用:
bash
eval $(jq -r export NEYNARAPIKEY=\(.apiKey)\nexport NEYNARSIGNERUUID=\(.signerUuid) /path/to/neynar.json)
脚本
fc_cast.sh — 发布 Cast
发布文本,可附带嵌入、频道或回复。
bash
简单文本 cast
scripts/fc_cast.sh --text 你好 Farcaster!
带图片/视频嵌入的 cast
scripts/fc_cast.sh --text 看看这个 --embed https://example.com/image.png
带两个嵌入(最多 2 个)
scripts/fc_cast.sh --text 链接 --embed https://a.com --embed https://b.com
发布到频道
scripts/fc_cast.sh --text gm --channel base
回复 cast
scripts/fc_cast.sh --text 好观点! --parent 0xabcdef1234...
引用 cast(嵌入另一个 cast)
scripts/fc_cast.sh --text 这个 👆 --embed-cast 0xabcdef1234... --embed-cast-fid 12345
输出:JSON {success, hash}。
fc_feed.sh — 读取信息流
bash
按 FID 获取用户 cast
scripts/fc_feed.sh --fid 3 --limit 10
按用户名获取用户 cast
scripts/fc_feed.sh --username vitalik --limit 5
频道信息流
scripts/fc_feed.sh --channel base --limit 10
关注信息流(签名者关注的人的 cast)
scripts/fc_feed.sh --following --fid 3 --limit 10
Cast 回复/线程
scripts/fc_feed.sh --thread 0xabcdef...
带游标的分页
scripts/fc_feed.sh --fid 3 --cursor eyJwYWdlIjoxfQ==
输出:包含 {hash, author, text, timestamp, embeds, reactions, replies} 的 cast JSON 数组。
fc_user.sh — 用户查询
bash
按用户名
scripts/fc_user.sh --username dwr
按 FID
scripts/fc_user.sh --fid 3
按以太坊地址(已验证)
scripts/fc_user.sh --address 0x1234...
批量按 FID
scripts/fc_user.sh --fids 3,194,6131
输出:包含 {fid, username, displayname, bio, followercount, followingcount, verifiedaddresses} 的用户 JSON 对象。
fc_search.sh — 搜索 Cast
bash
按关键词搜索
scripts/fc_search.sh --query base chain
带作者筛选的搜索
scripts/fc_search.sh --query ethereum --author-fid 3
在频道中搜索
scripts/fc_search.sh --query gm --channel base
限制结果数量
scripts/fc_search.sh --query nft --limit 5
输出:匹配 cast 的 JSON 数组。
fc_react.sh — 点赞 / 转发
bash
点赞 cast
scripts/fc_react.sh --like 0xabcdef...
取消点赞
scripts/fc_react.sh --like 0xabcdef... --undo
转发
scripts/fc_react.sh --recast 0xabcdef...
取消转发
scripts/fc_react.sh --recast 0xabcdef... --undo
fc_delete.sh — 删除 Cast
bash
scripts/fc_delete.sh --hash 0xabcdef...
fc_channels.sh — 列出和搜索频道
bash
按关键词搜索频道
scripts/fc_channels.sh --search defi
按 ID 获取频道详情
scripts/fc_channels.sh --id base
列出热门频道
scripts/fc_channels.sh --trending --limit 10
常见模式
线程式多 cast 公告
bash
HASH1=$(scripts/fc_cast.sh --text 线程 🧵 1/3:重大消息! --channel base | jq -r .hash)
HASH2=$(scripts/fc_cast.sh --text 2/3:详情在此... --parent $HASH1 | jq -r .hash)
scripts/fc_cast.sh --text 3/3:下方链接 --parent $HASH2 --embed https://example.com
监控提及(轮询循环)
bash
while true; do
scripts/fc_search.sh --query @yourusername --limit 5
sleep 300
done
发布带媒体内容(先上传,后嵌入)
bash
先上传到 catbox/litterbox
URL=$(curl -sS -F reqtype=fileupload -F time=72h \
-F fileToUpload=@/path/to/image.png \
https://litterbox.catbox.moe/resources/internals/api.php)
然后嵌入 URL
scripts/fc_cast.sh --text 看看这个! --embed $URL
免费版与付费版
并非所有端点都在 Neynar 免费计划中可用。
| 功能 | 脚本 | 免费? |
|---|
| 发布 cast | fccast.sh | ✅ |
| 用户 cast 信息流 |
fcfeed.sh --fid | ✅ |
| 用户查询(用户名/FID/地址) | fc_user.sh | ✅ |
| 点赞 / 转发 | fc_react.sh | ✅ |
| 关注信息流 | fc_feed.sh --following | ✅ |
| 频道信息流 | fc_feed.sh --channel | ❌ 付费 |
| Cast 搜索 | fc_search.sh | ❌ 付费 |
| 频道搜索/详情/热门 | fc_channels.sh | ❌ 付费 |
| 删除 cast | fc_delete.sh | ❌ 付费 |
| 线程/对话 | fc_feed.sh --thread | ✅ |
访问付费端点的脚本将以非零退出并显示明确的 402 PaymentRequired 错误。
错误处理
所有脚本成功时退出 0,失败时退出非零。错误以 JSON 格式输出到 stderr:
json
{error: message, status: 403}
常见错误:
- - 401 — API 密钥无效
- 402 — 功能需要付费 Neynar 计划
- 403 — 签名者未批准或未与 API 密钥配对
- 404 — 未找到 Cast/用户/频道
- 429 — 请求频率限制(Neynar 免费版:300 次/分钟)
API 参考
完整端点列表和参数文档请参见 references/neynar_endpoints.md。