Pulse
管理台API 文档
API 文档 v0.2.1 OpenAPI 3.0

Pulse Analytics API

轻量产品埋点服务。API Key 一等公民,适合 Agent / 脚本 / 服务端。浏览器采集可用 public websiteId;查询与管理需 x-api-key。

鉴权

除 health / collect(浏览器模式)外,请求需带 API Key:

x-api-key: pk_live_…

或 Authorization: Bearer pk_live_… · 权限范围: collect / read / admin

Base URL
https://pulse.nezus.cn

System

2
GET
/v1/health

Health check

公开

无需鉴权。仅返回服务状态与版本。

响应示例

{
  "ok": true,
  "service": "pulse",
  "version": "0.2.1",
  "ts": 1710000000000
}

cURL

curl -sS 'https://pulse.nezus.cn/v1/health'
GET
/v1/openapi.json

OpenAPI JSON

公开

机器可读规范。人类请看 /docs。

cURL

curl -sS 'https://pulse.nezus.cn/v1/openapi.json'

Collect

2
POST
/v1/collect

上报 pageview / event

公开

浏览器可仅传 websiteId(public id)。可用 text/plain JSON 避免 CORS 预检。Agent 可带 collect scope 的 API Key。

请求体

{
  "websiteId": "ws_xxx",
  "type": "event",
  "name": "quiz_complete",
  "path": "/q/abstract-mbti/result",
  "props": {
    "quizId": "abstract-mbti",
    "typeId": "INTJ"
  },
  "visitorId": "v_demo",
  "sessionId": "s_demo"
}

响应示例

{
  "ok": true,
  "accepted": 1,
  "id": "ev_xxx"
}

cURL

curl -sS -X POST 'https://pulse.nezus.cn/v1/collect' \
  -H 'content-type: application/json' \
  -d '{"websiteId":"ws_xxx","type":"event","name":"quiz_complete","path":"/q/abstract-mbti/result","props":{"quizId":"abstract-mbti","typeId":"INTJ"},"visitorId":"v_demo","sessionId":"s_demo"}'
POST
/v1/collect/batch

批量上报

需 Key

需要 collect scope。最多 100 条。

请求体

{
  "items": [
    {
      "websiteId": "ws_xxx",
      "type": "pageview",
      "path": "/"
    },
    {
      "websiteId": "ws_xxx",
      "type": "event",
      "name": "quiz_start",
      "path": "/q/x"
    }
  ]
}

cURL

curl -sS -X POST 'https://pulse.nezus.cn/v1/collect/batch' \
  -H 'x-api-key: $PULSE_KEY' \
  -H 'content-type: application/json' \
  -d '{"items":[{"websiteId":"ws_xxx","type":"pageview","path":"/"},{"websiteId":"ws_xxx","type":"event","name":"quiz_start","path":"/q/x"}]}'

Websites

13
GET
/v1/websites

列出站点

需 Key

需要 read 或 admin。

cURL

curl -sS 'https://pulse.nezus.cn/v1/websites' \
  -H 'x-api-key: $PULSE_KEY'
POST
/v1/websites

创建站点

需 Key

需要全局 admin(未绑定站点的 key)。withKeys=true 时返回 collect/read 明文 key(仅一次)。

请求体

{
  "name": "viral-quiz",
  "domain": "quiz.nezus.cn",
  "withKeys": true
}

cURL

curl -sS -X POST 'https://pulse.nezus.cn/v1/websites' \
  -H 'x-api-key: $PULSE_KEY' \
  -H 'content-type: application/json' \
  -d '{"name":"viral-quiz","domain":"quiz.nezus.cn","withKeys":true}'
GET
/v1/overview

全部站点总览(管理台首页数据源)

需 Key

一次请求返回 key 可见的所有站点:1d/7d/30d 窗口与环比、近 14 天 PV 迷你曲线、近 5 分钟在线访客。需要 read。

cURL

curl -sS 'https://pulse.nezus.cn/v1/overview' \
  -H 'x-api-key: $PULSE_KEY'
GET
/v1/websites/{id}/timeseries

按日时间序列

需 Key

query: days、startDay/endDay 或 startAt/endAt(毫秒;默认近 30 天,最长 366 天)。返回站点时区下补零的每日 pageviews / events / visitors。

参数

名称位置必填类型
idpath是string
startAtquery否integer
endAtquery否integer

cURL

curl -sS 'https://pulse.nezus.cn/v1/websites/{id}/timeseries' \
  -H 'x-api-key: $PULSE_KEY'
GET
/v1/websites/{id}/stats

聚合统计

需 Key

query: days(最近 N 个自然日)| startDay+endDay | startAt+endAt(毫秒)。默认近 7 天;支持全部筛选参数。

参数

名称位置必填类型
idpath是string
startAtquery否integer
endAtquery否integer

响应示例

{
  "pageviews": 120,
  "events": 40,
  "visitors": 18,
  "startAt": 0,
  "endAt": 0
}

cURL

curl -sS 'https://pulse.nezus.cn/v1/websites/{id}/stats' \
  -H 'x-api-key: $PULSE_KEY'
