API v0文档

发布于 2022-05-01  44 次阅读


前情提要

此文档描述的是幻海API的正常请求方式

幻海API终结点

  • 存在refere限制)https://api.phantom-sea-limited.ltd
  • (正常)https://graph.phantom-sea-limited.ltd

v0设计初衷

v0版本一般用于接入qq机器人/幻海实验室官方等直接配置的直接访问,由于设计问题,大部分跨站访问都会出现由refer限制导致的403(此问题请使用graph域名进行服务,后续会更新APIv1)

当然,为了处理403错误,您也可以直接用反向代理进行规避(此处不做过多描述)

调用API v0

API v0没有设置安全认证,调用方式为GET,构造方法为在URL上直接添加api=True或api的请求参数,参考如下

具体功能

1.获取文件夹/文件信息

文件夹和文件的获取被整合,API会自动判断是否为文件/文件夹,统一请求样式如下

GET https://api.phantom-sea-limited.ltd/release/API/get?api&id={id}
GET https://graph.phantom-sea-limited.ltd/v0/get?api&id={id}

示例 · 获取文件

GET /release/API/get?api&id=01T4VX66252JUR65UFBRC245VREVKVYOBL
GET /v0/get?api&id=01T4VX66252JUR65UFBRC245VREVKVYOBL

HTTP/1.1 200 OK
Content-type: application/json

{
	"@odata.context": "https://graph.microsoft.com/v1.0/$metadata#...",
	"@microsoft.graph.downloadUrl": "https://kirinaire-my.sharepoint.com/personal...",
	"createdDateTime": "2021-06-12T04:00:38Z",
	"eTag": "\"{1F69D25D-8576-450C-AE76-B125555C382B},8\"",
	"id": "01T4VX66252JUR65UFBRC245VREVKVYOBL",
	"lastModifiedDateTime": "2021-07-05T07:35:40Z",
	"name": "robots.txt",
	"webUrl": "https://kirinaire-my.sharepoint.com/personal...",
	"cTag": "\"c:{1F69D25D-8576-450C-AE76-B125555C382B},3\"",
	"size": 101,
	"createdBy": {
		"application": {
			"id": "89b4a753-031a-4c47-95aa-168ce8418c8a",
			"displayName": "Mover OneDrive Single User"
		},
		"user": {
			"email": "helper@kirinaire.onmicrosoft.com",
			"id": "1c030ec3-aadb-4274-913e-1e89b01c1ae5",
			"displayName": "\u5de5 \u5177\u4eba"
		}
	},
	"lastModifiedBy": {
		"application": {
			"id": "89b4a753-031a-4c47-95aa-168ce8418c8a",
			"displayName": "Mover OneDrive Single User"
		},
		"user": {
			"email": "helper@kirinaire.onmicrosoft.com",
			"id": "1c030ec3-aadb-4274-913e-1e89b01c1ae5",
			"displayName": "\u5de5 \u5177\u4eba"
		}
	},
	"parentReference": {
		"driveType": "business",
		"driveId": "b!X9X2q6X_d0CZTtfwSemlkFk66k00O09PrgFKHYKfYZmdL9EGpHahS4-2GYu-WAZw",
		"id": "01T4VX6666ZAQ7SDF4TFCKV2VWDGHRZ4W5",
		"path": "/drive/root:/\u5e7b\u6d77\u56fe\u4e66\u9986"
	},
	"file": {
		"mimeType": "text/plain",
		"hashes": {
			"quickXorHash": "hw112XtGhbeBw/bfYT4SckwxDto="
		}
	},
	"fileSystemInfo": {
		"createdDateTime": "2021-06-12T04:00:38Z",
		"lastModifiedDateTime": "2021-07-05T07:35:40Z"
	}
}

关于返回值

属性类型说明
@microsoft.graph.downloadUrlstring一个可用于下载此文件的内容的 URL。不需要使用此 URL 进行身份验证。只读。
nameString项目名称(文件名和扩展名)。读写。
sizeInt64项目大小,以字节为单位。只读。
文件返回值信息,更多信息请前往此处

示例 · 获取文件夹子项目

GET /release/API/get?api&id=01T4VX66475746W4JUQZFIIRIGQHPBCIYX
GET /v0/get?api&id=01T4VX66475746W4JUQZFIIRIGQHPBCIYX

HTTP/1.1 200 OK
Content-type: application/json

