Getting started overview

Integrating Clearbit Logo involves a sequence of steps to retrieve company logos programmatically. The process begins with account creation, followed by the generation of an API key, which authenticates requests to Clearbit's services. Once authenticated, developers can send HTTP GET requests to the Logo API endpoint, providing a domain name as a parameter. The API responds with a URL pointing directly to the company's logo image, which can then be displayed within an application or website. The Logo API is a component of the broader Clearbit data enrichment platform, designed to provide visual branding assets.

The following table outlines the key steps to initiate usage of the Clearbit Logo API:

Step Action Location/Details
1 Sign up for a Clearbit account Clearbit homepage
2 Locate your API key Clearbit Dashboard > API Settings
3 Install an SDK (optional but recommended) Clearbit provides SDKs for Node.js, Ruby, Python, and Go
4 Construct and send your first request Using curl, an SDK, or an HTTP client
5 Handle the API response Process the returned logo image URL

Create an account and get keys

To use the Clearbit Logo API, an account is required. This account provides access to the Clearbit Dashboard, where API keys are managed. The API key serves as the authentication credential for all requests made to Clearbit's services, including the Logo API. Clearbit offers various pricing tiers, including options for enterprise use, detailed on their pricing page.

Account Creation Steps:

  1. Navigate to the Clearbit website.
  2. Click on the "Sign Up" or "Get Started" option, typically located in the navigation bar.
  3. Complete the registration form, providing necessary information such as email address and company details.
  4. Follow any email verification steps to activate the new account.

Obtaining Your API Key:

After successfully creating and logging into your Clearbit account, your API key can be found within the dashboard:

  1. From the Clearbit Dashboard, navigate to the "API" or "Account Settings" section.
  2. Locate the "API Keys" subsection. Clearbit generates a unique secret API key for each account. This key should be kept confidential to prevent unauthorized access to your account and usage.
  3. Copy the API key. This key will be used to authenticate your requests to the Logo API.

Clearbit's API key authentication typically involves including the key as a query parameter (api_key) or as a Bearer token in the Authorization header. The Clearbit Logo API documentation specifies the accepted authentication methods and parameters.

Your first request

The Clearbit Logo API is a RESTful service that accepts an HTTP GET request and returns a direct URL to a company's logo. The primary endpoint for logo retrieval is https://logo.clearbit.com/:domain or https://logo.clearbit.com/DOMAIN, where :domain is the company's website domain.

Example using curl:

This example demonstrates how to retrieve the logo for example.com using a curl command. Replace YOUR_API_KEY with your actual Clearbit API key.

curl "https://logo.clearbit.com/example.com?size=100&greyscale=true&api_key=YOUR_API_KEY"

In this request:

  • example.com is the target domain for which the logo is requested.
  • size=100 is an optional parameter to specify the desired logo size in pixels.
  • greyscale=true is an optional parameter to request a greyscale version of the logo.
  • api_key=YOUR_API_KEY authenticates the request.

The response to this request will be a redirect (HTTP 302) to the actual image file's URL. Most HTTP clients and browsers will automatically follow this redirect. The final URL will directly serve the logo image.

Example using Node.js SDK:

Clearbit provides official SDKs for several languages, which simplify interaction with their APIs. For Node.js, begin by installing the SDK:

npm install clearbit

Then, use the following code to make a request:

const clearbit = require('clearbit')('YOUR_API_KEY');

async function getCompanyLogo(domain) {
  try {
    // The Logo API is accessed directly via a URL rather than a specific SDK method for some clients.
    // For a direct URL, you might construct it yourself or use a helper if available.
    // Clearbit's Node.js SDK focuses more on enrichment data, but you can still form the URL.
    const logoUrl = `https://logo.clearbit.com/${domain}?size=128`;
    console.log(`Logo URL for ${domain}: ${logoUrl}`);
    // In a real application, you'd embed this URL in an  tag or fetch it.
    // For instance, using a simple fetch to confirm it's an image:
    const response = await fetch(logoUrl);
    if (response.ok) {
      console.log(`Successfully retrieved logo for ${domain}. Content type: ${response.headers.get('Content-Type')}`);
    } else {
      console.error(`Failed to retrieve logo for ${domain}: ${response.status} ${response.statusText}`);
    }
  } catch (error) {
    console.error(`Error fetching logo for ${domain}:`, error.message);
  }
}

getCompanyLogo('stripe.com');

