Skip to main content
Glama
baranwang

Trends Hub

get-douyin-trending

Retrieve Douyin trending topics to discover current social discussions, entertainment events, and viral content trends.

Instructions

获取抖音热搜榜单,展示当下最热门的社会话题、娱乐事件、网络热点和流行趋势

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The core handler function for the 'get-douyin-trending' tool. It fetches a CSRF token, queries the Douyin hot search API, validates the response, and maps the data to a standardized format with title, event time, cover image, popularity, and link.
    func: async () => {
      const csrfToken = await getCsrfToken();
      const resp = await http.get<{
        status_code: number;
        data: {
          word_list: any[];
        };
      }>('https://www.douyin.com/aweme/v1/web/hot/search/list/', {
        params: {
          device_platform: 'webapp',
          aid: 6383,
          channel: 'channel_pc_web',
          detail_list: 1,
        },
        headers: {
          Cookie: `passport_csrf_token=${csrfToken}`,
        },
      });
      if (resp.data?.status_code !== 0 || !Array.isArray(resp.data.data.word_list)) {
        throw new Error('获取抖音热榜失败');
      }
      return resp.data.data.word_list.map((item) => {
        return {
          title: item.word,
          eventTime: dayjs.unix(item.event_time).toISOString(),
          cover: item.word_cover?.url_list?.[0],
          popularity: item.hot_value,
          link: `https://www.douyin.com/hot/${item.sentence_id}`,
        };
      });
    },
  • Helper function to extract CSRF token from Douyin's login strategy endpoint cookies, required for authenticated API requests.
    const getCsrfToken = async () => {
      try {
        const reps = await http.get('https://www.douyin.com/passport/general/login_guiding_strategy/', {
          params: {
            aid: 6383,
          },
        });
        const pattern = /passport_csrf_token=([^;]*); Path/;
        const matchResult = reps.headers['set-cookie']?.[0].match(pattern);
        const csrfToken = matchResult?.[1];
        return csrfToken;
      } catch (error) {
        return undefined;
      }
    };
  • Tool registration via defineToolConfig, defining the name, description, and handler. This config is dynamically loaded by the MCP server from the tools directory.
    export default defineToolConfig({
      name: 'get-douyin-trending',
      description: '获取抖音热搜榜单,展示当下最热门的社会话题、娱乐事件、网络热点和流行趋势',
      func: async () => {
        const csrfToken = await getCsrfToken();
        const resp = await http.get<{
          status_code: number;
          data: {
            word_list: any[];
          };
        }>('https://www.douyin.com/aweme/v1/web/hot/search/list/', {
          params: {
            device_platform: 'webapp',
            aid: 6383,
            channel: 'channel_pc_web',
            detail_list: 1,
          },
          headers: {
            Cookie: `passport_csrf_token=${csrfToken}`,
          },
        });
        if (resp.data?.status_code !== 0 || !Array.isArray(resp.data.data.word_list)) {
          throw new Error('获取抖音热榜失败');
        }
        return resp.data.data.word_list.map((item) => {
          return {
            title: item.word,
            eventTime: dayjs.unix(item.event_time).toISOString(),
            cover: item.word_cover?.url_list?.[0],
            popularity: item.hot_value,
            link: `https://www.douyin.com/hot/${item.sentence_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