名称: octolens
描述: 从 Octolens API 查询和分析品牌提及。当用户需要获取提及、追踪关键词、按来源平台(Twitter、Reddit、GitHub、LinkedIn 等)筛选、进行情感分析或分析社交媒体互动时使用。支持使用 AND/OR 逻辑、日期范围、粉丝数和书签进行复杂筛选。
许可证: MIT
元数据:
author: octolens
version: "1.0"
compatibility: 需要 Node.js 18+(用于 fetch API)和互联网访问权限
允许工具: Node Read
当用户需要执行以下操作时,请使用此技能:
- 从社交媒体和其他平台获取品牌提及
- 按来源筛选提及(Twitter、Reddit、GitHub、LinkedIn、YouTube、HackerNews、DevTO、StackOverflow、Bluesky、新闻通讯、播客)
- 分析情感(积极、中性、消极)
- 按作者粉丝数或互动情况筛选
- 搜索特定关键词或标签
- 按日期范围查询提及
- 列出可用关键词或已保存的视图
- 应用带有 AND/OR 条件的复杂筛选逻辑
Octolens API 需要使用 Bearer 令牌进行身份验证。用户应提供其 API 密钥,你将在 Authorization 请求头中使用它:
Authorization: Bearer YOUR_API_KEY
重要提示:在进行任何 API 调用之前,务必向用户索要其 API 密钥。将其存储在变量中,以供后续请求使用。
所有 API 端点均使用以下基础 URL:https://app.octolens.com/api/v1
X-RateLimit-* 请求头指示当前使用情况获取匹配关键词的提及,支持可选筛选。返回按时间戳排序(最新优先)的帖子。
关键参数:
- limit(数字,1-100):返回的最大结果数(默认值:20)
- cursor(字符串):来自先前响应的分页游标
- includeAll(布尔值):是否包含低相关性帖子(默认值:false)
- view(数字):用于筛选的视图 ID
- filters(对象):筛选条件(参见筛选部分)
响应示例:
{
"data": [
{
"id": "abc123",
"url": "https://twitter.com/user/status/123",
"body": "刚刚发现了 @YourProduct - 这正是我需要的!",
"source": "twitter",
"timestamp": "2024-01-15T10:30:00Z",
"author": "user123",
"authorName": "张三",
"authorFollowers": 5420,
"relevance": "relevant",
"sentiment": "positive",
"language": "en",
"tags": ["feature-request"],
"keywords": [{ "id": 1, "keyword": "YourProduct" }],
"bookmarked": false,
"engaged": false
}
],
"cursor": "eyJsYXN0SWQiOiAiYWJjMTIzIn0="
}
列出为组织配置的所有关键词。
响应示例:
{
"data": [
{
"id": 1,
"keyword": "YourProduct",
"platforms": ["twitter", "reddit", "github"],
"color": "#6366f1",
"paused": false,
"context": "我们的主要产品名称"
}
]
}
列出所有已保存的视图(预配置的筛选器)。
响应示例:
{
"data": [
{
"id": 1,
"name": "高优先级",
"icon": "star",
"filters": {
"sentiment": ["positive", "negative"],
"source": ["twitter"]
},
"createdAt": "2024-01-01T00:00:00Z"
}
]
}
/mentions 端点支持两种模式的强大筛选功能:
将字段直接放入 filters 中。所有条件之间为 AND 关系。
{
"filters": {
"source": ["twitter", "linkedin"],
"sentiment": ["positive"],
"minXFollowers": 1000
}
}
→ source IN (twitter, linkedin) AND sentiment = positive AND followers ≥ 1000
在任何数组字段前添加 ! 前缀以排除特定值:
{
"filters": {
"source": ["twitter"],
"!keyword": [5, 6]
}
}
→ source = twitter AND keyword NOT IN (5, 6)
使用 operator 和 groups 实现复杂逻辑:
{
"filters": {
"operator": "AND",
"groups": [
{
"operator": "OR",
"conditions": [
{ "source": ["twitter"] },
{ "source": ["linkedin"] }
]
},
{
"operator": "AND",
"conditions": [
{ "sentiment": ["positive"] },
{ "!tag": ["spam"] }
]
}
]
}
}
→ (source = twitter OR source = linkedin) AND (sentiment = positive AND tag ≠ spam)
| 字段 | 类型 | 描述 |
|---|---|---|
source |
string[] | 平台:twitter, reddit, github, linkedin, youtube, hackernews, devto, stackoverflow, bluesky, newsletter, podcast |
sentiment |
string[] | 值:positive, neutral, negative |
keyword |
string[] | 关键词 ID(从 /keywords 端点获取) |
language |
string[] | ISO 639-1 代码:en, es, fr, de, pt, it, nl, ja, ko, zh |
tag |
string[] | 标签名称 |
bookmarked |
boolean | 筛选已加书签 (true) 或未加书签 (false) 的帖子 |
engaged |
boolean | 筛选已互动 (true) 或未互动 (false) 的帖子 |
minXFollowers |
number | Twitter 粉丝数最小值 |
maxXFollowers |
number | Twitter 粉丝数最大值 |
startDate |
string | ISO 8601 格式(例如:"2024-01-15T00:00:00Z") |
endDate |
string | ISO 8601 格式 |
此技能包含用于常见操作的辅助脚本。使用它们可以快速与 API 交互:
node scripts/fetch-mentions.js YOUR_API_KEY [limit] [includeAll]
node scripts/list-keywords.js YOUR_API_KEY
node scripts/list-views.js YOUR_API_KEY
node scripts/query-mentions.js YOUR_API_KEY '{"source": ["twitter"], "sentiment": ["positive"]}' [limit]
node scripts/advanced-query.js YOUR_API_KEY [limit]
X-RateLimit-*)/keywords 端点获取关键词 IDincludeAll=false 和相关性筛选以获得高质量结果{
"limit": 20,
"filters": {
"source": ["twitter"],
"sentiment": ["positive"],
"minXFollowers": 1000
}
}
{
"limit": 50,
"filters": {
"source": ["reddit", "github"],
"!tag": ["spam", "irrelevant"]
}
}
{
"limit": 30,
"filters": {
"operator": "AND",
"groups": [
{
"operator": "OR",
"conditions": [
{ "source": ["twitter"] },
{ "source": ["linkedin"] }
]
},
{
"operator": "AND",
"conditions": [
{ "sentiment": ["positive"] },
{ "startDate": "2024-01-20T00:00:00Z" }
]
}
]
}
}
| 状态码 | 错误 | 描述 |
|---|---|---|
| 401 | unauthorized | 缺少或无效的 API 密钥 |
| 403 | forbidden | 密钥有效但无权限 |
| 404 | not_found | 资源未找到(例如视图 ID) |
| 429 | rate_limit_exceeded | 请求过多 |
| 400 | invalid_request | 请求正文格式错误 |
| 500 | internal_error | 服务器错误,请稍后重试 |
当用户要求查询 Octolens 数据时:
用户:"显示过去 7 天内来自 Twitter 的积极提及"
操作(使用捆绑脚本):
node scripts/query-mentions.js YOUR_API_KEY '{"source": ["twitter"], "sentiment": ["positive"], "startDate": "2024-01-20T00:00:00Z"}'
替代方案(直接使用 fetch API):
const response = await fetch('https://app.octolens.com/api/v1/mentions', {
method: 'POST',
headers: {
'Authorization': `Bearer ${API_KEY}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({
limit: 20,
filters: {
source: ['twitter'],
sentiment: ['positive'],
startDate: '2024-01-20T00:00:00Z',
},
}),
});
const data = await response.json();
用户:"查找来自 Reddit 或 GitHub、排除垃圾标签、且情感为积极或中性的提及"
操作(使用捆绑脚本):
node scripts/query-mentions.js YOUR_API_KEY '{"operator": "AND", "groups": [{"operator": "OR", "conditions": [{"source": ["reddit"]}, {"source": ["github"]}]}, {"operator": "OR", "conditions": [{"sentiment": ["positive"]}, {"sentiment": ["neutral"]}]}, {"operator": "AND", "conditions": [{"!tag": ["spam"]}]}]}'
替代方案(直接使用 fetch API):
const response = await fetch('https://app.octolens.com/api/v1/mentions', {
method: 'POST',
headers: {
'Authorization': `Bearer ${API_KEY}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({
limit: 30,
filters: {
operator: 'AND',
groups: [
{
operator: 'OR',
conditions: [
{ source: ['reddit'] },
{ source: ['github'] },
],
},
{
operator: 'OR',
conditions: [
{ sentiment: ['positive'] },
{ sentiment: ['neutral'] },
],
},
{
operator: 'AND',
conditions: [
{ '!tag': ['spam'] },
],
},
],
},
}),
});
const data = await response.json();
用户:"显示我们主要产品关键词的提及"
操作步骤:
1. 首先,列出关键词:
node scripts/list-keywords.js YOUR_API_KEY
node scripts/query-mentions.js YOUR_API_KEY '{"keyword": [1]}'