EhTagConnector
连接到 EhTagTranslation 数据库的 RESTful API。
Install / Use
/learn @EhTagTranslation/EhTagConnectorREADME
See https://github.com/EhTagTranslation/Editor
EhTagConnector <!-- omit in toc -->
连接到 EhTagTranslation 数据库的 RESTful API。
API 使用
API 域名
https://ehtagconnector.azurewebsites.net/api/
版本控制
使用 ETag 进行版本控制,其值为最新一次 Git commit 的 sha1 值。可以使用查询数据库数据版本 API 进行查询。
-
ETag将随HTTP 2XX及HTTP 404响应返回。 -
对于
HEAD,GET请求,可以使用If-None-Match控制缓存。 -
对于
POST,PUT,DELETE请求,必须使用If-Match头以防止编辑冲突。当未包含
If-Match头时,将返回HTTP 428 Precondition Required;当If-Match头的版本与最新版本不匹配时,将返回HTTP 412 Precondition Failed,此时需要使用对应的GET/HEAD请求更新ETag及相应的资源。
参考:HTTP 条件请求
用户认证
进行数据库修改(POST, PUT, DELETE 请求)时需要进行用户认证,需要的信息为用户的 GitHub token,可通过 OAuth 或 PAT 获取。该 token 只用于确认用户信息,不需要除 public access 外的特殊 scope。
认证信息通过 X-Token HTTP 头输入(如 X-Token: e9b35fc3cd731c11d4e535724b1e376bfc2b3104)。当缺少此头部或 token 无效时返回 HTTP 401 Unauthorized,具体错误原因可查询响应内容。
提交的显示效果如下:

