跳转至

批量创建新闻

来源同步:/Users/mac/Projects/chatgpt-codex/doc/api_News.md

所属接口集:新闻资讯

请求 URL

POST /v1/api/news/batch-create

认证方式

Bearer Token(详见 认证与签名

接口概述

批量创建新闻文章。会检测请求内和数据库中的标题重复,若存在重复标题则拒绝创建。

请求参数

参数名 类型 必填 说明
articles array[object] 文章对象列表
articles[].title string 文章标题
articles[].url string 文章链接
articles[].published_at string 发布时间,ISO 格式,默认为当前时间
articles[].content string 文章内容
articles[].stock_code string 关联股票代码,逗号分隔
articles[].block_name string 关联板块名称,逗号分隔
articles[].source string 新闻来源
articles[].type int 新闻类型(1=新闻事件,2=公告,3=其他),默认 1

接口说明

  • articles 必须为非空数组,否则返回错误。
  • 会先检查请求内标题是否重复,再检查标题是否与数据库已有记录重复。若存在重复则拒绝创建,返回错误。
  • 若标题相同且 published_at 相同的记录已存在,则更新该记录而非重复插入。

响应格式示例

成功:

{
  "code": 1,
  "message": "success",
  "data": {
    "created": 2,
    "skipped": 0
  }
}
标题重复错误:
{
  "code": 0,
  "message": "failure",
  "data": {
    "error": "duplicate title"
  }
}
参数格式错误:
{
  "code": 0,
  "message": "failure",
  "data": {
    "error": "articles is required and must be a list"
  }
}

返回状态

状态码 说明
200 成功或业务错误(重复标题等)
400 参数错误
401 未认证
403 无权限