Build OpenAI agents that can discover and analyze website sitemaps. Give your agent the ability to map out any domain's content structure.
from agents import Agent, Runner, function_tool
import requests
@function_tool
def discover_sitemaps(domain: str) -> dict:
"""Discover all XML sitemaps on a domain."""
resp = requests.post(
"https://sitemapkit.com/api/v1/sitemap/full",
headers={"x-api-key": "YOUR_API_KEY", "Content-Type": "application/json"},
json={"url": domain}
)
data = resp.json()
return {
"sitemaps_found": len(data["sitemaps"]),
"total_urls": len(data["urls"]),
"sample_urls": [u["loc"] for u in data["urls"][:10]],
}
agent = Agent(
name="SEO Analyst",
instructions="You analyze websites. Use discover_sitemaps to map out a domain.",
tools=[discover_sitemaps],
)
result = Runner.run_sync(agent, "Analyze the sitemap of vercel.com")
print(result.final_output)sk_live_* API key./api/v1/sitemap/full endpoint to discover and extract all sitemaps from a domain in one call.POST /api/v1/sitemap/discover — Find all sitemaps on a domainPOST /api/v1/sitemap/extract — Parse a sitemap URL and extract all URLsPOST /api/v1/sitemap/full — Discover + extract in one call (recommended)100 free API calls/month. No credit card required.