get-ifanr-news
Fetch curated tech updates from iFanr on products, gadgets, and internet trends. Use Trends Hub to stay informed on cutting-edge technology insights with customizable limits and offsets.
Instructions
获取爱范儿科技快讯,包含最新的科技产品、数码设备、互联网动态等前沿科技资讯
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| limit | No | ||
| offset | No |
Implementation Reference
- src/tools/ifanr.ts:13-33 (handler)The main handler function that parses input args, fetches news from ifanr API using http.get, processes the response, and maps to title, description, link.func: async (args: unknown) => { const { limit, offset } = ifanrRequestSchema.parse(args); const resp = await http.get<{ objects: any[]; }>('https://sso.ifanr.com/api/v5/wp/buzz', { params: { limit, offset, }, }); if (!Array.isArray(resp.data.objects)) { throw new Error('获取爱范儿快讯失败'); } return resp.data.objects.map((item) => { return { title: item.post_title, description: item.post_content, link: item.buzz_original_url || `https://www.ifanr.com/${item.post_id}`, }; }); },
- src/tools/ifanr.ts:4-7 (schema)Zod schema for input validation: optional limit (default 20) and offset (default 0). Used in handler and tool config.const ifanrRequestSchema = z.object({ limit: z.number().int().optional().default(20), offset: z.number().int().optional().default(0), });
- src/tools/ifanr.ts:9-34 (registration)Tool registration using defineToolConfig, setting name, description, schema, and handler function. Exported as default.export default defineToolConfig({ name: 'get-ifanr-news', description: '获取爱范儿科技快讯,包含最新的科技产品、数码设备、互联网动态等前沿科技资讯', zodSchema: ifanrRequestSchema, func: async (args: unknown) => { const { limit, offset } = ifanrRequestSchema.parse(args); const resp = await http.get<{ objects: any[]; }>('https://sso.ifanr.com/api/v5/wp/buzz', { params: { limit, offset, }, }); if (!Array.isArray(resp.data.objects)) { throw new Error('获取爱范儿快讯失败'); } return resp.data.objects.map((item) => { return { title: item.post_title, description: item.post_content, link: item.buzz_original_url || `https://www.ifanr.com/${item.post_id}`, }; }); }, });