GET
/v1/websites/{id}/overview

1d / 7d / 30d 总览 + 环比

需 Key

返回 current / previous / change,用于管理台卡片。时间窗为站点时区的自然日(0 点起算),非滚动 24h:d1=今日 00:00→now 对比昨日全天;d7/d30 含今日在内的 N 个自然日。

参数

名称位置必填类型
idpath是string

cURL

curl -sS 'https://pulse.nezus.cn/v1/websites/{id}/overview' \
  -H 'x-api-key: $PULSE_KEY'
GET
/v1/websites/{id}/metrics

维度拆解

需 Key

type=path | event | referrer

参数

名称位置必填类型
idpath是string
typequery否path | event | referrer
startAtquery否integer
endAtquery否integer
limitquery否integer

cURL

curl -sS 'https://pulse.nezus.cn/v1/websites/{id}/metrics' \
  -H 'x-api-key: $PULSE_KEY'
GET
/v1/websites/{id}/events

原始事件列表

需 Key

参数

名称位置必填类型
idpath是string
namequery否string
pathPrefixquery否string
startAtquery否integer
endAtquery否integer
limitquery否integer

cURL

curl -sS 'https://pulse.nezus.cn/v1/websites/{id}/events' \
  -H 'x-api-key: $PULSE_KEY'
GET
/v1/websites/{id}/interest

社交证明 interest

需 Key

pathPrefix 或 eventName + days(默认 7)。

参数

名称位置必填类型
idpath是string
pathPrefixquery否string
eventNamequery否string
daysquery否integer

cURL

curl -sS 'https://pulse.nezus.cn/v1/websites/{id}/interest' \
  -H 'x-api-key: $PULSE_KEY'
GET
/v1/websites/{id}

站点详情

需 Key

参数

名称位置必填类型
idpath是string

cURL

curl -sS 'https://pulse.nezus.cn/v1/websites/{id}' \
  -H 'x-api-key: $PULSE_KEY'
PATCH
/v1/websites/{id}

修改站点设置(admin)

需 Key

name / domain / timezone(IANA,null=服务器时区)/ retentionDays(0=永久,null=服务器默认)。修改时区会按新时区重建全部历史聚合。

参数

名称位置必填类型
idpath是string

请求体

{
  "timezone": "Asia/Shanghai",
  "retentionDays": 365
}

cURL

curl -sS -X PATCH 'https://pulse.nezus.cn/v1/websites/{id}' \
  -H 'x-api-key: $PULSE_KEY' \
  -H 'content-type: application/json' \
  -d '{"timezone":"Asia/Shanghai","retentionDays":365}'
DELETE
/v1/websites/{id}

永久删除站点(全局 admin)

需 Key

连同全部事件、汇总、目标、漏斗与密钥一起删除,不可恢复。

参数

名称位置必填类型
idpath是string

cURL

curl -sS -X DELETE 'https://pulse.nezus.cn/v1/websites/{id}' \
  -H 'x-api-key: $PULSE_KEY'
POST
/v1/websites/{id}/prune

立即清理明细事件(admin)

需 Key

删除早于 days 天的原始事件与访客明细;每日汇总保留。缺省使用站点保留天数(或 PULSE_RETENTION_DAYS)。

参数

名称位置必填类型
idpath是string

请求体

{
  "days": 365
}

cURL

curl -sS -X POST 'https://pulse.nezus.cn/v1/websites/{id}/prune' \
  -H 'x-api-key: $PULSE_KEY' \
  -H 'content-type: application/json' \
  -d '{"days":365}'

Keys

3
GET
/v1/websites/{id}/keys

列出 Key(仅 prefix)

需 Key

参数

名称位置必填类型
idpath是string

cURL

curl -sS 'https://pulse.nezus.cn/v1/websites/{id}/keys' \
  -H 'x-api-key: $PULSE_KEY'
POST
/v1/websites/{id}/keys

创建 Key

需 Key

明文 key 仅在响应中返回一次。scopes: collect | read | admin

参数

名称位置必填类型
idpath是string

请求体

{
  "name": "agent-read",
  "scopes": [
    "read"
  ]
}

cURL

curl -sS -X POST 'https://pulse.nezus.cn/v1/websites/{id}/keys' \
  -H 'x-api-key: $PULSE_KEY' \
  -H 'content-type: application/json' \
  -d '{"name":"agent-read","scopes":["read"]}'
DELETE
/v1/keys/{id}

吊销 Key

需 Key

参数

名称位置必填类型
idpath是string

cURL

curl -sS -X DELETE 'https://pulse.nezus.cn/v1/keys/{id}' \
  -H 'x-api-key: $PULSE_KEY'

Reports

8
GET
/v1/websites/{id}/report

一次返回整页报表

需 Key

总数、按日序列、可选对比(compare=prev|year)、页面/事件/来源/渠道排行与目标转化。所有筛选同时作用于每一部分。

参数

