Octolens API Skill
When to use this skill
Use this skill when the user needs to:
- - Fetch brand mentions from social media and other platforms
- Filter mentions by source (Twitter, Reddit, GitHub, LinkedIn, YouTube, HackerNews, DevTO, StackOverflow, Bluesky, newsletters, podcasts)
- Analyze sentiment (positive, neutral, negative)
- Filter by author follower count or engagement
- Search for specific keywords or tags
- Query mentions by date range
- List available keywords or saved views
- Apply complex filtering logic with AND/OR conditions
API Authentication
The Octolens API requires a Bearer token for authentication. The user should provide their API key, which you'll use in the Authorization header:
CODEBLOCK0
Important: Always ask the user for their API key before making any API calls. Store it in a variable for subsequent requests.
Base URL
All API endpoints use the base URL: INLINECODE1
Rate Limits
- - Limit: 500 requests per hour
- Check headers:
X-RateLimit-* headers indicate current usage
Available Endpoints
1. POST /mentions
Fetch mentions matching keywords with optional filtering. Returns posts sorted by timestamp (newest first).
Key Parameters:
- -
limit (number, 1-100): Maximum results to return (default: 20) - INLINECODE4 (string): Pagination cursor from previous response
- INLINECODE5 (boolean): Include low-relevance posts (default: false)
- INLINECODE6 (number): View ID to use for filtering
- INLINECODE7 (object): Filter criteria (see filtering section)
Example Response:
CODEBLOCK1
2. GET /keywords
List all keywords configured for the organization.
Example Response:
CODEBLOCK2
3. GET /views
List all saved views (pre-configured filters).
Example Response:
CODEBLOCK3
Filtering Mentions
The /mentions endpoint supports powerful filtering with two modes:
Simple Mode (Implicit AND)
Put fields directly in filters. All conditions are ANDed together.
CODEBLOCK4
→ INLINECODE9
Exclusions
Prefix any array field with ! to exclude values:
CODEBLOCK5
→ INLINECODE10
Advanced Mode (AND/OR Groups)
Use operator and groups for complex logic:
CODEBLOCK6
→ INLINECODE13
Available Filter Fields
| Field | Type | Description |
|---|
| INLINECODE14 | string[] | Platforms: twitter, reddit, github, linkedin, youtube, hackernews, devto, stackoverflow, bluesky, newsletter, podcast |
| INLINECODE15 |
string[] | Values: positive, neutral, negative |
|
keyword | string[] | Keyword IDs (get from /keywords endpoint) |
|
language | string[] | ISO 639-1 codes: en, es, fr, de, pt, it, nl, ja, ko, zh |
|
tag | string[] | Tag names |
|
bookmarked | boolean | Filter bookmarked (true) or non-bookmarked (false) posts |
|
engaged | boolean | Filter engaged (true) or non-engaged (false) posts |
|
minXFollowers | number | Minimum Twitter follower count |
|
maxXFollowers | number | Maximum Twitter follower count |
|
startDate | string | ISO 8601 format (e.g., "2024-01-15T00:00:00Z") |
|
endDate | string | ISO 8601 format |
Using the Bundled Scripts
This skill includes helper scripts for common operations. Use them to quickly interact with the API:
Fetch Mentions
CODEBLOCK7
List Keywords
CODEBLOCK8
List Views
CODEBLOCK9
Custom Filter Query
CODEBLOCK10
Advanced Query
CODEBLOCK11
Best Practices
- 1. Always ask for the API key before making requests
- Use views when possible to leverage pre-configured filters
- Start with simple filters and add complexity as needed
- Check rate limits in response headers (
X-RateLimit-*) - Use pagination with cursor for large result sets
- Dates must be ISO 8601 format (e.g., "2024-01-15T00:00:00Z")
- Get keyword IDs from
/keywords endpoint before filtering by keyword - Use exclusions (!) to filter out unwanted content
- Combine includeAll=false with relevance filtering for quality results
Common Use Cases
Find positive Twitter mentions with high followers
CODEBLOCK12
Exclude spam and get Reddit + GitHub mentions
CODEBLOCK13
Complex query: (Twitter OR LinkedIn) AND positive sentiment, last 7 days
CODEBLOCK14
Error Handling
| Status | Error | Description |
|---|
| 401 | unauthorized | Missing or invalid API key |
| 403 |
forbidden | Valid key but no permission |
| 404 | not_found | Resource (e.g., view ID) not found |
| 429 | rate
limitexceeded | Too many requests |
| 400 | invalid_request | Malformed request body |
| 500 | internal_error | Server error, retry later |
Step-by-Step Workflow
When a user asks to query Octolens data:
- 1. Ask for API key if not already provided
- Understand the request: What are they looking for?
- Determine filters needed: Source, sentiment, date range, etc.
- Check if a view applies: List views first if user mentions saved filters
- Build the query: Use simple mode first, advanced mode for complex logic
- Execute the request: Use bundled Node.js scripts or fetch API directly
- Parse results: Extract key information (author, body, sentiment, source)
- Handle pagination: If more results needed, use cursor from response
- Present findings: Summarize insights, highlight patterns
Examples
Example 1: Simple Query
User: "Show me positive mentions from Twitter in the last 7 days"
Action (using bundled script):
CODEBLOCK15
Alternative (using fetch API directly):
CODEBLOCK16
Example 2: Advanced Query
User: "Find mentions from Reddit or GitHub, exclude spam tag, with positive or neutral sentiment"
Action (using bundled script):
CODEBLOCK17
Alternative (using fetch API directly):
CODEBLOCK18
Example 3: Get Keywords First
User: "Show mentions for our main product keyword"
Actions:
- 1. First, list keywords:
CODEBLOCK19
- 2. Then query mentions with the keyword ID:
CODEBLOCK20
Tips for Agents
- - Use bundled scripts: The Node.js scripts handle JSON parsing automatically
- Cache keywords: After fetching keywords once, remember them for the session
- Explain filters: When using complex filters, explain the logic to the user
- Show examples: When users are unsure, show example filter structures
- Paginate wisely: Ask if user wants more results before fetching next page
- Summarize insights: Don't just dump data, provide analysis (sentiment trends, top authors, platform distribution)
Octolens API 技能
何时使用此技能
当用户需要以下操作时,请使用此技能:
- - 从社交媒体及其他平台获取品牌提及
- 按来源筛选提及(Twitter、Reddit、GitHub、LinkedIn、YouTube、HackerNews、DevTO、StackOverflow、Bluesky、新闻通讯、播客)
- 分析情感倾向(正面、中性、负面)
- 按作者粉丝数或互动量筛选
- 搜索特定关键词或标签
- 按日期范围查询提及
- 列出可用关键词或已保存视图
- 使用 AND/OR 条件应用复杂筛选逻辑
API 认证
Octolens API 需要 Bearer 令牌进行认证。用户应提供其 API 密钥,您将在 Authorization 标头中使用该密钥:
Authorization: Bearer YOURAPIKEY
重要提示:在进行任何 API 调用之前,务必向用户索要其 API 密钥。将其存储在变量中,以便后续请求使用。
基础 URL
所有 API 端点均使用基础 URL:https://app.octolens.com/api/v1
速率限制
- - 限制:每小时 500 次请求
- 检查标头:X-RateLimit-* 标头指示当前使用情况
可用端点
1. POST /mentions
获取匹配关键词的提及,支持可选筛选。返回按时间戳排序的帖子(最新在前)。
关键参数:
- - limit(数字,1-100):最大返回结果数(默认:20)
- cursor(字符串):来自先前响应的分页游标
- includeAll(布尔值):包含低相关性帖子(默认:false)
- view(数字):用于筛选的视图 ID
- filters(对象):筛选条件(参见筛选部分)
示例响应:
json
{
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: zh,
tags: [功能请求],
keywords: [{ id: 1, keyword: YourProduct }],
bookmarked: false,
engaged: false
}
],
cursor: eyJsYXN0SWQiOiAiYWJjMTIzIn0=
}
2. GET /keywords
列出为组织配置的所有关键词。
示例响应:
json
{
data: [
{
id: 1,
keyword: YourProduct,
platforms: [twitter, reddit, github],
color: #6366f1,
paused: false,
context: 我们的主要产品名称
}
]
}
3. GET /views
列出所有已保存的视图(预配置的筛选器)。
示例响应:
json
{
data: [
{
id: 1,
name: 高优先级,
icon: star,
filters: {
sentiment: [positive, negative],
source: [twitter]
},
createdAt: 2024-01-01T00:00:00Z
}
]
}
筛选提及
/mentions 端点支持两种模式的强大筛选功能:
简单模式(隐式 AND)
将字段直接放入筛选器中。所有条件均以 AND 连接。
json
{
filters: {
source: [twitter, linkedin],
sentiment: [positive],
minXFollowers: 1000
}
}
→ source IN (twitter, linkedin) AND sentiment = positive AND followers ≥ 1000
排除
在任何数组字段前加 ! 以排除值:
json
{
filters: {
source: [twitter],
!keyword: [5, 6]
}
}
→ source = twitter AND keyword NOT IN (5, 6)
高级模式(AND/OR 分组)
使用 operator 和 groups 实现复杂逻辑:
json
{
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 交互:
获取提及
bash
node scripts/fetch-mentions.js YOUR
APIKEY [limit] [includeAll]
列出关键词
bash
node scripts/list-keywords.js YOUR
APIKEY
列出视图
bash
node scripts/list-views.js YOUR
APIKEY
自定义筛选查询
bash
node scripts/query-mentions.js YOUR
APIKEY {source: [twitter], sentiment: [positive]} [limit]
高级查询
bash
node scripts/advanced-query.js YOUR
APIKEY [limit]
最佳实践
- 1. 在发起请求前务必索要 API 密钥
- 尽可能使用视图以利用预配置的筛选器
- 从简单筛选开始,根据需要增加复杂度
- 检查响应标头中的速率限制(X-RateLimit-*)
- 对大型结果集使用游标分页
- 日期必须为 ISO 8601 格式(例如 2024-01-15T00:00:00Z)
- 在按关键词筛选前,先从 /keywords 端点获取关键词 ID
- 使用排除(!) 过滤掉不需要的内容
- 将 includeAll=false 与相关性筛选结合以获得高质量结果
常见用例
查找高粉丝数的正面 Twitter 提及
json
{
limit: 20,
filters: {
source: [twitter],
sentiment: [positive],
minXFollowers: 1000
}
}
排除垃圾信息,获取 Reddit + GitHub 提及
json
{
limit: 50,
filters: {
source: [reddit, github],
!tag: [spam, irrelevant]
}
}
复杂查询:(Twitter OR LinkedIn) AND 正面情感,最近 7 天
json
{
limit: 30,
filters: {
operator: AND,
groups: [
{
operator: OR,
conditions: [
{ source: [twitter] },
{ source: [linkedin] }
]
},
{
operator: AND,
conditions: [
{ sentiment: [positive] },
{ startDate: 2024-01-20T00:00:00Z }
]
}
]
}
}
错误处理
| 状态码 | 错误 |