dataforgeo://docs~/getting-started/quickstart.md控制台
 ___       _        ___         ___ ___ ___
|   \ __ _| |_ __ _| __|__ _ _ / __| __/ _ \
| |) / _` |  _/ _` | _/ _ \ '_| (_ | _| (_) |
|___/\__,_|\__\__,_|_|\___/_|  \___|___\___/  api v1 · 草稿

快速开始

所有接口用一个请求头认证:x-api-key。请求和响应都是 JSON,时间一律用 ISO 8601(UTC)。

项说明
Base URLhttps://api.dataforgeo.dev
认证x-api-key 在控制台创建 API key;Pro 可建 5 个,Scale 和 Enterprise 不限
免费额度100 credits 注册即送,可跑 100 次标准引擎调用

第一个请求

bash
$ curl https://api.dataforgeo.dev/v1/geo/answer \
  -H "x-api-key: YOUR_API_KEY" \
  -H "content-type: application/json" \
  -d '{
    "prompt": "东京有哪些适合家庭入住的民宿?",
    "engines": [
      "chatgpt"
    ],
    "brand": "晓宅",
    "location": "JP",
    "language": "zh-CN"
  }'
stdout
HTTP/1.1: 200 OK
x-credits-used: 1
x-credits-remaining: 99
x-cache: miss

{
  "request_id": "req_8f2c1a",
  "prompt": "东京有哪些适合家庭入住的民宿?",
  "credits_used": 1,
  "answers": [
    {
      "engine": "chatgpt",
      "sample": 1,
      "status": "ok",
      "cached": false,
      "generated_at": "2026-11-02T00:31:12Z",
      "text": "……",
      "brand": {
        "mentioned": true,
        "mention_count": 2,
        "first_position": 3,
        "sentiment": "positive"
      },
      "entities": [
        {
          "name": "晓宅",
          "type": "brand",
          "position": 3,
          "is_competitor": false
        },
        {
          "name": "Example Stay",
          "type": "brand",
          "position": 1,
          "is_competitor": true
        }
      ],
      "citations": [
        {
          "url": "https://example.com/guide",
          "domain": "example.com",
          "position": 1,
          "is_brand_domain": false
        }
      ]
    }
  ]
}

# answers[].text 渲染后:

带孩子在东京住民宿,可以按这几家来挑:1. Example Stay 浅草,两居室带厨房,离地铁站 3 分钟;2. Sakura House 上野,有婴儿床可借;3. 晓宅 谷中店,独栋町屋改造,榻榻米房间适合小朋友,周边安静。如果更在意价格,晓宅 的平日价通常更低。

计费与 credits

只对实际返回的答案扣费;请求开始时按「prompt × 引擎 × 采样数」预占 credits,结束后多退少补。credits 一次性购买、永不过期。

调用每条答案扣费
GEO 数据,标准引擎(chatgpt、perplexity、grok、google-aio)1
GEO 数据,高成本引擎(gemini、claude)2
Index 分析(/v1/geo/index 在答案上计算 KPI)+1
缓存命中0
引擎超时、失败或无答案0
/v1/geo/index/summary、/v1/jobs、/v1/account0

响应头

响应头含义
x-credits-used本次请求实际扣除的 credits
x-credits-remaining扣除后的余额
x-cachehit、miss 或 partial(多条答案中部分命中)

cache

缓存键为 prompt + 引擎 + 地区 + 语言 + 采样序号,有效期 24 小时,跨账户共享。传 fresh: true 跳过缓存,按正常价格扣费。

credits.sh
# 预占 = prompt × 引擎 × 采样数;结束后按实际答案多退少补
$ dfg estimate --engines chatgpt,perplexity,gemini --samples 2 --index
chatgpt     1 × 2   = 2
perplexity  1 × 2   = 2
gemini      2 × 2   = 4
index       +1 × 6  = 6
──────────────────────
held                 14 credits

引擎与地区

engines 参数接受下面 6 个 id,一次请求可传多个;每个引擎单独计费、单独返回。

