Skip to main content
Glama
baranwang

Trends Hub

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
NameRequiredDescriptionDefault
category_idNo6809637769959178254

Implementation Reference

  • 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}`,
          };
        });
      },
    };
  • 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),
    });
  • 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}`,
        };
      });
    },

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/baranwang/mcp-trends-hub'

If you have feedback or need assistance with the MCP directory API, please join our Discord server