EditorAI 目前开放的公共 API 一共有 4 个接口,分别是:
下面分别描述。
API 地址:GET https://editorai.com/api/public/v1/ai_news
使用示例:
curl 'https://editorai.com/api/public/v1/ai_news?api_token=<你的 api token>'
返回 200 OK
{
"data": {
"news": [
{
"category": "中概股",
"content": "文章内容",
"created_at": "2017-02-06T07:57:34.597+08:00",
"id": 1,
"image_url": "https://editorai.com/picture_url",
"title": "文章标题"
},
{
"category": "科技股财报",
"content": "文章内容",
"created_at": "2017-02-06T07:57:34.597+08:00",
"id": 2,
"image_url": "https://editorai.com/picture_url",
"title": "文章标题2"
}
]
}
}
此接口接受 URL 参数
参数
意义
from
整数,返回第 n 个以后的新闻(按发布时间倒序)
limit
整数,最多返回 n 个新闻
created_after
时间戳,类似 "2016-01-01 00:00:00",只返回该时间后生成的新闻(UTC 时区)
category
字符串或字符串数组,比如 "中概股"
all
任意值,如果该参数存在,就无论是否已经发布,都返回。默认只返回未发布的 AI 新闻
示例:获取 2016 年 1 月 1 日 0 点(UTC)后的“中概股”和“科技股财报”的新闻,只取前 5 个结果:
curl -X GET "https://editorai.com/api/public/v1/ai_news?api_token=<你的 api token>&category%5B%5D=中概股&category%5B%5D=科技股财报&created_after=2016-01-01%2000:00:00&limit=5"
API 地址:GET https://editorai.com/api/public/v1/ai_news/:id
使用示例:获取 id = 1 的 AI 推送新闻
curl 'https://editorai.com/api/public/v1/ai_news/1?api_token=<你的 api token>'
返回 200 OK
:
{
"data": {
"news": {
"category": "中概股",
"content": "文章内容",
"created_at": "2017-02-06T07:57:34.597+08:00",
"id": 1,
"image_url": "https://editorai.com/picture_url",
"title": "文章标题"
}
}
}
API 地址:POST https://editorai.com/api/public/v1/ai_news/:id/publish
使用示例:把 id = 1 的 AI 推送新闻标记为“已发布”
curl -X POST 'https://editorai.com/api/public/v1/ai_news/1/publish?api_token=<你的 api token>'
如果成功,返回 201 Created
。
如果失败,返回 400 Bad Request
,失败的原因可能是先前已经标记为“已发布”或“无需发布”了。
API 地址:POST https://editorai.com/api/public/v1/ai_news/:id/reject
使用示例:把 id = 1 的 AI 推送新闻标记为“无需发布”
curl -X POST 'https://editorai.com/api/public/v1/ai_news/1/reject?api_token=<你的 api token>'
如果成功,返回 201 Created
。
如果失败,返回 400 Bad Request
,失败的原因可能是先前已经标记为“已发布”或“无需发布”了。