API 文档

通过我们简洁的 REST API 将 IndexTensor 集成到您的应用中。

认证

所有 API 请求均需 Bearer 令牌认证。请在 Authorization 头中包含您的 API 令牌:

Authorization: Bearer YOUR_API_TOKEN

登录以获取 API 令牌。

接口

POST /api/links

提交链接以进行索引。链接可以分号分隔的字符串或数组形式提供。

请求体

// Option 1: Semicolon-separated string
{
  "links": "https://example.com/page1;https://example.com/page2"
}

// Option 2: Array of links
{
  "links": [
    "https://example.com/page1",
    "https://example.com/page2"
  ]
}

成功响应 (200)

{
  "status": 200,
  "msg": "Task created successfully",
  "data": {
    "units_used": 4,
    "task_id": "1721392204",
    "links_count": 4
  }
}

错误码

代码 说明
400 无效数据(JSON 格式错误、无效 URL)
401 缺少或格式错误的 Authorization 头
403 无效的 API 令牌
404 接口未找到
405 余额不足
429 超出频率限制
500 服务器内部错误

错误响应格式

{
  "status": 400,
  "message": "Task wasn't created: Invalid data provided"
}

频率限制与约束

  • 单次请求最大链接数: 20,000
  • URL 最大长度: 2,000 characters
  • 支持的协议: http:// and https://
  • 费用: 每条链接 1 单位
  • 频率限制: 每分钟 60 次请求

代码示例

curl -X POST https://indextensor.com/api/links \
  -H "Authorization: Bearer YOUR_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"links": ["https://example.com/page1", "https://example.com/page2"]}'