• Townie
    AI
  • Blog
  • Docs
  • Pricing
  • We’re hiring!
Log inSign up
nic

nic

OnboardCompany

Public
Like
OnboardCompany
Home
Code
2
README.md
H
index.ts
Branches
1
Pull requests
Remixes
History
Environment variables
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.
Sign up now
Code
/
README.md
Code
/
README.md
Search
7/11/2025
Viewing readonly version of main branch: v21
View latest version
README.md

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

POST /find-logo

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.png", "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 SVG > PNG > other image formats
  5. URL Validation: Ensures the logo URL ends with a valid image extension (.svg, .png, .jpg, .jpeg, .gif, .webp)

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

Find Company Logo

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. SVG logos (highest priority) - Vector graphics, scalable, often used by modern companies
  2. PNG logos (second priority) - High-quality raster images, good for detailed logos
  3. Other formats (lowest priority) - JPG, JPEG, GIF, WEBP

Strict URL Validation

  • Only returns URLs that end with valid image extensions
  • Rejects URLs that don't end with: .svg, .png, .jpg, .jpeg, .gif, .webp
  • Prevents returning non-image URLs or API endpoints

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 Analysis

  • Processes up to 20,000 characters of HTML (increased from 15,000)
  • More sophisticated pattern recognition
  • Better handling of modern website structures

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
FeaturesVersion controlCode intelligenceCLI
Use cases
TeamsAI agentsSlackGTM
ExploreDocsShowcaseTemplatesNewestTrendingAPI examplesNPM packages
PricingNewsletterBlogAboutCareers
We’re hiring!
Brandhi@val.townStatus
X (Twitter)
Discord community
GitHub discussions
YouTube channel
Bluesky
Terms of usePrivacy policyAbuse contact
© 2025 Val Town, Inc.