URL/Slug Utilities

Extract Domain

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.

API Endpoint

GET /v1/slug/extract-domain

Code Examples

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)

Use via MCP

Add to your AI agent

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"
      }
    }
  }
}

Learn more about MCP setup →

FAQ

How do I extract domain from URL using MCP in Cursor?

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'.

What does extract domain return for subdomains?

Returns the full subdomain structure. For 'https://api.staging.example.com/v1/users', it returns 'api.staging.example.com', not just 'example.com'.

Does extract domain work with URLs without protocols?

Yes, it handles URLs with or without http/https protocols. Both 'example.com/path' and 'https://example.com/path' return 'example.com'.

Can I use this for domain validation in AI agents?

Absolutely. Extract the domain first, then validate against your whitelist or check DNS records. Great for building content filters or security checks.

What happens with malformed URLs?

Returns an error for truly malformed URLs, but handles common variations like missing protocols gracefully. Always validate your input URLs first.

Try Extract Domain Now

Get your free API key and start using Extract Domain in seconds.

Get Free API Key