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: v6View latest version
This API endpoint helps you find company logos by searching their websites and using AI to extract the logo image URL from the HTML.
POST /find-logo
{ "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": false, "error": "Error description", "searchedUrl": "https://example.com" // Optional: URL that was searched }
- Website Discovery: If no website is provided, the API 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
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-logo \ -H "Content-Type: application/json" \ -d '{ "name": "Microsoft", "country": "United States", "state": "Washington" }'
The API handles various error scenarios:
- Missing required fields (name, country)
- Website not found during search
- Website unreachable or returns errors
- Logo 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 extraction
- Supports both provided websites and automatic website discovery
- Handles relative and absolute URL conversion
- Includes proper error handling and logging