This Node.js example constructs the logo URL directly, as the Clearbit Node.js SDK primarily focuses on data enrichment rather than direct Logo API calls that return an image URL. It then uses the built-in fetch API (available in modern Node.js versions or via a polyfill) to demonstrate retrieving the image. For browser-based applications, the constructed URL can be directly assigned to an <img> tag's src attribute.

Common next steps

After successfully retrieving your first company logo, consider these common next steps to integrate Clearbit Logo more deeply into your applications:

  • Dynamic Logo Display: Implement logic to dynamically fetch and display logos based on user input or data from other sources. For web applications, this typically involves setting the src attribute of an <img> tag based on the returned URL.

  • Error Handling: Develop robust error handling for cases where a logo cannot be found for a given domain, or if API limits are reached. The API might return a 404 Not Found status for unknown domains, or other HTTP error codes for rate limiting or authentication issues. For example, a 403 Forbidden status indicates an authentication problem, as detailed in the MDN Web Docs on HTTP 403 status.

  • Caching: To improve performance and reduce API calls, implement client-side or server-side caching of logo URLs and images. Since logo URLs are relatively stable, caching can significantly decrease latency and API usage. Consider HTTP caching headers or a content delivery network (CDN) for optimal performance.

  • Parameter Customization: Experiment with optional parameters like size, greyscale, and format to customize the appearance of the logos to match your application's design requirements. Refer to the Clearbit Logo API reference for a complete list of supported parameters.

  • SDK Integration: If you are working with languages like Ruby, Python, or Go, explore the official Clearbit SDKs to streamline API interactions. While the Logo API is straightforward to use with direct HTTP calls, SDKs often provide convenience wrappers for other Clearbit services.

  • Usage Monitoring: Monitor your API usage through the Clearbit Dashboard to stay within your plan's limits and understand your consumption patterns. This helps in planning for scalability and managing costs.

  • Security Best Practices: Ensure your API key is stored securely and not exposed in client-side code. For server-side applications, use environment variables. For client-side requests that need the API key, consider using a proxy server to keep the key confidential.

Troubleshooting the first call

When making your first call to the Clearbit Logo API, you might encounter issues. Here are common problems and their solutions:

  1. 401 Unauthorized / Missing API Key:

    • Problem: The API returns a 401 status code, indicating that the request could not be authenticated. This often means the API key is missing or incorrect.
    • Solution: Double-check that your API key is correctly included in the request, either as a query parameter (api_key=YOUR_API_KEY) or as a Bearer token in the Authorization header, as specified in the Clearbit Logo API documentation. Verify that the key you are using matches the one in your Clearbit Dashboard.

  2. 404 Not Found (for a domain):

    • Problem: The API returns a 404 status code, even when the API key is correct. This typically means Clearbit does not have a logo associated with the provided domain.
    • Solution: Confirm the domain name is spelled correctly. Try a well-known domain (e.g., google.com, microsoft.com) to verify the API is generally working. Implement fallback logic in your application to display a default logo or placeholder image when a specific logo is not found.

  3. 403 Forbidden / Rate Limit Exceeded:

    • Problem: A 403 status code can indicate that your account does not have permission for the requested action or that you have exceeded your API rate limits.
    • Solution: Review your Clearbit plan and usage limits in your dashboard. If you've hit a rate limit, pause your requests and retry after the specified retry-after period. For persistent issues, contact Clearbit support to discuss your account's permissions or upgrade your plan. The IETF RFC 7231 defines the 403 status code as indicating the server understood the request but refuses to authorize it.

  4. CORS Issues (Client-side):

    • Problem: If you're making requests directly from a web browser (e.g., using fetch or XMLHttpRequest), you might encounter Cross-Origin Resource Sharing (CORS) errors.
    • Solution: While the Logo API typically returns a direct image URL, which browsers handle without CORS issues for <img> tags, if you're attempting to fetch the image data programmatically client-side, you might need a server-side proxy to bypass CORS restrictions. Alternatively, ensure the Clearbit API's CORS headers are configured to allow requests from your domain, or use the direct image URL in an <img> tag.

  5. Incorrect URL Parameters:

    • Problem: The API returns an unexpected response or an error, possibly due to malformed URL parameters.
    • Solution: Refer to the Clearbit Logo API reference to confirm the correct spelling and expected values for all query parameters (e.g., size, greyscale, format). Ensure proper URL encoding for any complex domain names or parameters.