Generate sitemap.xml for any website using our simple to use API.
Authorization
header for all API requests.website_url
and postback_url
.postback_url
. This response includes a download link to the sitemap.xml file."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
Follow the below steps to generate new API key/secret:
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
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.
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
$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;
}
?>