Languages

SitemapKit + PHP

Call the SitemapKit API from PHP using cURL. Ideal for WordPress plugins, Laravel applications, and PHP-based SEO tools.

Written by SitemapKit Editorial TeamUpdated: Jul 21, 2026

Prerequisites

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

How to connect SitemapKit and PHP

  1. 1

    Store the API key for PHP

    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 PHP example below and send the target domain from a trusted server process.

  3. 3

    Map the response in PHP

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

Quick start

<?php
$apiKey = 'YOUR_API_KEY';

$ch = curl_init('https://sitemapkit.com/api/v1/sitemap/full');
curl_setopt_array($ch, [
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_POST => true,
    CURLOPT_HTTPHEADER => [
        'Content-Type: application/json',
        "x-api-key: $apiKey",
    ],
    CURLOPT_POSTFIELDS => json_encode(['url' => 'example.com']),
]);

$response = curl_exec($ch);
curl_close($ch);

$data = json_decode($response, true);
echo "Found " . count($data['sitemaps']) . " sitemaps\n";
echo "Extracted " . count($data['urls']) . " URLs\n";

// Filter blog posts
$blogUrls = array_filter($data['urls'], function($u) {
    return strpos($u['loc'], '/blog/') !== false;
});

Continue with SitemapKit

Start using SitemapKit with PHP

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

More Languages integrations