引擎 id平台每条答案扣费典型耗时
chatgptChatGPT1待实测
perplexityPerplexity1待实测
grokGrok1待实测
google-aioGoogle AI Overview1待实测
geminiGemini2待实测
claudeClaude2待实测
  • location:ISO 3166-1 两位国家代码,例如 JP、US;决定搜索结果和 AI Overview 的地区。默认 US。
  • language:BCP 47 语言代码,例如 ja、zh-CN、en。默认按 location 推断。
  • google-aio 只在搜索结果出现 AI Overview 时返回答案;没出现时 status 为 no_answer,不扣费。

获取 AI 答案

POST /v1/geo/answer [all plans]

拿一个 prompt 在多个引擎上的 AI 答案,并标出品牌提及、引用来源和竞品实体。所有档位可用。

参数

promptstring要问的问题,最长 2,000 字符
enginesstring[]引擎 id 列表,见「引擎与地区」
brandstring要识别的品牌名;不传则只返回答案和实体
brand_variantsstring[]品牌别名,例如片假名、英文名
competitorsstring[]竞品名,最多 20 个
locationstring国家代码,默认 US
languagestring语言代码,默认按 location 推断
samplesinteger每个引擎采样次数,1–10,默认 1
freshbooleantrue 时跳过缓存,默认 false
asyncbooleantrue 时立即返回 job_id,见「异步任务与账户」
webhook_urlstring异步完成后回调的地址

* = 必填

请求

bash
$ curl https://api.dataforgeo.dev/v1/geo/answer \
  -H "x-api-key: YOUR_API_KEY" \
  -H "content-type: application/json" \
  -d '{
    "prompt": "东京有哪些适合家庭入住的民宿?",
    "engines": [
      "chatgpt"
    ],
    "brand": "晓宅",
    "location": "JP",
    "language": "zh-CN"
  }'

响应

200 OK
{
  "request_id": "req_8f2c1a",
  "prompt": "东京有哪些适合家庭入住的民宿?",
  "credits_used": 1,
  "answers": [
    {
      "engine": "chatgpt",
      "sample": 1,
      "status": "ok",
      "cached": false,
      "generated_at": "2026-11-02T00:31:12Z",
      "text": "……",
      "brand": {
        "mentioned": true,
        "mention_count": 2,
        "first_position": 3,
        "sentiment": "positive"
      },
      "entities": [
        {
          "name": "晓宅",
          "type": "brand",
          "position": 3,
          "is_competitor": false
        },
        {
          "name": "Example Stay",
          "type": "brand",
          "position": 1,
          "is_competitor": true
        }
      ],
      "citations": [
        {
          "url": "https://example.com/guide",
          "domain": "example.com",
          "position": 1,
          "is_brand_domain": false
        }
      ]
    }
  ]
}
  • status 取值:ok、no_answer、timeout、failed;后三种不扣费。
  • first_position 是品牌在答案推荐列表中第一次出现的位次,未出现时为 null。

计算 GEO Index

POST /v1/geo/index [pro|scale|enterprise]

在 /v1/geo/answer 的结果上计算 GEO Index 的 KPI。Pro、Scale、Enterprise 可用;Starter 调用返回 403 plan_not_allowed。

参数与 /v1/geo/answer 相同,brand 改为必填,另加:

brandstring要计算 KPI 的品牌
tagstring自定义分组标签,例如 osaka-family-q4;/summary 按它汇总
intentstringprompt 意图:compare、cost、discover、evaluate、howto、recommend
personastring提问人群,自由文本,例如 带孩子的家庭

* = 必填

Starter → 403 plan_not_allowed升级到 Pro
bash
$ curl https://api.dataforgeo.dev/v1/geo/index \
  -H "x-api-key: YOUR_API_KEY" \
  -H "content-type: application/json" \
  -d '{
    "prompt": "大阪带孩子住哪里方便?",
    "engines": [
      "chatgpt",
      "perplexity",
      "grok"
    ],
    "brand": "晓宅",
    "tag": "osaka-family-q4",
    "intent": "recommend",
    "persona": "带孩子的家庭",
    "location": "JP",
    "language": "zh-CN"
  }'
