get_website_traffic
Retrieve website traffic estimates and analytics data for any URL to analyze visitor volume and engagement metrics.
Instructions
Get website traffic data from SEO Review Tools.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| url | Yes | The URL of the website to get traffic data for. |
Implementation Reference
- The main handler function that fetches website traffic data from the SEO Review Tools API endpoint.const executeFunction = async ({ url }) => { const baseUrl = 'https://api.seoreviewtools.com'; const apiKey = process.env.SEO_API_WORKSPACE_API_KEY; try { // Construct the URL with query parameters const requestUrl = new URL(`${baseUrl}/website-traffic/`); requestUrl.searchParams.append('url', url); requestUrl.searchParams.append('key', apiKey); // Perform the fetch request const response = await fetch(requestUrl.toString(), { method: 'GET', headers: { 'Content-Type': 'application/json' } }); // 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 getting website traffic data:', error); return { error: 'An error occurred while getting website traffic data.' }; } };
- Tool schema definition including name, description, input parameters (url: string, required), for the get_website_traffic tool.definition: { type: 'function', function: { name: 'get_website_traffic', description: 'Get website traffic data from SEO Review Tools.', parameters: { type: 'object', properties: { url: { type: 'string', description: 'The URL of the website to get traffic data for.' } }, required: ['url'] } } }
- Exports the apiTool object which combines the handler function and schema definition for registration.const apiTool = { function: executeFunction, definition: { type: 'function', function: { name: 'get_website_traffic', description: 'Get website traffic data from SEO Review Tools.', parameters: { type: 'object', properties: { url: { type: 'string', description: 'The URL of the website to get traffic data for.' } }, required: ['url'] } } } }; export { apiTool };
- tools/paths.js:2-2 (registration)Lists the file path for the get_website_traffic tool in the toolPaths array used for dynamic loading.'seo-api-workspace/seo-ap-is-seo-review-tools/get-website-traffic.js',
- lib/tools.js:7-16 (registration)Dynamically imports and registers all tools, including get_website_traffic, by loading apiTool from each module specified in toolPaths.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); }