tiktok_shop_search
Search TikTok Shop products by keyword to retrieve scraped results with automatic parsing. Supports geolocation, country code, and device emulation for targeted queries.
Instructions
Scrape TikTok Shop Search results with automatic parsing
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| query | Yes | Search query for TikTok Shop products | |
| geo | No | Geolocation of the desired request, expressed as a country name | |
| jsRender | No | Should the request be opened in a headless browser, false by default | |
| country | No | Country code for the request (e.g., US, GB, DE) | |
| deviceType | No | Device type to emulate for the request |
Implementation Reference
- TiktokShopSearchTool class that implements the tool logic. The register() method (lines 21-58) contains the handler which calls sapiClient.scrape() with target 'tiktok_shop_search', then transforms the response by removing high-char-count fields ('suggested', 'refinements') from the nested data.
export class TiktokShopSearchTool extends Tool { toolset = TOOLSET.ECOMMERCE; private static FIELDS_WITH_HIGH_CHAR_COUNT = ['suggested', 'refinements']; transformResponse = ({ data }: { data: object }) => { for (const fieldToRemove of TiktokShopSearchTool.FIELDS_WITH_HIGH_CHAR_COUNT) { data = removeKeyFromNestedObject({ obj: data, keyToRemove: fieldToRemove }); } return { data: JSON.stringify(data) }; }; register = ({ server, sapiClient, auth }: ToolRegistrationArgs) => { server.registerTool( 'tiktok_shop_search', { description: 'Scrape TikTok Shop Search results with automatic parsing', inputSchema: { query: z.string().describe('Search query for TikTok Shop products'), geo: zodGeo, jsRender: zodJsRender, country: zodCountry, deviceType: zodDeviceType, }, annotations: { readOnlyHint: true, openWorldHint: true, }, }, async (scrapingParams: ScrapingMCPParams, extra: ProgressExtra) => { const params = { ...scrapingParams, target: SCRAPER_API_TARGETS.TIKTOK_SHOP_SEARCH, markdown: true, } satisfies ScraperAPIParams; const { data } = await sapiClient.scrape<object>({ auth, scrapingParams: params, extra }); const { data: text } = this.transformResponse({ data }); return { content: [ { type: 'text', text, }, ], }; } ); }; } - Input schema defining parameters: query (string), geo, jsRender, country, deviceType. Uses Zod validation with reusable zod types.
description: 'Scrape TikTok Shop Search results with automatic parsing', inputSchema: { query: z.string().describe('Search query for TikTok Shop products'), geo: zodGeo, jsRender: zodJsRender, country: zodCountry, deviceType: zodDeviceType, }, - src/server/sapi-base-server.ts:84-84 (registration)Tool instantiation in the allTools static array on the ScraperAPIBaseServer class, which is then registered via tool.register() in registerAllTools() or registerTools().
new TiktokShopSearchTool(), - src/server/sapi-base-server.ts:25-25 (registration)Import statement for TiktokShopSearchTool in the server file.
TiktokShopSearchTool, - src/constants.ts:30-30 (helper)The SCRAPER_API_TARGETS enum value TIKTOK_SHOP_SEARCH = 'tiktok_shop_search', used as the target parameter in the scraper API call.
TIKTOK_SHOP_SEARCH = 'tiktok_shop_search',