DataFast Analytics Skill
Use this skill to call the DataFast API and summarize results for the user.
Quick Workflow
- 1. Confirm the request type (overview, timeseries, realtime, breakdown, visitor, goals/payments create/delete).
- Gather required inputs:
- Date range:
startAt and
endAt together or neither (overview/timeseries support ranges).
-
timezone,
fields,
interval,
limit,
offset, and any
filter_* parameters.
- 3. Build the HTTP request with
Authorization: Bearer $DATAFAST_API_KEY and Content-Type: application/json. - Execute with
curl and parse JSON. - Summarize results in a table plus a short narrative (totals + key takeaways). Include pagination info if relevant.
Setup
- 1. Get your API key from DataFast (starts with
df_). - Store it:
CODEBLOCK0
Authentication
All requests need:
CODEBLOCK1
If the user hasn't set up the API key, ask them to follow the setup steps above.
Base URL
INLINECODE12
Reference Docs
Use the full API reference at {baseDir}/references/datafast-api-docs.md for endpoint details, response fields, and examples.
Endpoint Guidance
Overview
- - INLINECODE14
- Optional:
startAt, endAt, timezone, fields.
Time Series
- - INLINECODE19
- Typical params:
fields, interval (hour/day/week/month), startAt, endAt, timezone, limit, offset. - Accepts
filter_* query params for segmentation. - Note:
fields is required (e.g., fields=visitors,sessions).
Realtime
- - INLINECODE30
- INLINECODE31
Breakdowns
- - INLINECODE32
- INLINECODE33
- INLINECODE34
- INLINECODE35
- INLINECODE36
- INLINECODE37
- INLINECODE38
- INLINECODE39
- INLINECODE40
- INLINECODE41
- INLINECODE42
Visitor Details
Goals
- - Create goal: INLINECODE44
- Delete goals:
DELETE /goals (requires at least one filter or time range; confirm scope)
Payments
- - Create payment: INLINECODE46
- Delete payments:
DELETE /payments (confirm scope)
Destructive Actions
For DELETE /goals or DELETE /payments:
- - Always confirm exact filters and time range in plain English before executing.
- If user asks for "all time" deletion, ask for explicit confirmation.
- Echo the final URL that will be called (without the API key).
Filter Syntax
Use filter_* params for segmentation (e.g., filter_referrer=is:X).
Important: Filter values must match the exact names from breakdown endpoints. For example, X/Twitter is stored as "X" (not "x.com" or "twitter.com"). When in doubt, query the breakdown first:
curl ... "/analytics/referrers?limit=20"
Then use the exact
referrer value in your filter.
Example Command Patterns
GET
CODEBLOCK3
POST
CODEBLOCK4
DELETE
CODEBLOCK5
Output Expectations
- - Provide a short summary and a flat table of results.
- Include totals and conversion/revenue metrics when present.
- For time series, include the top-level totals and the first/last timestamps in the selected range.
- If pagination exists, report
limit, offset, and total, and ask if the user wants the next page.
DataFast 分析技能
使用此技能调用 DataFast API 并为用户汇总结果。
快速工作流程
- 1. 确认请求类型(概览、时间序列、实时、细分、访客、目标/支付 创建/删除)。
- 收集必要输入:
- 日期范围:startAt 和 endAt 需同时提供或同时不提供(概览/时间序列支持范围)。
- timezone、fields、interval、limit、offset 以及任何 filter_* 参数。
- 3. 使用 Authorization: Bearer $DATAFASTAPIKEY 和 Content-Type: application/json 构建 HTTP 请求。
- 使用 curl 执行并解析 JSON。
- 以表格加简短叙述(总计 + 关键要点)的形式汇总结果。如相关,包含分页信息。
设置
- 1. 从 DataFast 获取您的 API 密钥(以 df_ 开头)。
- 存储密钥:
bash
mkdir -p ~/.config/datafast
echo df
yourkey
here > ~/.config/datafast/apikey
身份验证
所有请求都需要:
bash
DATAFASTAPIKEY=$(cat ~/.config/datafast/api_key)
curl ... \
-H Authorization: Bearer $DATAFASTAPIKEY \
-H Content-Type: application/json
如果用户尚未设置 API 密钥,请要求他们按照上述设置步骤操作。
基础 URL
https://datafa.st/api/v1/
参考文档
使用 {baseDir}/references/datafast-api-docs.md 中的完整 API 参考文档获取端点详情、响应字段和示例。
端点指南
概览
- - GET /analytics/overview
- 可选参数:startAt、endAt、timezone、fields。
时间序列
- - GET /analytics/timeseries
- 典型参数:fields、interval(小时/天/周/月)、startAt、endAt、timezone、limit、offset。
- 接受 filter_* 查询参数进行细分。
- 注意: fields 为必填(例如 fields=visitors,sessions)。
实时
- - GET /analytics/realtime
- GET /analytics/realtime/map
细分
- - GET /analytics/devices
- GET /analytics/pages
- GET /analytics/campaigns
- GET /analytics/goals
- GET /analytics/referrers
- GET /analytics/countries
- GET /analytics/regions
- GET /analytics/cities
- GET /analytics/browsers
- GET /analytics/operating-systems
- GET /analytics/hostnames
访客详情
- - GET /visitors/{datafastvisitorid}
目标
- - 创建目标:POST /goals
- 删除目标:DELETE /goals(至少需要一个筛选条件或时间范围;确认范围)
支付
- - 创建支付:POST /payments
- 删除支付:DELETE /payments(确认范围)
破坏性操作
对于 DELETE /goals 或 DELETE /payments:
- - 在执行前,始终用通俗语言确认确切的筛选条件和时间范围。
- 如果用户要求删除所有时间的数据,请要求明确确认。
- 回显最终将调用的 URL(不包含 API 密钥)。
筛选语法
使用 filter* 参数进行细分(例如 filterreferrer=is:X)。
重要提示: 筛选值必须与细分端点中的确切名称匹配。例如,X/Twitter 存储为X(而不是x.com或twitter.com)。如有疑问,请先查询细分数据:
bash
curl ... /analytics/referrers?limit=20
然后在筛选条件中使用确切的 referrer 值。
示例命令模式
GET
bash
DATAFAST
APIKEY=$(cat ~/.config/datafast/api_key)
curl -sS https://datafa.st/api/v1/analytics/overview?startAt=2024-01-01&endAt=2024-01-31&timezone=UTC \
-H Authorization: Bearer $DATAFAST
APIKEY \
-H Content-Type: application/json
POST
bash
DATAFAST
APIKEY=$(cat ~/.config/datafast/api_key)
curl -sS https://datafa.st/api/v1/goals \
-H Authorization: Bearer $DATAFAST
APIKEY \
-H Content-Type: application/json \
-d {datafast
visitorid:...,name:newsletter_signup,metadata:{email:...}}
DELETE
bash
DATAFAST
APIKEY=$(cat ~/.config/datafast/api_key)
curl -sS -X DELETE https://datafa.st/api/v1/goals?name=signup&startAt=2023-01-01T00:00:00Z&endAt=2023-01-31T23:59:59Z \
-H Authorization: Bearer $DATAFAST
APIKEY
输出预期
- - 提供简短摘要和扁平结果表格。
- 包含总计及转化/收入指标(如存在)。
- 对于时间序列,包含顶级总计以及所选范围内的第一个/最后一个时间戳。
- 如果存在分页,报告 limit、offset 和 total,并询问用户是否需要下一页。