返回格式
使用 Accept 头或 format URI 查询参数控制 API 返回 JSON 的格式,可选的值有:
-
Accept: application/json/?format=json默认设置,返回所有信息。
{ "name": { "raw": "轻音少女", "text": "轻音少女", "html": "<p>轻音少女</p>", "ast": [ { "type": "paragraph", "content": [ { "type": "text", "text": "轻音少女" } ] } ] }, "intro": { "raw": "", "text": "", "html": "<p><img src=\"https://ul.ehgt.org/ee/4f/ee4f3da314a2748030b53b9e495c8d20fd0d6fd5-1465878-5000-3501-jpg_l.jpg\" alt=\"图\" /></p>", "ast": [ { "type": "paragraph", "content": [ { "type": "image", "title": "", "url": "https://ul.ehgt.org/ee/4f/ee4f3da314a2748030b53b9e495c8d20fd0d6fd5-1465878-5000-3501-jpg_l.jpg", "nsfw": false, "content": [ { "type": "text", "text": "图" } ] } ] } ] }, "links": { "raw": "", "text": "", "html": "", "ast": [] } } -
Accept: application/raw+json/?format=raw.json仅返回
raw字段内容。{ "name": "轻音少女", "intro": "", "links": "" } -
Accept: application/html+json/?format=html.json仅返回
html字段内容。{ "name": "<p>轻音少女</p>", "intro": "<p><img src=\"https://ul.ehgt.org/ee/4f/ee4f3da314a2748030b53b9e495c8d20fd0d6fd5-1465878-5000-3501-jpg_l.jpg\" alt=\"图\" /></p>", "links": "" } -
Accept: application/text+json/?format=text.json仅返回
text字段内容。{ "name": "轻音少女", "intro": "", "links": "" } -
Accept: application/ast+json/?format=ast.json仅返回
ast字段内容。{ "name": [ { "type": "paragraph", "content": [ { "type": "text", "text": "轻音少女" } ] } ], "intro": [ { "type": "paragraph", "content": [ { "type": "image", "title": "", "url": "https://ul.ehgt.org/ee/4f/ee4f3da314a2748030b53b9e495c8d20fd0d6fd5-1465878-5000-3501-jpg_l.jpg", "nsfw": false, "content": [ { "type": "text", "text": "图" } ] } ] } ], "links": [] }
API Endpoints
所有示例可参见 examples.http,返回 JSON 对象的定义可参见 interface.d.ts。
查询数据库基本情况
路径: GET /database
示例请求:
GET /api/database
Accept: application/json
If-None-Match: "5bd33aed633b18d5bca6b2d8c66dcf6b56bd75b1"
示例响应:
HTTP/2.0 200 OK
Content-Type: application/json; charset=utf-8
ETag: "10ee33e7a348bf5842433944baa196da53eaa0df"
{
# Git 地址
"repo": "https://github.com/EhTagTranslation/Database.git",
# 最新一次提交信息
"head": {
"author": {
"name": "OpportunityLiu",
"email": "Opportunity@live.in",
"when": "2019-02-06T14:06:00+00:00"
},
"committer": {
"name": "EhTagApi-Bot",
"email": "47353891+EhTagApi-Bot@users.noreply.github.com",
"when": "2019-02-06T14:06:00+00:00"
},
"sha": "10ee33e7a348bf5842433944baa196da53eaa0df",
"message": "In parody: Added 'gotoubun no hanayome'.\n\nPrevious value: (non-existence)\nCurrent value: | gotoubun no hanayome | 五等分的新娘 | 《五等分的新娘》(日语:五等分の花嫁)是由日本漫画家春场葱所创作的少年漫画作品。于《周刊少年Magazine》2017年第36・37合并号开始正式连载中。 | [维基百科](https://zh.wikipedia.org/zh-cn/五等分的新娘) (\\*) |\n"
},
# 数据库结构版本
"version": 5,
# 数据库内容摘要
"data": [
{
"namespace": "rows",
"count": 9,
"frontMatters": {
"key": "rows",
"name": "内容索引",
"description": "标签列表的行名。"
}
}
# ...
]
}
如需获取数据库全部内容请参考获取数据库内容。
查询数据库数据版本
如只需获取 ETag 信息(即最新一次提交的 sha1),可以使用 HEAD 请求。
路径: HEAD /database
示例请求:
HEAD /api/database
If-None-Match: "5bd33aed633b18d5bca6b2d8c66dcf6b56bd75b1"
示例响应:
HTTP/2.0 204 No Content
ETag: "10ee33e7a348bf5842433944baa196da53eaa0df"
查询某一分类的信息
路径: GET /database/:namespace
示例请求:
GET /api/database/reclass
Accept: application/json
示例响应:
HTTP/2.0 200 OK
Content-Type: application/json; charset=utf-8
ETag: "d4553b638098466ef013567b319c034f8ee34950"
{
"namespace": "reclass",
"count": 11,
"frontMatters": {
"key": "reclass",
"name": "重新分类",
"description": "标签列表的重新分类(reclass)翻译。",
"copyright": "除有特殊说明外,本文的简介文本翻译自 EHWiki,遵循原始许可协议(即 GNU 自由文档许可证)进行二次分发。\n\nCopyright (c) 2017 EhTagTranslator-Wiki. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version published by the Free Software Foundation; with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. A copy of the license is included in the section entitled \"GNU Free Documentation License\".\n\n本文的其他内容,遵循知识共享(Creative Commons) 署名-非商业性使用-相同方式共享 3.0 协议提供。\n"
}
}
查询某一条目是否存在
路径: HEAD /database/:namespace/:raw
示例请求:
HEAD /api/database/reclass/private
示例响应:
HTTP/2.0 204 No Content
ETag: "d4553b638098466ef013567b319c034f8ee34950"
条目不存在则返回
HTTP 404 Not Found。
查询某一条目的翻译
路径: GET /database/:namespace/:raw
示例请求:
GET /api/database/male/shotacon?format=raw.json
Accept: application/json
示例响应:
HTTP/2.0 200 OK
Content-Type: application/raw+json; charset=utf-8
ETag: "d4553b638098466ef013567b319c034f8ee34950"
{
"name": "正太",
"intro": "小男孩。\n",
"links": ""
}
条目不存在则返回
HTTP 404 Not Found。
增加条目
路径: POST /database/:namespace/:raw
示例请求:
POST /api/database/parody/gotoubun%20no%20hanayome
X-Token: e9b35fc3cd731c11d4e535724b1e376bfc2b3104
If-Match: "5bd33aed633b18d5bca6b2d8c66dcf6b56bd75b1"
Content-Type: application/json
Accept: application/html+json
{
"name": "五等分的新娘",
"intro": "《五等分的新娘》(日语:五等分の花嫁)是由日本漫画家春场葱所创作的少年漫画作品。于《周刊少年Magazine》2017年第36・37合并号开始正式连载中。 ",
"links": "[维基百科](https://zh.wikipedia.org/zh-cn/五等分的新娘) (*)"
}
示例响应:
HTTP/2.0 201 Created
Content-Type: application/html+json; charset=utf-8
Location: /api/database/parody/gotoubun no hanayome
ETag: "d4553b638098466ef013567b319c034f8ee34950"
{
"name": "<p>五等分的新娘</p>",
"intro": "<p>《五等分的新娘》(日语:五等分の花嫁)是由日本漫画家春场葱所创作的少年漫画作品。于《周刊少年Magazine》2017年第36・37合并号开始正式连载中。</p>",
"links": "<p><a href=\"https://zh.wikipedia.org/zh-cn/五等分的新娘\" rel=\"nofollow\">维基百科</a> (*)</p>"
}
已有同名条目时将返回
HTTP 409 Conflict,需改用PUT请求。
修改条目
路径: PUT /database/:namespace/:raw
示例请求:
PUT /api/database/reclass/private
X-Token: e9b35fc3cd731c11d4e535724b1e376bfc2b3104
Content-Type: application/json
If-Match: "d4553b638098466ef013567b319c034f8ee34950"
{
"name": "私人的",
"intro": "私人画廊是一个非正式的类别,允许用户不与 E-Hentai 社区其他成员分享他们的内容。他们往往是想要成为自己的个人用户画廊,他们只是希望自己的朋友前来参观。",
"links": ""
}
``
Related Skills
node-connect
344.1kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
96.8kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
344.1kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
qqbot-media
344.1kQQBot 富媒体收发能力。使用 <qqmedia> 标签,系统根据文件扩展名自动识别类型(图片/语音/视频/文件)。
