openapi: '3.1.0' info: version: '1.0.0' title: 'CNKGraph.com 开放 API' description: 可用于浏览或获取 CNKGraph.com 网站的所有知识图谱数据 servers: - url: https://open.cnkgraph.com description: 古典文献知识图谱网开放 API 网站 paths: /api/Writing: description: 获取各朝诗文作品总览 get: responses: '200': description: 返回诗文库已收录各朝各有多少作者多少作品 content: application/json: schema: $ref: '#/components/schemas/WritingOverview' /api/Writing/{id}: description: 获取某一作品的内容或某一朝代含哪些作家。 parameters: - name: id description: 作品Id、或朝代名称、或作家名称 in: path required: true schema: type: string get: responses: '200': description: 返回某一作品的内容或某一朝代含哪些作家 content: application/json: schema: $ref: '#/components/schemas/WritingOrAuthors' /api/Writing/{dynasty}/{author}: description: 获取某朝某作家的作品 parameters: - name: dynasty description: 朝代 in: path required: true schema: $ref: '#/components/schemas/Dynasty' - name: author description: 作家 in: path required: true schema: type: string - name: pageNo description: 页码,从0开始,每页20首 in: query required: false schema: type: integer get: responses: '200': description: 返回某朝某作家的作品。如作品数超过20首,那么结果将分页显示 content: application/json: schema: $ref: '#/components/schemas/AuthorWritings' /api/Writing/{dynasty}/{author}/{authorId}: description: 获取某朝某作家的作品 parameters: - name: dynasty description: 朝代 in: path required: true schema: $ref: '#/components/schemas/Dynasty' - name: author description: 作家 in: path required: true schema: type: string - name: authorId description: 作家Id,一些作家未建立档案,没有Id,这时可不填 in: path required: true schema: type: integer - name: pageNo description: 页码,从0开始,每页20首 in: query required: false schema: type: integer get: responses: '200': description: 返回某朝某作家的作品。如作品数超过20首,那么结果将分页显示 content: application/json: schema: $ref: '#/components/schemas/AuthorWritings' /api/Writing/{dynasty}/{author}/{authorId}/{writingType}: description: 获取某朝某作家某一类作品 parameters: - name: dynasty description: 朝代 in: path required: true schema: $ref: '#/components/schemas/Dynasty' - name: author description: 作家 in: path required: true schema: type: string - name: authorId description: 作家Id,一些作家未建立档案,没有Id,这时可不填 in: path required: true schema: type: integer - name: writingType description: 作品体裁 in: path required: true schema: $ref: '#/components/schemas/WritingType' - name: pageNo description: 页码,从0开始,每页20首 in: query required: false schema: type: integer get: responses: '200': description: 返回某朝某作家某一类作品。如作品数超过20首,那么结果将分页显示 content: application/json: schema: $ref: '#/components/schemas/AuthorWritings' /api/Writing/SimilarClauses/{key}: description: 获取作品库中与某一作品中各句,或指定输入类似的句子。如果是指定句子,句子的长度至少为4。 parameters: - name: key description: 作品Id或者具体的诗句(可以是不存在于cnkgraph.com中的句子) in: path required: true schema: type: string get: responses: '200': description: 返回来自诗文库与指定作品中各句类似的句子 content: application/json: schema: $ref: '#/components/schemas/SimilarClauses' /api/Writing/SameRhymes/{key}: description: 获取诗文库中与某一作品(可以是非库中作品)韵脚相同的作品。 parameters: - name: key description: 诗文库中作品Id或者另外指定的诗作(可以是不存在于cnkgraph.com中的句子) in: path required: true schema: type: string get: responses: '200': description: 返回来自诗文库与指定作品中韵脚用字相同的作品 content: application/json: schema: $ref: '#/components/schemas/SameRhymes' /api/Writing/Couplet/{key}: description: 获取含指定对仗词汇的律句 parameters: - name: key description: 以英文逗号为分隔的一字、二字或三字对仗词汇。如“天地,古今” in: path required: true schema: type: string get: responses: '200': description: 返回含指定对仗词汇的律句 content: application/json: schema: $ref: '#/components/schemas/Couplets' /api/Writing/{id}/Tones: description: 为作品内容逐字标注平仄 parameters: - name: id description: 作品Id in: path required: true schema: type: integer get: responses: '200': description: 返回带平仄标注的作品 content: application/json: schema: $ref: '#/components/schemas/WritingWithTones' /api/Writing/{id}/BookLinks: description: 获取作品在古籍库中的出处及引用情况 parameters: - name: id description: 作品Id in: path required: true schema: type: integer - name: pageNo description: 页码,从0开始,每页100首 in: query required: false schema: type: integer get: responses: '200': description: 返回作品在古籍库中的出处及引用情况 content: application/json: schema: $ref: '#/components/schemas/BookLinks' /api/Writing/Find: description: 按组合条件检索作品 post: requestBody: content: 'application/json': schema: type: object properties: key: description: 关键词 type: string exactlyMatch: description: 是否精确匹配,默认为 false type: boolean showMatchedClauseOnly: description: 是否只返回匹配到的句子,默认为 false type: boolean clauseIndex: description: 在哪个位置搜索指定关键词 schema: $ref: '#/components/schemas/ClauseIndex' charIndex: description: 从句中第几字开始搜索 type: integer author: description: 作者关键词 type: string authorSearchScope: description: 作者关键词的搜索范围 schema: $ref: '#/components/schemas/AuthorSearchScope' dynasty: description: 朝代 schema: $ref: '#/components/schemas/Dynasty' writingType: description: 体裁 schema: $ref: '#/components/schemas/WritingType' rhyme: description: 韵部 schema: $ref: '#/components/schemas/Rhyme' labelKey: description: 仅在含有指定标签的作品中进行搜索 type: string pageNo: description: 页码,从0开始,每页20首 type: integer responses: '200': description: 返回搜索结果,因条件不同,返回内容 schema 也会不同 content: application/json: schema: $ref: '#/components/schemas/WritingSearchResult' /api/Calendar: description: 年历资源总览 get: responses: '200': description: 返回年历资源的总体状况 content: application/json: schema: $ref: '#/components/schemas/CalendarOverview' components: schemas: Dynasty: description: 朝代 type: type: string enum: - 先秦 - 秦朝 - 汉朝 - 魏晋 - 南北朝 - 隋朝 - 唐朝 - 宋朝 - 金朝 - 辽朝 - 元朝 - 明朝 - 清朝 - 近现代 - 当代 WritingType: description: 作品体裁,以下 enum 分别对应体裁:“绝句”,“律诗”,“五绝”,“七绝”,“五律”,“七律”,“排律”,“五排”,“七排”,“律诗或排律”,“五言律绝”,“七言律绝”,“词”,“散曲”,“古体”,“五言古体”,“七言古体”,“乐府”,“古体、乐府”,“骚”,“四言”,“五言”,“六言”,“七言”,“偈、颂”,“联”,“赋”,“其他” type: type: string enum: - Jue - Lv - WuJue - QiJue - WuLv - QiLv - Pai - WuPai - QiPai - LvPai - WuYanLvJie - QiYanLvJie - Ci - Qu - GuFeng - WuGu - QiGu - YueFu - GuYue - Sao - SiYan - WuYan - LiuYan - QiYan - Jie - Lian - Fu - Others ClauseIndex: description: 位置信息,以下 enum 分别对应:“题目”,“内容”,“诗文中上下句”,“律诗中一联”,以及第 N 句 type: type: string enum: - title - content - sentence - couplet - '0' - '1' - '2' - '3' - '4' - '5' - '6' - '7' - '8' AuthorSearchScope: description: 作者关键词搜索范围,以下 enum 分别对应:姓、字、号、谥号、封爵 type: type: string enum: - Xing - Zi - Hao - ShiHao - FengJue Rhyme: description: 平水韵或词林正韵韵部信息。平水韵用韵部单字名称,词林正韵用0-32序号,分别表示第一部至第十九部韵目,如,“0”代表“第一部 东冬通押”,“1”代表“第一部 仄声 董肿送宋通押” type: type: string enum: - 东 - 冬 - 江 - 支 - 微 - 鱼 - 虞 - 齐 - 佳 - 灰 - 真 - 文 - 元 - 寒 - 删 - 先 - 萧 - 肴 - 豪 - 歌 - 麻 - 阳 - 庚 - 青 - 蒸 - 尤 - 侵 - 覃 - 盐 - 咸 - 董 - 肿 - 讲 - 纸 - 尾 - 语 - 麌 - 荠 - 蟹 - 贿 - 轸 - 吻 - 阮 - 旱 - 潸 - 铣 - 筱 - 巧 - 皓 - 哿 - 马 - 养 - 梗 - 迥 - 有 - 寢 - 感 - 俭 - 豏 - 送 - 宋 - 绛 - 寘 - 未 - 御 - 遇 - 霁 - 泰 - 卦 - 队 - 震 - 问 - 愿 - 翰 - 谏 - 霰 - 啸 - 效 - 号 - 个 - 祃 - 漾 - 敬 - 径 - 宥 - 沁 - 勘 - 艳 - 陷 - 屋 - 沃 - 觉 - 质 - 物 - 月 - 曷 - 黠 - 屑 - 药 - 陌 - 锡 - 职 - 缉 - 合 - 叶 - 洽 - '0' - '1' - '2' - '3' - '4' - '5' - '6' - '7' - '8' - '9' - '10' - '11' - '12' - '13' - '14' - '15' - '17' - '18' - '19' - '20' - '21' - '23' - '25' - '26' - '27' - '28' - '29' - '30' - '31' - '32' WritingOverview: type: object properties: Total: description: 诗文库共有多少作品 type: integer Dynasties: type: type: array items: type: object properties: Dynasty: type: string AuthorCount: type: integer WritingCount: type: integer WritingOrAuthors: type: object properties: Writing: type: type: object schema: $ref: '#/components/schemas/Writing' Links: type: array items: schema: $ref: '#/components/schemas/Link' AuthorsByDynasty: type: type: object properties: description: 朝代名称 Name: type: string AuthorCount: type: integer WritingCount: type: integer Dynasties: $ref: '#/components/schemas/AuthorInDynasties' AuthorInDynasties: type: array items: type: object properties: description: 细分时段或朝代名称 Name: type: string Authors: type: array items: type: object properties: Id: type: integer Name: type: string Surname: type: string Life: description: 作者生卒信息 type: string WritingCount: type: integer Writing: type: object properties: Id: type: integer GroupIndex: description: 如果是成组的作品,那么 GroupIndex 大于零,指第几首 type: integer Classes: description: 作品的分类信息,目前只少数作品具有此属性,如军旅类 type: array items: type: string Froms: description: 作品录入来源 type: array items: type: string Allusions: description: 作品内容中引用了哪些典故,目前仅部分唐诗具备此信息 type: array items: type: object properties: AllusionIndex: description: 典故索引标号 type: integer AllusionKey: description: 典故名称 SentenceIndex: description: 作品中哪一句子引用了本典故 type: integer Pictures: description: 与本作品有关的图片,目前主要是诗经类作品有此信息 type: array items: type: string Dynasty: type: string Author: type: string AuthorId: type: integer AuthorDate: description: 创作日期,多数作品不具备 type: string AuthorPlace: description: 创作地点,多数作品不具备 type: string Type: description: 体裁 type: string TypeDetail: description: 细分体裁信息 schema: $ref: '#/components/schemas/writingType' Rhyme: description: 作品所押韵部 schema: $ref: '#/components/schemas/rhyme' Title: description: 作品题目 schema: $ref: '#/components/schemas/Clause' SubTitle: description: 副标题,常出现在组诗中 TuneId: description: 如果本作品是词作,那么此处指出该作品用了哪一个词牌 type: object schema: properties: Name: description: 词牌名 type: string Id: description: 词牌Id type: integer Preface: description: 序 type: string Clauses: description: 作品内容 type: array items: $ref: '#/components/schemas/Clause' Note: description: 对整首作品的按语、作者自注、跋等 type: string Comments: description: 对作品的赏析、评价等 type: object schema: $ref: '#/components/schemas/Quote' Links: description: 作品中的标签信息 type: array items: type: object schema: $ref: '#/components/schemas/Link' Clause: description: 句 type: object properties: description: 句子内容 Content: type: string Tones: description: 平仄句式 type: integer Comments: description: 句内注释 type: array items: schema: $ref: '#/components/schemas/Comment' BreakAfter: description: 显示本句时,是否宜在此句之后加上换行符,以区分上下文。 Comment: description: 注释 type: object properties: Category: description: 注释来源 type: string Content: description: 注释内容 required: true type: string Type: description: 注释内容的数据类型,默认是 Text type: string enum: - Text - CharDictInJson - WordDictInJson - AllusionKey - Image Index: description: 注释在句子中的位置 Quote: description: 引用片段 type: object properties: Book: description: 出自哪一本书 type: string Section: description: 出自书中哪一节 Content: description: 引用内容 required: true type: string IsComment: description: 是否作品评论类 type: boolean ReferrenceUrls: description: 引用外部资源网址,例如来自《词学图录》的图片 type: array items: type: string AuthorWritings: description: 作者作品集合 type: object properties: Name: type: string Surname: type: string Life: description: 作者生卒信息 type: string Dynasty: type: string Id: description: 作者 id WritingCount: type: integer PageNo: type: integer PageSize: type: integer Writings: type: array items: $ref: '#/components/schemas/writing' WritingCountByTypes: type: array items: properties: Count: type: integer TypeName: description: 体裁名称 type: string TypeValue: $ref: '#/components/schemas/writingType' SimilarClauses: description: 相似句子 type: array items: OriginalClause: description: 原句 type: string SimilarClauses: description: 相似句 type: array items: Author: type: string Title: type: string Dynasty: type: string Content: type: string Id: description: 作品Id type: integer Index: description: 句子在作品中的位置(从0开始) SameRhymes: description: 同韵脚作品 type: array items: properties: Id: description: 作品Id type: integer Author: type: string Title: type: string Dynasty: type: string Couplets: description: 含指定对仗词汇的律句集合 type: object properties: Word1: description: word1和word2构成互为对仗的词汇组 type: string Word2: type: string Couplets: type: array items: $ref: '#/components/schemas/writingSentence' WritingSentence: properties: WritingId: type: integer Author: type: string Title: type: string Sentence: description: 律中一联 type: string WritingWithTones: description: 带平仄标注的作品 properties: Writing: $ref: '#/components/schemas/writing' ClauseTones: description: 作品中每一句的平仄信息 type: array items: description: 句中每一字的平仄信息 type: array items: properties: Character: description: 字 type: string Tone: description: 平仄,内容为“平上去入”的各种组合 type: string BookLinks: description: 资源片段在古籍库中的上下文内容和位置信息 properties: Froms: description: 录入来源 type: array items: type: string ResourceType: $ref: '#/components/schemas/resourceType' ResourceId: description: 资源Id type: integer Count: description: 共有多少条出处和引用信息 type: integer PageSize: description: 每一页包含多少首 type: integer PageNo: type: integer Links: type: array items: Book: type: string Volumn: description: 卷目名 type: string VolumnId: description: 卷目Id type: string StartPage: description: 起始页码 type: string EndPage: description: 起始页码 type: string Start: description: 起始页中起始位置 type: integer Length: description: 内容长度 type: integer MatchedText: description: 匹配到的内容 type: string PreviousText: description: 匹配到的内容的前文 type: string LaterText: description: 匹配到的内容的后文 type: string PageImages: description: 与匹配到的内容对应的影印图片网址 type: array items: type: string ResourceType: type: string enum: - Poem - Author - Book - Activity WritingSearchResult: description: 诗文库搜索结果 properties: Notification: description: 通知消息。搜索过程中,如果因容错需要而做了一些特殊处理,那么将通过本属性告知客户端 AuthorWritings: description: 如果是按作者搜索,并且只找到一位作者时,返回该作者的作品信息 type: $ref: '#/components/schemas/authorWritings' Dynasties: description: 如果是按作者搜索,并且只找到多于一位作者时,按朝代分组展示搜索到的作者信息 type: $ref: '#/components/schemas/authorInDynasties' WrtingCount: description: 当按关键词搜索时,匹配到的作品数 PageSize: description: 每一页包含多少首 type: integer PageNo: type: integer MatchedKeys: description: 匹配到的关键词 type: array items: type: string Writings: description: 匹配到的作品,当多于20首时,将分页返回。 type: array items: $ref: '#/components/schemas/writing' WritingSetences: description: 如搜索选项 showMatchedClauseOnly 为true,那么返回匹配到的句子,而不是作品全文 type: array items: $ref: '#/components/schemas/WritingSentence' Link: type: object properties: LabelType: $ref: '#/components/schemas/LabelType' LabelIdentity: description: 标签Id type: string LabelDescription: description: 标签描述信息 type: string ResourceType: $ref: '#/components/schemas/resourceType' ResourceId: type: integer ResourcePath: description: 资源链接的相对路径 type: string Value: description: 标签值 type: string Start: description: 标签值在resourcePath所指的内容中的起始位置 type: integer Length: description: 标签值在resourcePath所指的内容中的长度 type: integer Weight: description: 标签的置信度,数值越小越高 type: integer IsDeleted: description: 标签是否已经被删除 type: boolean LabelType: description: 标签类型 type: string enum: - Other - People - Title - CiTune - QuTune - Poem - Region - Scenery - Plant - Flower - Fruit - DateTime - MonthDay - Year - TimeSpan - Vocabulary - CountAndIndex - Alias - Empire - PeopleClass