Languages

SitemapKit + TypeScript

Use SitemapKit with full TypeScript type safety. Define response types for sitemap data and integrate into your typed codebases.

Written by SitemapKit Editorial TeamUpdated: Jul 21, 2026

Prerequisites

  • A SitemapKit API key kept outside browser and mobile client bundles.
  • A server-side TypeScript environment that can make HTTPS requests and parse JSON responses.

How to connect SitemapKit and TypeScript

  1. 1

    Store the API key for TypeScript

    Use the secret or environment-variable mechanism provided by your languages setup. Never expose the key in client-side code.

  2. 2

    Call the SitemapKit full endpoint

    Adapt the request shown in the TypeScript example below and send the target domain from a trusted server process.

  3. 3

    Map the response in TypeScript

    Handle discovered sitemap files, extracted URLs, lastmod values, truncation flags, and API errors before passing the result downstream.

Quick start

type SitemapUrl = {
  loc: string;
  lastmod?: string;
  changefreq?: string;
  priority?: number;
};

type FullResponse = {
  sitemaps: string[];
  urls: SitemapUrl[];
  metadata: { totalUrls: number; cached: boolean };
};

async function getSitemapData(domain: string): Promise<FullResponse> {
  const res = await fetch("https://sitemapkit.com/api/v1/sitemap/full", {
    method: "POST",
    headers: {
      "Content-Type": "application/json",
      "x-api-key": process.env.SITEMAPKIT_API_KEY!,
    },
    body: JSON.stringify({ url: domain }),
  });

  if (!res.ok) throw new Error(`API error: ${res.status}`);
  return res.json() as Promise<FullResponse>;
}

const data = await getSitemapData("example.com");
console.log(`${data.urls.length} URLs extracted`);

Continue with SitemapKit

Start using SitemapKit with TypeScript

100 free API calls/month. No credit card required.

More Languages integrations