XML Sitemap API

Generate sitemap.xml for any website using our simple to use API.

Getting Started

  1. Sigup, login and obtain the API key and API secret key from your account area.
  2. Use the API credentials to generate a SHA256 hash and include in the Authorization header for all API requests.
  3. Post your request, in JSON format, to API endpoint. The request payload will have two variables; website_url and postback_url.
  4. The API generates the sitemap and posts a JSON response to the postback_url. This response includes a download link to the sitemap.xml file.

API End Point

"POST" your requests to the below URL. Make sure to always use HTTPS. Non-SSL requests will be rejected.

https://www.sitemapgenie.com/api/v1/sitemap

Obtain API Credentials

Follow the below steps to generate new API key/secret:

  1. Login to your account and navigate to "API Keys" tab.
  2. Click on "Generate new API Key" button.
  3. Input name and click on "Add API Key" button.

Authorization Header

Each API call needs to include a Authorization header in the following format:

Authorization: Basic APIKEY:SHA256_HASH

The APIKEY will be the API Key that you got in the "Obtain API Credentials" step above. The SHA256_HASH will need be generated by concatenating the API Key and API Secret and then generating a SHA256 digest of the concatenated string. Example:

<?php
$api_key = "e020fcc1256125f5e07f8c595b9a8447"; //Your API Key
$secret_key = "c15589c1e50fba98e73345916dce045b"; //Your API Secret Key
$hash = hash("sha256", $api_key . $secret_key);
?>

Using the above API key and secret, the Authorization header will be something like:

Authorization: Basic e020fcc1256125f5e07f8c595b9a8447:3a19d9227ebc6b1d541f334d2186264b2faa70f390ed1ce03d5bdd309fcc8e4d

Request Body

The /sitemap API endpoint will accept a JSON request with the following format:

{
    "website_url": "https:\/\/acme-test.com",
    "postback_url": "https:\/\/acme-test.com\/postback.php"
}

website_url: Website address to crawl and generate sitemap for.
postback_url: URL of your own script. The API will post the response to this script once the sitemap has been generated.

Postback Data

The /sitemap API endpoint will post a JSON payload to the postback_url you included as part of your request.

The postback payload will have the following format:

{
    "sitemap_id": {ID},
    "download_url": "https:\/\/www.sitemapgenie.com\/sitemap\/download\/{ID}"
}

PHP Code Example

<?php
$api_key = "YOUR_API_KEY";
$hash_key = "YOUR_API_HASH_KEY";
$hash = hash("sha256", $api_key . $hash_key);

$request = [
    "website_url" => "https://acme-test.com",
    "postback_url" => "https://acme-test.com/postback.php"
];

$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, "https://www.sitemapgenie.com/api/v1/sitemap");
curl_setopt($curl, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($curl, CURLOPT_POSTFIELDS, json_encode($request));
curl_setopt($curl, CURLOPT_HTTPHEADER, [
	"Authorization: Basic $api_key:$hash"
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
	echo "cURL Error #:" . $err;
} else {
	echo $response;
}
?>

Sitemap API

Signup and use the SitemapGenie API to generate sitemaps for your website.

Get Started

Let's Get In Touch!


Need help with our free sitemap generator? Click Here To Contact Us!

+91 181-4629055