百度关键词排名查询 API

服务地址:http://chaxun.kuaijiexitong.com/chaxun/platform/

📖 概述

本 API 提供百度PC端(前50名)和移动端(前50名)的关键词排名查询。您提交关键词和域名后,系统自动查询并返回任务ID,之后可通过任务ID获取排名结果。

REST JSON UTF-8

🔐 认证

每个请求必须携带 apikey,可通过URL参数或请求头传递:

  • ?apikey=YOUR_API_KEY
  • apikey: YOUR_API_KEY *(Header)
📌 请向服务提供方获取您的专属 apikey,并妥善保管。

📤 单个提交任务

GET / POST add_task.php

请求参数

参数类型必填说明
apikeystringAPI密钥
namestring关键词
urlstring域名(不带http://)
typeint1=百度PC, 4=百度移动

请求示例

curl "http://chaxun.kuaijiexitong.com/chaxun/platform/add_task.php?apikey=YOUR_KEY&name=SEO优化&url=example.com&type=1"

响应示例

{"code":1,"msg":"添加成功","time":1776144164,"data":"123"}

🔍 单个查询结果

GET / POST get_taskrank.php
参数类型必填说明
apikeystringAPI密钥
idint任务ID
curl "http://chaxun.kuaijiexitong.com/chaxun/platform/get_taskrank.php?apikey=YOUR_KEY&id=123"
{"code":1,"msg":"查询成功","time":1776149877,"data":8}

其他状态: {"code":0,"msg":"任务排队中"} / {"code":0,"msg":"任务查询中..."} / {"code":0,"msg":"查询失败,系统将自动重试"}

📦 批量提交任务

POST batch_add_task.php

Content-Type: application/json

curl -X POST "http://chaxun.kuaijiexitong.com/chaxun/platform/batch_add_task.php?apikey=YOUR_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "tasks": [
      {"name": "SEO优化", "url": "example.com", "type": 1},
      {"name": "移动排名", "url": "example.com", "type": 4}
    ]
  }'

响应字段

字段说明
success_tasks成功任务列表,含任务ID
fail_tasks失败任务及原因
total/success_count统计信息

📋 批量查询结果

GET / POST batch_get_rank.php
curl "http://chaxun.kuaijiexitong.com/chaxun/platform/batch_get_rank.php?apikey=YOUR_KEY&ids=101,102"
curl -X POST ... -d '{"ids":[101,102]}'
{
  "code": 1,
  "total": 2,
  "tasks": [
    {"id":101,"keyword":"SEO","status":2,"rank":8,"updated_at":"2026-04-15 10:23:45"},
    {"id":102,"keyword":"移动排名","status":2,"rank":51}
  ]
}

📊 状态码 status

含义建议操作
0待处理稍后重试
1处理中稍后重试
2已完成读取 rank 字段
3失败(自动重试)等待系统自动重试(5分钟后)
当 status=2 且 rank=51 时,表示未找到排名(PC前50名/移动前50名)。

⚠️ 常见错误码

错误信息原因
无效的API Key密钥错误或已过期
关键词和域名不能为空缺少必填参数
type必须是1或4搜索引擎类型错误
任务不存在任务ID无效
请提供 tasks 数组批量请求JSON格式错误

📌 注意事项

  • 每天凌晨自动清理当天之前的所有任务,请及时获取结果。
  • 批量提交建议不超过500个任务/次,避免超时。
  • 查询频率建议每秒不超过2次。
  • 若任务长时间处于 status=1 或 3(超过30分钟),请联系客服。