Company Logo & Address Finder API
This API provides endpoints to find company logos and addresses by searching their websites and using AI to extract the information from HTML.
Find company logos by analyzing website HTML.
Find company addresses by searching about/contact pages.
Request Body (Both Endpoints)
{
"name": "Company Name", // Required: The company name
"website": "https://..." // Optional: Company website URL
}
{
"success": true,
"logoUrl": "https://example.com/logo.svg",
"searchedUrl": "https://example.com"
}
Or for inline SVG:
{
"success": true,
"logoUrl": "data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTAwIiBoZWlnaHQ9IjEwMCI+PC9zdmc+",
"searchedUrl": "https://example.com"
}
{
"success": true,
"address": "123 Main Street, City, State 12345, Country",
"searchedUrl": "https://example.com",
"foundOnPage": "https://example.com/contact"
}
Error Response (400/404/500)
{
"success": false,
"error": "Error description",
"searchedUrl": "https://example.com" // Optional: URL that was searched
}
- Website Discovery: If no website is provided, searches DuckDuckGo to find the company's official website
- HTML Fetching: Retrieves the raw HTML from the company's homepage
- AI Logo Extraction: Uses OpenAI's GPT-4o-mini with enhanced logic to locate the company logo
- Format Prioritization: Prefers Inline SVG > SVG files > PNG > other image formats
- Inline SVG Conversion: Converts inline SVG elements to base64 encoded data URLs
- URL Validation: Ensures proper image URLs or data URLs are returned
- Website Discovery: Same as logo finding
- Page Discovery: Tries multiple pages including homepage, /about, /contact, /about-us, /contact-us, /company, /locations, /office, /headquarters
- HTML Analysis: Fetches HTML from each page until an address is found
- AI Address Extraction: Uses OpenAI to locate and format the company's physical address
curl -X POST https://your-val-url/find-logo \
-H "Content-Type: application/json" \
-d '{
"name": "Apple Inc",
"website": "https://apple.com"
}'
curl -X POST https://your-val-url/find-address \
-H "Content-Type: application/json" \
-d '{
"name": "Microsoft"
}'
Auto-Search (No Website Provided)
curl -X POST https://your-val-url/find-logo \
-H "Content-Type: application/json" \
-d '{
"name": "Google"
}'
Both endpoints handle various error scenarios:
- Missing required field (company name)
- Website not found during search
- Website unreachable or returns errors
- Logo/Address not found in website HTML
- AI service errors
Logo Finding Enhancements
The logo extraction has been significantly improved with:
- Inline SVG logos (highest priority) - Converted to base64 data URLs for maximum quality and scalability
- SVG image files (second priority) - Vector graphics, scalable, often used by modern companies
- PNG logos (third priority) - High-quality raster images, good for detailed logos
- Other formats (lowest priority) - JPG, JPEG, GIF, WEBP
- Detects inline
<svg>
elements in header/navigation areas
- Converts them to
data:image/svg+xml;base64,[encoded-content]
format
- Preserves full vector quality and scalability
- Works perfectly in browsers and applications
- Inline SVG elements in header/navigation areas
- IMG tags with alt text containing company name + "logo"
- Multiple logo placement patterns (header, navigation, etc.)
- Better handling of relative and absolute URLs
- Improved recognition of logo-related CSS classes
- Processes up to 25,000 characters of HTML (increased from 20,000)
- More sophisticated pattern recognition for inline SVGs
- Better handling of modern website structures
- Strict response formatting to avoid parsing issues
This API uses OpenAI's services, so it's subject to OpenAI's rate limits. For production use, consider implementing caching and rate limiting.
- Built with Hono framework on Val Town
- Uses OpenAI GPT-4o-mini for logo and address extraction
- Supports both provided websites and automatic website discovery
- Handles relative and absolute URL conversion
- Includes proper error handling and logging
- Address finding tries multiple common page paths (/about, /contact, etc.)
- Simplified API - only requires company name (country/state removed)
The address finder uses a multi-page approach:
- Tries homepage first
- Searches common pages: /about, /about-us, /contact, /contact-us, /company, /locations, /office, /headquarters
- Stops at the first page where an address is found
- Returns the complete address and the page where it was found