Extracts the domain portion from any URL string, returning just the hostname without protocol, path, or query parameters. Use via MCP in AI coding assistants or REST API at `/v1/slug/extract-domain`. Perfect for URL parsing, domain validation, or building analytics dashboards where you need clean domain names from messy URLs.
curl "https://tinyfn.io/v1/slug/extract-domain" \
-H "X-API-Key: YOUR_API_KEY"
const response = await fetch('https://tinyfn.io/v1/slug/extract-domain', {
headers: { 'X-API-Key': 'YOUR_API_KEY' }
});
const data = await response.json();
console.log(data);
import requests
response = requests.get('https://tinyfn.io/v1/slug/extract-domain',
headers={'X-API-Key': 'YOUR_API_KEY'})
data = response.json()
print(data)
Connect your AI agent (Claude, Cursor, Windsurf, etc.) to TinyFn's url/slug tools:
{
"mcpServers": {
"tinyfn-slug": {
"url": "https://tinyfn.io/mcp/slug",
"headers": {
"X-API-Key": "YOUR_API_KEY"
}
}
}
}
Call the extract-domain tool with your URL string. It returns just the domain portion, like 'example.com' from 'https://example.com/path?query=value'.
Returns the full subdomain structure. For 'https://api.staging.example.com/v1/users', it returns 'api.staging.example.com', not just 'example.com'.
Yes, it handles URLs with or without http/https protocols. Both 'example.com/path' and 'https://example.com/path' return 'example.com'.
Absolutely. Extract the domain first, then validate against your whitelist or check DNS records. Great for building content filters or security checks.
Returns an error for truly malformed URLs, but handles common variations like missing protocols gracefully. Always validate your input URLs first.
Get your free API key and start using Extract Domain in seconds.
Get Free API Key