@open-dy/ai_coding_sdk 1.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (81) hide show
  1. package/LICENSE +176 -0
  2. package/README.md +38 -0
  3. package/dist/index.d.ts +1 -0
  4. package/dist/index.js +39 -0
  5. package/dist/openapi/account/ai_data.d.ts +20 -0
  6. package/dist/openapi/account/ai_data.js +7 -0
  7. package/dist/openapi/account/ai_items.d.ts +22 -0
  8. package/dist/openapi/account/ai_items.js +7 -0
  9. package/dist/openapi/account/ai_profile.d.ts +18 -0
  10. package/dist/openapi/account/ai_profile.js +7 -0
  11. package/dist/openapi/account/certification.d.ts +1 -0
  12. package/dist/openapi/account/certification.js +2 -0
  13. package/dist/openapi/account/device.d.ts +1 -0
  14. package/dist/openapi/account/device.js +2 -0
  15. package/dist/openapi/account/identity.d.ts +17 -0
  16. package/dist/openapi/account/identity.js +27 -0
  17. package/dist/openapi/account/index.d.ts +10 -0
  18. package/dist/openapi/account/index.js +14 -0
  19. package/dist/openapi/account/profile.d.ts +14 -0
  20. package/dist/openapi/account/profile.js +22 -0
  21. package/dist/openapi/account/realname.d.ts +1 -0
  22. package/dist/openapi/account/realname.js +2 -0
  23. package/dist/openapi/business/index.d.ts +1 -0
  24. package/dist/openapi/business/index.js +2 -0
  25. package/dist/openapi/comment/comment.d.ts +23 -0
  26. package/dist/openapi/comment/comment.js +15 -0
  27. package/dist/openapi/comment/index.d.ts +2 -0
  28. package/dist/openapi/comment/index.js +6 -0
  29. package/dist/openapi/content/follow.d.ts +37 -0
  30. package/dist/openapi/content/follow.js +15 -0
  31. package/dist/openapi/content/index.d.ts +6 -0
  32. package/dist/openapi/content/index.js +11 -0
  33. package/dist/openapi/content/recommend.d.ts +42 -0
  34. package/dist/openapi/content/recommend.js +7 -0
  35. package/dist/openapi/content/video.d.ts +12 -0
  36. package/dist/openapi/content/video.js +15 -0
  37. package/dist/openapi/core.d.ts +18 -0
  38. package/dist/openapi/core.js +119 -0
  39. package/dist/openapi/hot/hot.d.ts +15 -0
  40. package/dist/openapi/hot/hot.js +7 -0
  41. package/dist/openapi/hot/index.d.ts +2 -0
  42. package/dist/openapi/hot/index.js +5 -0
  43. package/dist/openapi/im/index.d.ts +1 -0
  44. package/dist/openapi/im/index.js +2 -0
  45. package/dist/openapi/index.d.ts +14 -0
  46. package/dist/openapi/index.js +35 -0
  47. package/dist/openapi/live/index.d.ts +1 -0
  48. package/dist/openapi/live/index.js +2 -0
  49. package/dist/openapi/platform/following.d.ts +14 -0
  50. package/dist/openapi/platform/following.js +16 -0
  51. package/dist/openapi/platform/index.d.ts +6 -0
  52. package/dist/openapi/platform/index.js +9 -0
  53. package/dist/openapi/platform/topic.d.ts +12 -0
  54. package/dist/openapi/platform/topic.js +16 -0
  55. package/dist/openapi/platform/user-basic.d.ts +20 -0
  56. package/dist/openapi/platform/user-basic.js +16 -0
  57. package/dist/openapi/relation/index.d.ts +1 -0
  58. package/dist/openapi/relation/index.js +2 -0
  59. package/dist/openapi/search/experience.d.ts +77 -0
  60. package/dist/openapi/search/experience.js +31 -0
  61. package/dist/openapi/search/general.d.ts +23 -0
  62. package/dist/openapi/search/general.js +15 -0
  63. package/dist/openapi/search/index.d.ts +16 -0
  64. package/dist/openapi/search/index.js +28 -0
  65. package/dist/openapi/search/live.d.ts +1 -0
  66. package/dist/openapi/search/live.js +2 -0
  67. package/dist/openapi/search/music.d.ts +35 -0
  68. package/dist/openapi/search/music.js +19 -0
  69. package/dist/openapi/search/poi.d.ts +47 -0
  70. package/dist/openapi/search/poi.js +12 -0
  71. package/dist/openapi/search/search.d.ts +138 -0
  72. package/dist/openapi/search/search.js +43 -0
  73. package/dist/openapi/search/user.d.ts +1 -0
  74. package/dist/openapi/search/user.js +2 -0
  75. package/dist/openapi/search/video.d.ts +1 -0
  76. package/dist/openapi/search/video.js +2 -0
  77. package/dist/openapi/search/vision.d.ts +37 -0
  78. package/dist/openapi/search/vision.js +50 -0
  79. package/dist/openapi/traffic/index.d.ts +1 -0
  80. package/dist/openapi/traffic/index.js +2 -0
  81. package/package.json +92 -0
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,35 @@
1
+ import type { CallOptions, OpenAPIResponse } from '../core';
2
+ export interface SearchMusicParams {
3
+ keyword: string;
4
+ cursor?: string;
5
+ count?: number;
6
+ }
7
+ /**
8
+ * 音乐搜索结果项。
9
+ */
10
+ export interface SearchMusicItem {
11
+ mid: string;
12
+ cover: string[];
13
+ author: string;
14
+ duration: number;
15
+ play_addr: string;
16
+ title: string;
17
+ tag: string;
18
+ doyin_share_url: string;
19
+ }
20
+ /**
21
+ * 音乐搜索响应数据。
22
+ */
23
+ export interface SearchMusicResponse {
24
+ cursor: number;
25
+ has_more: boolean;
26
+ result: SearchMusicItem[];
27
+ }
28
+ /**
29
+ * 抖音音乐搜索。
30
+ * @param params - 搜索参数
31
+ */
32
+ export declare function searchMusic(params: SearchMusicParams, options?: CallOptions): Promise<OpenAPIResponse<SearchMusicResponse>>;
33
+ /**
34
+ * 评论列表请求参数。
35
+ */
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.searchMusic = searchMusic;
4
+ const core_1 = require("../core");
5
+ /**
6
+ * 抖音音乐搜索。
7
+ * @param params - 搜索参数
8
+ */
9
+ async function searchMusic(params, options) {
10
+ return (0, core_1.callOpenAPI)({
11
+ path: '/dy_open_api/v1/search/music/',
12
+ method: 'GET',
13
+ queryParams: params,
14
+ domain: 'open.douyin.com',
15
+ }, options);
16
+ }
17
+ /**
18
+ * 评论列表请求参数。
19
+ */
@@ -0,0 +1,47 @@
1
+ import type { CallOptions, OpenAPIResponse } from '../core';
2
+ export interface PoiSearchParams {
3
+ keyword: string;
4
+ count: number;
5
+ cursor?: number;
6
+ search_id?: string;
7
+ device_id?: string;
8
+ sort_params?: {
9
+ filter_params?: Array<{
10
+ id?: string;
11
+ type?: string;
12
+ condition_field?: string;
13
+ condition_value?: string;
14
+ log_info?: {
15
+ data_id?: string;
16
+ };
17
+ log_text?: string;
18
+ }>;
19
+ rank_param?: {
20
+ id?: string;
21
+ type?: string;
22
+ condition_field?: string;
23
+ condition_value?: string;
24
+ log_info?: {
25
+ data_id?: string;
26
+ };
27
+ log_text?: string;
28
+ };
29
+ };
30
+ }
31
+ export interface PoiItem {
32
+ poi_id: string;
33
+ poi_name: string;
34
+ address: string;
35
+ city: string;
36
+ latitude: number;
37
+ longitude: number;
38
+ avg_price: number;
39
+ poi_image: string;
40
+ }
41
+ export interface PoiSearchResponse {
42
+ cursor: number;
43
+ has_more: boolean;
44
+ search_id: string;
45
+ data: PoiItem[];
46
+ }
47
+ export declare function searchPoi(params: PoiSearchParams, options?: CallOptions): Promise<OpenAPIResponse<PoiSearchResponse>>;
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.searchPoi = searchPoi;
4
+ const core_1 = require("../core");
5
+ async function searchPoi(params, options) {
6
+ return (0, core_1.callOpenAPI)({
7
+ path: '/dy_open_api/v1/search/poi/',
8
+ method: 'POST',
9
+ body: params,
10
+ domain: 'open.douyin.com',
11
+ }, options);
12
+ }
@@ -0,0 +1,138 @@
1
+ import type { CallOptions, OpenAPIResponse } from '../core';
2
+ export interface VideoSearchParams {
3
+ [key: string]: string | number | undefined;
4
+ device_id: number;
5
+ keyword: string;
6
+ count: number;
7
+ cursor?: number;
8
+ open_id?: string;
9
+ publish_time?: number;
10
+ search_id?: string;
11
+ sort_type?: number;
12
+ }
13
+ export interface VideoSearchItem {
14
+ item_id: string;
15
+ title: string;
16
+ cover: string;
17
+ create_time: number;
18
+ avatar: string;
19
+ nickname: string;
20
+ statistics: {
21
+ digg_count: number;
22
+ };
23
+ link: string;
24
+ }
25
+ export interface VideoSearchResponse {
26
+ video_list: VideoSearchItem[];
27
+ has_more: boolean;
28
+ cursor: number;
29
+ search_id: string;
30
+ }
31
+ /**
32
+ * 通用 OpenAPI 调用方法。
33
+ */
34
+ export declare function searchVideo(params: VideoSearchParams, options?: CallOptions): Promise<OpenAPIResponse<VideoSearchResponse>>;
35
+ /**
36
+ * 用户星座信息响应数据。
37
+ */
38
+ export interface SearchUserParams {
39
+ search_id?: string;
40
+ keyword: string;
41
+ cursor?: string;
42
+ count?: number;
43
+ }
44
+ /**
45
+ * 用户头像信息。
46
+ */
47
+ export interface AvatarThumb {
48
+ url_list: string[];
49
+ width: number;
50
+ height: number;
51
+ }
52
+ /**
53
+ * 搜索结果用户项。
54
+ */
55
+ export interface SearchUserItem {
56
+ nickname: string;
57
+ avatar_thumb: AvatarThumb;
58
+ custom_verify: string;
59
+ verification_type: number;
60
+ account_cert_info: string;
61
+ live_status: number;
62
+ room_id: number;
63
+ }
64
+ /**
65
+ * 搜索用户响应数据。
66
+ */
67
+ export interface SearchUserResponse {
68
+ cursor: number;
69
+ has_more: boolean;
70
+ search_id: string;
71
+ result: SearchUserItem[];
72
+ }
73
+ /**
74
+ * 搜索用户。
75
+ * @param params - 搜索参数
76
+ */
77
+ export declare function searchUser(params: SearchUserParams, options?: CallOptions): Promise<OpenAPIResponse<SearchUserResponse>>;
78
+ /**
79
+ * 搜索用户参数。
80
+ */
81
+ export interface SearchLiveParams {
82
+ search_id?: string;
83
+ keyword: string;
84
+ cursor?: string;
85
+ count?: number;
86
+ }
87
+ /**
88
+ * 直播作者信息。
89
+ */
90
+ export interface LiveAuthor {
91
+ nickname: string;
92
+ avatar_thumb: AvatarThumb;
93
+ }
94
+ /**
95
+ * 直播封面信息。
96
+ */
97
+ export interface LiveCover {
98
+ url_list: string[];
99
+ }
100
+ /**
101
+ * 直播原始数据。
102
+ */
103
+ export interface LiveRawData {
104
+ video_feed_tag: string;
105
+ id_str: string;
106
+ status: number;
107
+ cover: LiveCover;
108
+ title: string;
109
+ }
110
+ /**
111
+ * 直播信息。
112
+ */
113
+ export interface LiveInfo {
114
+ author: LiveAuthor;
115
+ rawdata: LiveRawData;
116
+ }
117
+ /**
118
+ * 搜索直播结果项。
119
+ */
120
+ export interface SearchLiveItem {
121
+ lives: LiveInfo;
122
+ }
123
+ /**
124
+ * 搜索直播响应数据。
125
+ */
126
+ export interface SearchLiveResponse {
127
+ data: SearchLiveItem[];
128
+ cursor: number;
129
+ has_more: boolean;
130
+ }
131
+ /**
132
+ * 搜索直播。
133
+ * @param params - 搜索参数
134
+ */
135
+ export declare function searchLive(params: SearchLiveParams, options?: CallOptions): Promise<OpenAPIResponse<SearchLiveResponse>>;
136
+ /**
137
+ * 图文搜索参数。
138
+ */
@@ -0,0 +1,43 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.searchVideo = searchVideo;
4
+ exports.searchUser = searchUser;
5
+ exports.searchLive = searchLive;
6
+ const core_1 = require("../core");
7
+ /**
8
+ * 通用 OpenAPI 调用方法。
9
+ */
10
+ async function searchVideo(params, options) {
11
+ return (0, core_1.callOpenAPI)({
12
+ path: '/dy_open_api/v1/search/video/',
13
+ method: 'GET',
14
+ queryParams: params,
15
+ }, options);
16
+ }
17
+ /**
18
+ * 搜索用户。
19
+ * @param params - 搜索参数
20
+ */
21
+ async function searchUser(params, options) {
22
+ return (0, core_1.callOpenAPI)({
23
+ path: '/dy_open_api/v1/search/discover/',
24
+ method: 'GET',
25
+ queryParams: params,
26
+ domain: 'open.douyin.com',
27
+ }, options);
28
+ }
29
+ /**
30
+ * 搜索直播。
31
+ * @param params - 搜索参数
32
+ */
33
+ async function searchLive(params, options) {
34
+ return (0, core_1.callOpenAPI)({
35
+ path: '/dy_open_api/v1/search/dy/live/',
36
+ method: 'GET',
37
+ queryParams: params,
38
+ domain: 'open.douyin.com',
39
+ }, options);
40
+ }
41
+ /**
42
+ * 图文搜索参数。
43
+ */
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,37 @@
1
+ import type { CallOptions, OpenAPIResponse } from '../core';
2
+ /**
3
+ * 视觉图搜请求参数
4
+ * image: 支持图片 URL、Blob、ArrayBuffer、Uint8Array 或 base64 编码的图片数据
5
+ */
6
+ export interface VisionSearchParams {
7
+ image: string | Blob | ArrayBuffer | Uint8Array;
8
+ _rticket: string;
9
+ ac: string;
10
+ os: string;
11
+ device_id: string;
12
+ os_version: string;
13
+ is_android_pad: string;
14
+ cpu_support_64: string;
15
+ language: string;
16
+ device_type: string;
17
+ host_abi: string;
18
+ resolution: string;
19
+ os_api: string;
20
+ device_brand: string;
21
+ device_platform: string;
22
+ is_android_fold: string;
23
+ dpi: string;
24
+ ts: string;
25
+ }
26
+ export interface VisionSearchItem {
27
+ item_id: string;
28
+ title: string;
29
+ cover: string;
30
+ author_name: string;
31
+ similarity: number;
32
+ }
33
+ export interface VisionSearchResponse {
34
+ business_config: Record<string, unknown>;
35
+ business_data: VisionSearchItem[];
36
+ }
37
+ export declare function searchVision(params: VisionSearchParams, options?: CallOptions): Promise<OpenAPIResponse<VisionSearchResponse>>;
@@ -0,0 +1,50 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.searchVision = searchVision;
4
+ const core_1 = require("../core");
5
+ /** 判断是否为 URL */
6
+ function isImageUrl(str) {
7
+ return /^https?:\/\//.test(str);
8
+ }
9
+ async function toImageBlob(image) {
10
+ if (image instanceof Blob) {
11
+ return image;
12
+ }
13
+ if (image instanceof ArrayBuffer) {
14
+ return new Blob([image]);
15
+ }
16
+ if (image instanceof Uint8Array) {
17
+ return new Blob([image]);
18
+ }
19
+ if (isImageUrl(image)) {
20
+ const resp = await fetch(image);
21
+ if (!resp.ok) {
22
+ throw new Error(`Download image failed: ${resp.status} ${resp.statusText}`);
23
+ }
24
+ return await resp.blob();
25
+ }
26
+ return new Blob([Buffer.from(image, 'base64')]);
27
+ }
28
+ /** 下载图片并转为 Blob */
29
+ async function downloadImageAsBlob(url) {
30
+ const resp = await fetch(url);
31
+ if (!resp.ok) {
32
+ throw new Error(`Download image failed: ${resp.status} ${resp.statusText}`);
33
+ }
34
+ return await resp.blob();
35
+ }
36
+ async function searchVision(params, options) {
37
+ const { image: _, ...queryParams } = params;
38
+ const imageBlob = typeof params.image === 'string' && isImageUrl(params.image)
39
+ ? await downloadImageAsBlob(params.image)
40
+ : await toImageBlob(params.image);
41
+ const formData = new FormData();
42
+ formData.append('image', imageBlob, 'image.jpg');
43
+ return (0, core_1.callOpenAPI)({
44
+ path: '/api/douyin/v1/search/vision_geneal/',
45
+ method: 'POST',
46
+ queryParams,
47
+ body: formData,
48
+ domain: 'open.douyin.com',
49
+ }, options);
50
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
package/package.json ADDED
@@ -0,0 +1,92 @@
1
+ {
2
+ "name": "@open-dy/ai_coding_sdk",
3
+ "version": "1.0.6",
4
+ "description": "AI Coding SDK — 抖音开放平台 OpenAPI 客户端与工具集",
5
+ "main": "dist/index.js",
6
+ "types": "dist/index.d.ts",
7
+ "files": [
8
+ "dist"
9
+ ],
10
+ "scripts": {
11
+ "build": "tsc",
12
+ "prepublishOnly": "tsc"
13
+ },
14
+ "publishConfig": {
15
+ "access": "public"
16
+ },
17
+ "keywords": [
18
+ "douyin",
19
+ "openapi",
20
+ "ai",
21
+ "coding",
22
+ "sdk",
23
+ "抖音"
24
+ ],
25
+ "license": "Apache-2.0",
26
+ "devDependencies": {
27
+ "typescript": "^5.0.0",
28
+ "@types/node": "^20.0.0"
29
+ },
30
+ "exports": {
31
+ ".": {
32
+ "types": "./dist/index.d.ts",
33
+ "default": "./dist/index.js"
34
+ },
35
+ "./openapi": {
36
+ "types": "./dist/openapi/index.d.ts",
37
+ "default": "./dist/openapi/index.js"
38
+ },
39
+ "./openapi/*": {
40
+ "types": "./dist/openapi/*.d.ts",
41
+ "default": "./dist/openapi/*.js"
42
+ },
43
+ "./openapi/account": {
44
+ "types": "./dist/openapi/account/index.d.ts",
45
+ "default": "./dist/openapi/account/index.js"
46
+ },
47
+ "./openapi/account/*": {
48
+ "types": "./dist/openapi/account/*.d.ts",
49
+ "default": "./dist/openapi/account/*.js"
50
+ },
51
+ "./openapi/content": {
52
+ "types": "./dist/openapi/content/index.d.ts",
53
+ "default": "./dist/openapi/content/index.js"
54
+ },
55
+ "./openapi/content/*": {
56
+ "types": "./dist/openapi/content/*.d.ts",
57
+ "default": "./dist/openapi/content/*.js"
58
+ },
59
+ "./openapi/search": {
60
+ "types": "./dist/openapi/search/index.d.ts",
61
+ "default": "./dist/openapi/search/index.js"
62
+ },
63
+ "./openapi/search/*": {
64
+ "types": "./dist/openapi/search/*.d.ts",
65
+ "default": "./dist/openapi/search/*.js"
66
+ },
67
+ "./openapi/hot": {
68
+ "types": "./dist/openapi/hot/index.d.ts",
69
+ "default": "./dist/openapi/hot/index.js"
70
+ },
71
+ "./openapi/hot/*": {
72
+ "types": "./dist/openapi/hot/*.d.ts",
73
+ "default": "./dist/openapi/hot/*.js"
74
+ },
75
+ "./openapi/comment": {
76
+ "types": "./dist/openapi/comment/index.d.ts",
77
+ "default": "./dist/openapi/comment/index.js"
78
+ },
79
+ "./openapi/comment/*": {
80
+ "types": "./dist/openapi/comment/*.d.ts",
81
+ "default": "./dist/openapi/comment/*.js"
82
+ },
83
+ "./openapi/platform": {
84
+ "types": "./dist/openapi/platform/index.d.ts",
85
+ "default": "./dist/openapi/platform/index.js"
86
+ },
87
+ "./openapi/platform/*": {
88
+ "types": "./dist/openapi/platform/*.d.ts",
89
+ "default": "./dist/openapi/platform/*.js"
90
+ }
91
+ }
92
+ }