Sitemap Generator API - Ruby Gem
Sitemap Generator creates valid XML sitemaps from URL lists following the sitemaps.org protocol for search engine optimization.
Installation
Add this line to your application's Gemfile:
gem 'apiverve_sitemapgenerator'
And then execute:
$ bundle install
Or install it yourself as:
$ gem install apiverve_sitemapgenerator
Getting Started
Get your API key at APIVerve
Basic Usage
require 'apiverve_sitemapgenerator'
# Initialize the client
client = APIVerve::Sitemapgenerator::Client.new(api_key: "YOUR_API_KEY")
# Make a request
response = client.execute({
urls: /,/about,/contact,[object Object],[object Object],
baseUrl: "https://example.com",
changeFreq: "weekly",
priority: 0.5,
includeLastMod: true
})
# Print the response
puts response
Error Handling
begin
response = client.execute({ urls: /,/about,/contact,[object Object],[object Object], baseUrl: "https://example.com", changeFreq: "weekly", priority: 0.5, includeLastMod: true })
puts response["data"]
rescue APIVerve::Sitemapgenerator::ValidationError => e
puts "Validation error: #{e.errors.join(', ')}"
rescue APIVerve::Sitemapgenerator::APIError => e
puts "API error: #{e.message}"
puts "Status code: #{e.status_code}"
end
Debug Mode
# Enable debug logging
client = APIVerve::Sitemapgenerator::Client.new(
api_key: "YOUR_API_KEY",
debug: true
)
Example Response
{
"status": "ok",
"error": null,
"data": {
"sitemap": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<urlset xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\">\n <url>\n <loc>https://example.com/</loc>\n <lastmod>2025-12-16</lastmod>\n <changefreq>weekly</changefreq>\n <priority>0.5</priority>\n </url>\n <url>\n <loc>https://example.com/about</loc>\n <lastmod>2025-12-16</lastmod>\n <changefreq>weekly</changefreq>\n <priority>0.5</priority>\n </url>\n <url>\n <loc>https://example.com/contact</loc>\n <lastmod>2025-12-16</lastmod>\n <changefreq>weekly</changefreq>\n <priority>0.5</priority>\n </url>\n <url>\n <loc>https://example.com/blog</loc>\n <lastmod>2025-12-16</lastmod>\n <changefreq>daily</changefreq>\n <priority>0.8</priority>\n </url>\n <url>\n <loc>https://example.com/products</loc>\n <lastmod>2025-12-16</lastmod>\n <changefreq>weekly</changefreq>\n <priority>0.9</priority>\n </url>\n</urlset>",
"urlCount": 5,
"sizeBytes": 892,
"sizeKb": 0.87,
"format": "XML",
"protocol": "sitemaps.org/0.9",
"settings": {
"defaultChangeFreq": "weekly",
"defaultPriority": 0.5,
"includeLastMod": true,
"baseUrl": "https://example.com"
}
}
}
Documentation
For more information, visit the API Documentation.
Support
- Website: https://apiverve.com/marketplace/sitemapgenerator?utm_source=ruby&utm_medium=readme
- Email: hello@apiverve.com
License
This gem is available under the MIT License.