200 OK
x-credits-used: 6

{
  "request_id": "req_91d0b3",
  "brand": "晓宅",
  "tag": "osaka-family-q4",
  "credits_used": 6,
  "answers": [
    "…与 /v1/geo/answer 相同…"
  ],
  "kpis": {
    "visibility": {
      "value": 0.667,
      "numerator": 2,
      "denominator": 3,
      "samples": 3
    },
    "share_of_voice": {
      "value": 0.25,
      "numerator": 2,
      "denominator": 8,
      "samples": 3
    },
    "top_rate": {
      "value": 0,
      "numerator": 0,
      "denominator": 3,
      "samples": 3
    },
    "competitor_gap": {
      "value": -1.33,
      "samples": 3
    },
    "positive_ratio": {
      "value": 1,
      "numerator": 2,
      "denominator": 2,
      "samples": 3
    }
  },
  "kpi_tier": "pro"
}
  • 上例为 3 个标准引擎各 1 条答案:3 × 1 credit + 3 × 1 credit Index = 6 credits。
  • kpi_tier 为 pro 时只返回核心 KPI;scale 时返回全部 KPI。
  • 单次请求的样本量小,KPI 仅供参考;趋势和对比请用 /v1/geo/index/summary。

Index 汇总与趋势

GET /v1/geo/index/summary [pro|scale|enterprise]

把账户里已经跑过的 /v1/geo/index 结果按时间窗口汇总成 KPI 和趋势,不产生新的 AI 调用,不扣费。Pro 可看总体与趋势;按维度拆分(group_by)仅 Scale 与 Enterprise。

参数

brandstring品牌名,与 index 请求一致
tagstring只汇总该标签下的请求
from / tostring时间窗口,ISO 8601;默认最近 30 天
intervalstring趋势粒度:day、week、month,默认 week
enginesstring逗号分隔,只看这些引擎
kpisstring逗号分隔,只返回这些 KPI;默认返回本档位全部
group_bystringengine、intent、persona、prompt,一次一个;仅 Scale [scale]

* = 必填

bash
$ curl "https://api.dataforgeo.dev/v1/geo/index/summary?brand=晓宅&tag=osaka-family-q4&interval=week&group_by=engine" \
  -H "x-api-key: YOUR_API_KEY"
200 OK
x-credits-used: 0

{
  "brand": "晓宅",
  "window": {
    "from": "2026-10-03T00:00:00Z",
    "to": "2026-11-02T00:00:00Z"
  },
  "answers_counted": 498,
  "kpis": {
    "findability": {
      "value": 42.1
    },
    "visibility": {
      "value": 0.262,
      "numerator": 130,
      "denominator": 498
    }
  },
  "series": [
    {
      "period": "2026-10-05",
      "visibility": 0.255,
      "share_of_voice": 0.018
    },
    {
      "period": "2026-10-12",
      "visibility": 0.263,
      "share_of_voice": 0.026
    }
  ],
  "groups": [
    {
      "key": "chatgpt",
      "answers_counted": 166,
      "kpis": {
        "visibility": {
          "value": 0.301
        }
      }
    },
    {
      "key": "gemini",
      "answers_counted": 166,
      "kpis": {
        "visibility": {
          "value": 0.241
        }
      }
    }
  ]
}
  • 部分 KPI 只在汇总里提供,单次 index 请求不返回,例如 knowledge_half_life、category_capture_gap。
  • 汇总只用本账户的 index 结果;跨账户共享的只是答案缓存,不共享 KPI 和标签。

异步任务与账户

多引擎、多采样的请求可能要等一两分钟,建议传 async: true:接口立即返回 job_id,结果用轮询或 webhook 取回。同步请求超过 120 秒会自动转为异步,并返回 202。

