Integration Patterns
The Website Categorization API supports multiple integration patterns depending on your use case, volume requirements, and latency constraints. This guide covers the most common patterns and helps you choose the right approach for your application. Start with our API quickstart if you haven't made your first API call yet.
Real-time Classification
For applications requiring instant categorization results, integrate the API synchronously into your request flow. This pattern suits use cases like live content filtering, real-time lead qualification, or instant brand safety checks.
// Real-time classification example
async function classifyDomain(domain) {
const response = await fetch(
`https://api.websitecategorizationapi.com/v1/categorize?domain=${domain}`,
{ headers: { 'Authorization': `Bearer ${API_KEY}` } }
);
return response.json();
}
Best for: Content moderation, web filtering, real-time lead scoring
Batch Processing
For large-scale data enrichment, use our batch endpoint to process thousands of domains efficiently. Batch processing offers cost efficiency and higher throughput for database enrichment, lead list qualification, and periodic data refresh workflows.
// Batch processing example
const domains = ['example1.com', 'example2.com', 'example3.com'];
const response = await fetch(
'https://api.websitecategorizationapi.com/v1/batch/categorize',
{
method: 'POST',
headers: {
'Authorization': `Bearer ${API_KEY}`,
'Content-Type': 'application/json'
},
body: JSON.stringify({ domains })
}
);
Best for: CRM enrichment, lead list processing, database updates
Cache-First Pattern
For high-volume applications, implement local caching to reduce API calls and improve response times. Cache categorization results with appropriate TTLs based on your freshness requirements.
// Cache-first pattern example
const cache = new Map();
const CACHE_TTL = 24 * 60 * 60 * 1000; // 24 hours
async function getCategoryWithCache(domain) {
const cached = cache.get(domain);
if (cached && Date.now() - cached.timestamp < CACHE_TTL) {
return cached.data;
}
const data = await classifyDomain(domain);
cache.set(domain, { data, timestamp: Date.now() });
return data;
}
Best for: High-traffic applications, cost optimization, latency reduction
Error Handling
Robust error handling ensures your integration remains stable under various conditions. Implement proper handling for common error scenarios:
async function classifyWithErrorHandling(domain) {
try {
const response = await fetch(url, options);
if (response.status === 429) {
// Rate limited - implement backoff
await delay(response.headers.get('Retry-After') * 1000);
return classifyWithErrorHandling(domain);
}
if (response.status === 401) {
throw new Error('Invalid API key');
}
if (!response.ok) {
throw new Error(`API error: ${response.status}`);
}
return response.json();
} catch (error) {
console.error('Classification failed:', error);
throw error;
}
}
Rate Limit Handling
When you receive a 429 status code, respect the Retry-After header and implement exponential backoff. See our rate limits documentation for detailed guidance on managing request volume.
Platform Integrations
Our API integrates with popular platforms and services:
- CRM Systems: Salesforce, HubSpot, Pipedrive - enrich lead and account records automatically
- Marketing Automation: Marketo, Pardot, Mailchimp - segment audiences based on company categorization
- Data Platforms: Snowflake, BigQuery, Databricks - enrich data warehouses with categorization data
- Security Tools: SIEM platforms, firewalls, secure web gateways - enable category-based filtering
For detailed platform-specific guidance, see our data enrichment solutions page or contact our integration team.