post_bulk_website_traffic
Submit multiple domain names to retrieve traffic estimates and location-based data for SEO analysis.
Instructions
Post bulk website traffic data to SEO Review Tools API.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| domains | Yes | An array of domain names to check traffic for. | |
| location | No | The location for the traffic data. | |
| hl | No | The language for the traffic data. |
Implementation Reference
- The core handler function `executeFunction` that performs the POST request to the SEO Review Tools API bulk website traffic endpoint, handling domains array, location, and language parameters, and returns the API response or error.const executeFunction = async ({ domains, location = 'United States', hl = 'English' }) => { const baseUrl = 'https://api.seoreviewtools.com/v2/bulk-website-traffic/'; const token = process.env.SEO_API_WORKSPACE_API_KEY; try { // Prepare the request body const body = JSON.stringify({ domains }); // Set up the URL with query parameters const url = new URL(baseUrl); url.searchParams.append('key', token); url.searchParams.append('location', location); url.searchParams.append('hl', hl); // Perform the fetch request const response = await fetch(url.toString(), { method: 'POST', headers: { 'Content-Type': 'application/json', 'X-API-Key': token }, body }); // Check if the response was successful if (!response.ok) { const errorData = await response.json(); throw new Error(errorData); } // Parse and return the response data const data = await response.json(); return data; } catch (error) { console.error('Error posting bulk website traffic data:', error); return { error: 'An error occurred while posting bulk website traffic data.' }; } };
- The JSON schema definition for the tool, including name 'post_bulk_website_traffic', description, input parameters (domains required array of strings, optional location and hl strings).type: 'function', function: { name: 'post_bulk_website_traffic', description: 'Post bulk website traffic data to SEO Review Tools API.', parameters: { type: 'object', properties: { domains: { type: 'array', items: { type: 'string', description: 'An array of domain names to check traffic for.' }, description: 'An array of domain names to check traffic for.' }, location: { type: 'string', description: 'The location for the traffic data.' }, hl: { type: 'string', description: 'The language for the traffic data.' } }, required: ['domains'] } } }
- tools/paths.js:5-5 (registration)The tool file path is registered in the toolPaths array, which is used by lib/tools.js to dynamically import and register the tool.'seo-api-workspace/seo-ap-is-seo-review-tools/post-bulk-website-traffic.js',
- lib/tools.js:7-16 (registration)The `discoverTools` function dynamically imports each tool file from toolPaths and extracts the `apiTool` object for registration, making 'post_bulk_website_traffic' available.export async function discoverTools() { const toolPromises = toolPaths.map(async (file) => { const module = await import(`../tools/${file}`); return { ...module.apiTool, path: file, }; }); return Promise.all(toolPromises); }