get-juejin-article-rank
Retrieve ranked technical articles from Juejin across categories like frontend, backend, AI, and mobile development to discover quality Chinese tech content.
Instructions
获取掘金文章榜,包含前端开发、后端技术、人工智能、移动开发及技术架构等领域的高质量中文技术文章和教程
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| category_id | No | 6809637769959178254 |
Implementation Reference
- src/tools/juejin.ts:49-86 (registration)Tool registration and configuration, including name, description, schema reference, and handler function reference.return { name: 'get-juejin-article-rank', description: '获取掘金文章榜,包含前端开发、后端技术、人工智能、移动开发及技术架构等领域的高质量中文技术文章和教程', zodSchema: juejinRequestSchema, func: async (args) => { const { category_id } = juejinRequestSchema.parse(args); const resp = await http.get<{ err_no: number; err_msg: string; data: any[]; }>('https://api.juejin.cn/content_api/v1/content/article_rank', { params: { category_id, type: 'hot', }, headers, }); if (resp.data.err_no !== 0) { throw new Error(resp.data.err_msg || '获取掘金文章榜失败'); } return resp.data.data.map((item) => { return { title: item.content.title, brief: item.content.brief || undefined, author: item.author.name, popularity: item.content_counter.hot_rank, view_count: item.content_counter.view, like_count: item.content_counter.like, collect_count: item.content_counter.collect, comment_count: item.content_counter.comment_count, interact_count: item.content_counter.interact_count, link: `https://juejin.cn/post/${item.content.content_id}`, }; }); }, };
- src/tools/juejin.ts:37-47 (schema)Dynamic Zod input schema for category_id, populated from fetched Juejin categories with default.const juejinRequestSchema = z.object({ category_id: z .union( categoryResp.data.data.map((item) => z.literal(item.category_id).describe(item.category_name)) as [ z.ZodLiteral<string>, z.ZodLiteral<string>, ], ) .optional() .default(categoryResp.data.data[0].category_id), });
- src/tools/juejin.ts:53-85 (handler)Handler function that fetches hot article rankings from Juejin API for the given category, handles errors, and maps response to structured output with title, author, counts, and link.func: async (args) => { const { category_id } = juejinRequestSchema.parse(args); const resp = await http.get<{ err_no: number; err_msg: string; data: any[]; }>('https://api.juejin.cn/content_api/v1/content/article_rank', { params: { category_id, type: 'hot', }, headers, }); if (resp.data.err_no !== 0) { throw new Error(resp.data.err_msg || '获取掘金文章榜失败'); } return resp.data.data.map((item) => { return { title: item.content.title, brief: item.content.brief || undefined, author: item.author.name, popularity: item.content_counter.hot_rank, view_count: item.content_counter.view, like_count: item.content_counter.like, collect_count: item.content_counter.collect, comment_count: item.content_counter.comment_count, interact_count: item.content_counter.interact_count, link: `https://juejin.cn/post/${item.content.content_id}`, }; }); },