{
  "value": [
    {"name": "myfile.jpg", "size": 2048, "file": {} },
    {"name": "Documents", "folder": { "childCount": 4} },
    {"name": "Photos", "folder": { "childCount": 203} },
    {"name": "my sheet(1).xlsx", "size": 197 }
  ],
  "@odata.nextLink": "https://..."
}

关于返回值

属性类型说明
@odata.nextLinkstring*一个指向下一部分文件列表内容的 URL。只读。
valuelist*文件列表
*非官方说明,更多信息请前往此处

2.获取文件缩略图

支持文件/文件夹获取缩略图,统一请求如下

GET https://api.phantom-sea-limited.ltd/release/API/get?api&thumbnails&id={id}
GET https://graph.phantom-sea-limited.ltd/v0/get?api&thumbnails&id={id}

示例 · 获取文件缩略图

GET /release/API/get?api&thumbnails&id=01T4VX663WXAY5VBAPRFAKTW7LL7QR72ZE
GET /v0/get?api&thumbnails&id=01T4VX663WXAY5VBAPRFAKTW7LL7QR72ZE

HTTP/1.1 200 OK
Content-type: application/json

{"thumbnail": "https://japaneast1-mediap.svc.ms/transform/thumbnail?provider=spo&inputFormat=png&cs=.."}
属性类型说明
thumbnailstring缩略图地址

示例 · 获取文件夹下文件缩略图

GET /release/API/get?api&thumbnails&id=01T4VX66475746W4JUQZFIIRIGQHPBCIYX
GET /v0/get?api&thumbnails&id=01T4VX66475746W4JUQZFIIRIGQHPBCIYX

HTTP/1.1 200 OK
Content-type: application/json

{
  "value": [
    {"name": "myfile.jpg", "size": 2048, "thumbnails": {...} },
    {"name": "Documents", "folder": { "childCount": 4} },
    {"name": "Photos", "folder": { "childCount": 203} },
    {"name": "my sheet(1).xlsx", "size": 197 , "thumbnails": {...} },
  ],
  "@odata.nextLink": "https://..."
}

关于返回值,和"获取文件夹子项目"内容一致,非文件夹项内会新增一个缩略图键thumbnails

3.搜索

GET https://api.phantom-sea-limited.ltd/release/API/search/Sharepoint?api&wd={search_word}
GET https://api.phantom-sea-limited.ltd/release/API/search/Graph?api&wd={search_word}
GET https://graph.phantom-sea-limited.ltd/v0/search/Sharepoint?api&wd={search_word}
GET https://graph.phantom-sea-limited.ltd/v0/search/Graph?api&wd={search_word}

推荐使用Sharepoint方式,目前Graph API出现异常2022111520221222

示例 · 搜索包含A的内容

GET /release/API/search/Sharepoint?api&wd=A
GET /v0/search/Graph?api&wd=A
HTTP/1.1 200 OK
Content-type: application/json

{
	"@odata.context": "https://graph.microsoft.com/v1.0/$metadata#Collection(driveItem)",
	"@odata.nextLink": "https://graph.microsoft.com/v1.0/me/drive/root/search(q='A')?skiptoken=..",
	"value": [{
		"@odata.type": "#microsoft.graph.driveItem",
		"id": "01T4VX664VNYT26ZN7GZC35WNL7VXMWHXO",
		"name": "[LY-RAW][Date_A_Live][ALL]"
	}, {
		"@odata.type": "#microsoft.graph.driveItem",
		"id": "01T4VX664MEHV73EMYCNFLKMOCPPH2G5UE",
		"name": "[LY-RAW][BDRIP][Date_A_Live_II]"
	}, {
		"@odata.type": "#microsoft.graph.driveItem",
		"id": "01T4VX662KK73FO3OM65FZQTY5SUVON5Q7",
		"name": "a"
	}, {
		"@odata.type": "#microsoft.graph.driveItem",
		"id": "01T4VX665YDRZ6OJLXXRB3RDTAD7D3GZ6J",
		"name": "A"
	}]
}
属性类型说明
@odata.nextLinkString*一个指向下一部分文件列表内容的 URL。只读。
idString项在驱动器中的唯一标识符。只读。
nameString项目名称(文件名和扩展名)。读写。
文件返回值信息,更多信息请前往此处

更多API请访问API v1文档

最后更新于 2023-12-11