名称位置必填类型
idpath是string
comparequery否prev | year
daysquery否integer
startDayquery否string
endDayquery否string
pathquery否string
referrerquery否string
channelquery否direct | organic_search | social | referral | email | paid | campaign
utm_sourcequery否string
utm_mediumquery否string
utm_campaignquery否string
countryquery否string
browserquery否string
osquery否string
devicequery否desktop | mobile | tablet
languagequery否string
eventquery否string

cURL

curl -sS 'https://pulse.nezus.cn/v1/websites/{id}/report' \
  -H 'x-api-key: $PULSE_KEY'
GET
/v1/websites/{id}/breakdown

某一维度的排行

需 Key

by = path | event | referrer | channel | utm_source | utm_medium | utm_campaign | country | browser | os | device | language。维度自身的筛选会被忽略。

参数

名称位置必填类型
idpath是string
byquery是string
limitquery否integer
daysquery否integer
startDayquery否string
endDayquery否string
pathquery否string
referrerquery否string
channelquery否direct | organic_search | social | referral | email | paid | campaign
utm_sourcequery否string
utm_mediumquery否string
utm_campaignquery否string
countryquery否string
browserquery否string
osquery否string
devicequery否desktop | mobile | tablet
languagequery否string
eventquery否string

cURL

curl -sS 'https://pulse.nezus.cn/v1/websites/{id}/breakdown' \
  -H 'x-api-key: $PULSE_KEY'
GET
/v1/websites/{id}/goals

目标及转化率

需 Key

参数

名称位置必填类型
idpath是string
daysquery否integer

cURL

curl -sS 'https://pulse.nezus.cn/v1/websites/{id}/goals' \
  -H 'x-api-key: $PULSE_KEY'
POST
/v1/websites/{id}/goals

创建目标(admin)

需 Key

type=event:value 为事件名;type=path:value 以 / 开头,结尾 * 表示前缀。

参数

名称位置必填类型
idpath是string

请求体

{
  "name": "Signup",
  "type": "event",
  "value": "signup"
}

cURL

curl -sS -X POST 'https://pulse.nezus.cn/v1/websites/{id}/goals' \
  -H 'x-api-key: $PULSE_KEY' \
  -H 'content-type: application/json' \
  -d '{"name":"Signup","type":"event","value":"signup"}'
DELETE
/v1/websites/{id}/goals/{goalId}

删除目标(admin)

需 Key

参数

名称位置必填类型
idpath是string
goalIdpath是string

cURL

curl -sS -X DELETE 'https://pulse.nezus.cn/v1/websites/{id}/goals/{goalId}' \
  -H 'x-api-key: $PULSE_KEY'
GET
/v1/websites/{id}/funnels

漏斗及各步骤访客数

需 Key

每一步必须在上一步之后 windowMinutes 分钟内完成;按访客计。

参数

名称位置必填类型
idpath是string
daysquery否integer

cURL

curl -sS 'https://pulse.nezus.cn/v1/websites/{id}/funnels' \
  -H 'x-api-key: $PULSE_KEY'
POST
/v1/websites/{id}/funnels

创建漏斗(admin)

需 Key

参数

名称位置必填类型
idpath是string

请求体

{
  "name": "Landing → Signup",
  "steps": [
    {
      "type": "path",
      "value": "/lp"
    },
    {
      "type": "event",
      "value": "signup"
    }
  ],
  "windowMinutes": 1440
}

cURL

curl -sS -X POST 'https://pulse.nezus.cn/v1/websites/{id}/funnels' \
  -H 'x-api-key: $PULSE_KEY' \
  -H 'content-type: application/json' \
  -d '{"name":"Landing → Signup","steps":[{"type":"path","value":"/lp"},{"type":"event","value":"signup"}],"windowMinutes":1440}'
DELETE
/v1/websites/{id}/funnels/{funnelId}

删除漏斗(admin)

需 Key

参数

名称位置必填类型
idpath是string
funnelIdpath是string

cURL

curl -sS -X DELETE 'https://pulse.nezus.cn/v1/websites/{id}/funnels/{funnelId}' \
  -H 'x-api-key: $PULSE_KEY'

Share

3
POST
/v1/websites/{id}/share

创建/重置只读分享链接(admin)

需 Key

参数

名称位置必填类型
idpath是string

响应示例

{
  "shareId": "k3j…",
  "path": "/share/k3j…"
}

cURL

curl -sS -X POST 'https://pulse.nezus.cn/v1/websites/{id}/share' \
  -H 'x-api-key: $PULSE_KEY'
DELETE
/v1/websites/{id}/share

停止分享(admin)

需 Key

参数

名称位置必填类型
idpath是string

cURL

curl -sS -X DELETE 'https://pulse.nezus.cn/v1/websites/{id}/share' \
  -H 'x-api-key: $PULSE_KEY'
GET
/v1/share/{shareId}/report

公开只读报表

公开

无需 key,凭分享链接 token 访问;参数同 /v1/websites/{id}/report,仅返回站点名称、域名与时区。另有 /breakdown、/funnels。

参数

名称位置必填类型
shareIdpath是string

cURL

curl -sS 'https://pulse.nezus.cn/v1/share/{shareId}/report'