接口说明credits
GET /v1/jobs/{job_id}查询任务状态和结果0
GET /v1/account查询余额、档位、本月用量0
async
$ curl ... -d '{"async": true, ...}'
{
  "job_id": "job_3b7e90",
  "status": "queued",
  "credits_held": 9
}
$ watch -n 5 curl https://api.dataforgeo.dev/v1/jobs/job_3b7e90
queued → running → completed
GET /v1/account
{
  "plan": "scale",
  "credits_remaining": 10422,
  "credits_used_this_month": 1578
}
  • status 依次为 queued、running、completed 或 failed;completed 时 result 字段与同步响应相同。
  • credits_held 是预占的 credits,完成后按实际返回的答案结算,多余部分退回。
  • 传了 webhook_url 时,完成后向该地址 POST 完整结果,请求头带 x-dataforgeo-signature(HMAC-SHA256,密钥在控制台查看),用于验证来源。
  • 任务结果保留 7 天。

KPI 字段参考

Pro 返回 11 个核心 KPI,Scale 与 Enterprise 另加 8 个高阶 KPI。这里只给公开定义,不公开计算方法。

字段名称定义单位档位返回位置
findability综合可发现度品牌在 AI 答案中被发现、被推荐程度的综合分分pro单次与汇总
visibility可见度出现品牌的答案占比比例pro单次与汇总
own_mentions自有提及数平均每条答案提到品牌的次数次pro单次与汇总
citations引用数平均每条答案引用的来源数次pro单次与汇总
citation_rate引用率引用了品牌自有来源的答案占比比例pro单次与汇总
share_of_voice声量份额品牌提及占品牌加竞品提及的比例比例pro单次与汇总
competitor_mentions竞品提及数平均每条答案提到竞品的次数次pro单次与汇总
competitor_gap竞品差距自有提及数减竞品提及数次pro单次与汇总
top_rate首推率品牌排在推荐第一位的答案占比比例pro单次与汇总
positive_ratio正面比例品牌提及中正面评价的占比比例pro单次与汇总
tone语气得分提及品牌时的整体语气,-1 到 1分pro单次与汇总
weighted_share加权份额按提及位置加权后的声量份额比例scale仅汇总
rank_gap排名差距与每个竞品的推荐位次差,按竞品分别返回位scale单次与汇总
recommendation_position推荐位次指数品牌在推荐列表中位置的得分分scale单次与汇总
purchase_intent_rate购买意向推荐率购买意向类问题中品牌被推荐的比例比例scale单次与汇总
conclusion_bias结论推荐倾向答案结论是推荐还是劝退品牌,-1 到 1分scale单次与汇总
category_capture_gap品类捕获差品牌在所属品类问题中的捕获差距分scale仅汇总
knowledge_half_lifeAI 知识半衰期AI 对品牌认知的衰减周期周scale仅汇总
features特征提及答案中提到的品牌卖点列表列表scale单次与汇总
  • 比例类字段取值 0 到 1;带 numerator 和 denominator 的字段可以直接核对。
  • purchase_intent_rate 只统计 intent 为购买意向的 prompt,请求时需带 intent。

错误码与限制

出错时返回统一结构,且不扣费。单个引擎失败不会让整个请求报错:该条答案的 status 为 timeout 或 failed,不扣费,其余引擎照常返回。

HTTPcode含义
400invalid_request参数缺失或格式错误,message 指出具体字段
400unsupported_engineengines 里有不认识的引擎 id
401invalid_api_keyAPI key 缺失、错误或已停用
402insufficient_credits余额不够预占本次请求
403plan_not_allowed当前档位不能用该接口或参数,例如 Starter 调用 index、Pro 使用 group_by
404not_foundjob_id 不存在或已过期
500internal_error服务端错误,可用 request_id 联系支持
402
{
  "error": {
    "code": "insufficient_credits",
    "message": "本次请求需预占 9 credits,余额 4",
    "request_id": "req_7a11c2"
  }
}

limits

  • 不设账户级速率限制;为保证稳定,建议并发不超过 100 个请求(待压测确定)。
  • 每个请求最多 6 个引擎 × 10 次采样 = 60 条答案。
  • prompt 最长 2,000 字符;competitors 最多 20 个。
  • 缓存 24 小时,异步任务结果保留 7 天。

EOF