get-ifanr-news
Retrieve technology news and updates from iFanr covering tech products, digital devices, and internet trends to stay informed on Chinese tech developments.
Instructions
获取爱范儿科技快讯,包含最新的科技产品、数码设备、互联网动态等前沿科技资讯
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| limit | No | ||
| offset | No |
Implementation Reference
- src/tools/ifanr.ts:13-33 (handler)The handler function that parses input arguments, makes an HTTP GET request to the Ifanr API, validates the response, and maps the news objects to a standardized format with title, description, and 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 validating input parameters: limit (default 20) and offset (default 0).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)Registers the tool using defineToolConfig, specifying name, description, schema, and handler function.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}`, }; }); }, });