Public
Like
OnboardCompany
Val Town is a collaborative website to build and scale JavaScript apps.
Deploy APIs, crons, & store data – all from the browser, and deployed in milliseconds.
Viewing readonly version of main branch: v14View latest version
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.
{ "name": "Company Name", // Required: The company name "website": "https://...", // Optional: Company website URL "country": "Country Name", // Required: Company's country "state": "State/Province" // Optional: Company's state or province }
{ "success": true, "logoUrl": "https://example.com/logo.png", "searchedUrl": "https://example.com" }
{ "success": true, "address": "123 Main Street, City, State 12345, Country", "searchedUrl": "https://example.com", "foundOnPage": "https://example.com/contact" }
{ "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 to analyze the HTML and locate the company logo
- URL Normalization: Converts relative URLs to absolute URLs for the logo image
- 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", "country": "United States", "state": "California" }'
curl -X POST https://your-val-url/find-address \ -H "Content-Type: application/json" \ -d '{ "name": "Microsoft", "country": "United States", "state": "Washington" }'
curl -X POST https://your-val-url/find-logo \ -H "Content-Type: application/json" \ -d '{ "name": "Google", "country": "United States" }'
Both endpoints handle various error scenarios:
- Missing required fields (name, country)
- Website not found during search
- Website unreachable or returns errors
- Logo/Address not found in website HTML
- AI service errors
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.)
The logo extraction has been enhanced to handle:
- Links with href="/" (like Apple's website)
- Various logo placement patterns (header, navigation, etc.)
- Different logo formats (img tags, SVG elements, CSS backgrounds)
- Common logo identifiers (class/id containing "logo", "brand", etc.)
- Relative and absolute URL conversion
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