@tpmjs/tools-redirect-trace
Trace all HTTP redirects from a URL to its final destination. Follows redirect chains and returns each step with status codes, headers, and timing. Useful for debugging redirects, understanding URL shorteners, and analyzing redirect chains.
Test @tpmjs/tools-redirect-trace (redirectTraceTool) with AI-powered execution
0/2000 characters
Install this tool and use it with the AI SDK
npm install @tpmjs/tools-redirect-tracepnpm add @tpmjs/tools-redirect-traceyarn add @tpmjs/tools-redirect-tracebun add @tpmjs/tools-redirect-tracedeno add npm:@tpmjs/tools-redirect-traceimport { redirectTraceTool } from '@tpmjs/tools-redirect-trace';import { generateText } from 'ai';
import { openai } from '@ai-sdk/openai';
import { redirectTraceTool } from '@tpmjs/tools-redirect-trace';
const result = await generateText({
model: openai('gpt-4o'),
tools: { redirectTraceTool },
prompt: 'Your prompt here...',
});
console.log(result.text);Available configuration options
urlstringThe URL to trace (must be http or https)
maxRedirectsnumberMaximum number of redirects to follow (default: 10, max: 50)
Schema extracted: 1/1/2026, 8:18:50 AM
Trace all HTTP redirects from a URL to its final destination.
npm install @tpmjs/tools-redirect-trace
import { redirectTraceTool } from '@tpmjs/tools-redirect-trace'; // Use with AI SDK const result = await redirectTraceTool.execute({ url: 'https://bit.ly/example', maxRedirects: 10, }); console.log(result.steps); // Array of redirect steps console.log(result.finalUrl); // 'https://example.com/final-page' console.log(result.redirectCount); // 2 console.log(result.statusCodes); // [301, 302, 200]
url (string, required): The URL to trace (must be http or https)maxRedirects (number, optional): Maximum number of redirects to follow (default: 10, max: 50)Returns a RedirectTraceResult object:
{ steps: RedirectStep[]; // Array of redirect steps finalUrl: string; // Final URL after all redirects statusCodes: number[]; // Array of status codes redirectCount: number; // Number of redirects (steps - 1) totalTimeMs: number; // Total time to trace all redirects metadata: { startUrl: string; // Original URL tracedAt: string; // ISO timestamp maxRedirectsReached: boolean; // Whether max redirects limit was hit }; }
Each RedirectStep contains:
{ url: string; // The URL at this step statusCode: number; // HTTP status code statusText: string; // HTTP status text location: string | null; // Location header (next URL) headers: Record<string, string>; // Important response headers }
MIT
Downloads/month
0
Quality Score