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.

Endpoints

Find company logos by analyzing website HTML.

POST /find-address

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 }

Responses

Logo Response (200)

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

Address Response (200)

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

How It Works

Logo Finding

  1. Website Discovery: If no website is provided, searches DuckDuckGo to find the company's official website
  2. HTML Fetching: Retrieves the raw HTML from the company's homepage
  3. AI Logo Extraction: Uses OpenAI's GPT-4o-mini with enhanced logic to locate the company logo
  4. Format Prioritization: Prefers Inline SVG > SVG files > PNG > other image formats
  5. Inline SVG Conversion: Converts inline SVG elements to base64 encoded data URLs
  6. URL Validation: Ensures proper image URLs or data URLs are returned

Address Finding

  1. Website Discovery: Same as logo finding
  2. Page Discovery: Tries multiple pages including homepage, /about, /contact, /about-us, /contact-us, /company, /locations, /office, /headquarters
  3. HTML Analysis: Fetches HTML from each page until an address is found
  4. AI Address Extraction: Uses OpenAI to locate and format the company's physical address

Example Usage

curl -X POST https://your-val-url/find-logo \ -H "Content-Type: application/json" \ -d '{ "name": "Apple Inc", "website": "https://apple.com" }'

Find Company Address

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

Error Handling

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:

Format Prioritization

  1. Inline SVG logos (highest priority) - Converted to base64 data URLs for maximum quality and scalability
  2. SVG image files (second priority) - Vector graphics, scalable, often used by modern companies
  3. PNG logos (third priority) - High-quality raster images, good for detailed logos
  4. Other formats (lowest priority) - JPG, JPEG, GIF, WEBP

Inline SVG Handling

  • 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

Enhanced Detection

  • 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

Improved Analysis

  • 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

Rate Limits

This API uses OpenAI's services, so it's subject to OpenAI's rate limits. For production use, consider implementing caching and rate limiting.

Technical Details

  • 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)

Address Finding Strategy

The address finder uses a multi-page approach:

  1. Tries homepage first
  2. Searches common pages: /about, /about-us, /contact, /contact-us, /company, /locations, /office, /headquarters
  3. Stops at the first page where an address is found
  4. Returns the complete address and the page where it was found