SDKs overview

Clearbit Logo offers a programmatic interface for retrieving company logos based on a given domain name. The underlying service is a REST endpoint that returns a URL to a company's logo. To facilitate integration for developers, Clearbit provides official Software Development Kits (SDKs) in several popular programming languages. These SDKs abstract the direct HTTP requests and API key authentication, allowing developers to focus on integrating the logo retrieval functionality into their applications. The primary goal of these SDKs is to simplify access to the Clearbit Logo API reference, which is part of Clearbit's broader suite of data enrichment products.

Integrating with Clearbit Logo typically involves sending a domain name (e.g., google.com) to the API and receiving a URL to the corresponding logo image. The SDKs handle the technical details of constructing the request, securely passing the API key, and parsing the response. This approach reduces boilerplate code and potential errors, streamlining the development process for applications that require dynamic company branding or visual enhancement of user profiles. Additionally, the SDKs often provide helper functions for common tasks, such as handling API errors or configuring request parameters.

Official SDKs by language

Clearbit maintains official SDKs for several programming languages, ensuring direct support and compatibility with the latest API versions. These SDKs are designed to provide a consistent and reliable interface for interacting with the Clearbit Logo API. They are typically open-source and available through standard package managers for each language, making installation straightforward.

Language Package Name Install Command Maturity
Node.js clearbit npm install clearbit Stable
Ruby clearbit gem install clearbit Stable
Python clearbit pip install clearbit Stable
Go github.com/clearbit/clearbit-go go get github.com/clearbit/clearbit-go Stable

Each official SDK is documented within the Clearbit developer documentation, providing specific usage examples and API function details for its respective language. These resources detail how to initialize the client, make requests, and handle responses, including error conditions. Developers can expect these SDKs to be actively maintained and updated to reflect any changes or enhancements to the Clearbit Logo API, ensuring long-term compatibility and performance.

Installation

Installing Clearbit Logo SDKs follows the standard practices for each programming language's ecosystem. Using a package manager simplifies dependency management and ensures that the correct version of the SDK and its prerequisites are installed. Below are detailed installation instructions for the officially supported languages.

Node.js

For Node.js projects, the Clearbit SDK is available via npm, the Node package manager. Navigate to your project directory and execute the following command in your terminal:

npm install clearbit

This command downloads the clearbit package and adds it to your project's node_modules directory, updating your package.json and package-lock.json files. After installation, you can require the package in your Node.js scripts.

Ruby

Ruby projects typically use Bundler and RubyGems for dependency management. To install the Clearbit Ruby gem, add it to your Gemfile:

# Gemfile
gem 'clearbit'

Then, run bundle install from your terminal:

bundle install

Alternatively, you can install the gem directly using RubyGems:

gem install clearbit

This makes the clearbit module available for use in your Ruby applications.

Python

Python developers can install the Clearbit library using pip, the Python package installer. Open your terminal or command prompt and run:

pip install clearbit

This command fetches the clearbit package from the Python Package Index (PyPI) and installs it into your Python environment. You can then import the library in your Python scripts.

Go

Go modules are used for dependency management in Go projects. To add the Clearbit Go SDK, use the go get command:

go get github.com/clearbit/clearbit-go

This command downloads the module and adds it to your go.mod file. After running go get, you can import the package in your Go source files and use its functions. Go's dependency management system ensures that the correct version is referenced and available for compilation.

Quickstart example

This quickstart example demonstrates how to retrieve a company logo using the Clearbit Node.js SDK. Similar patterns apply to Ruby, Python, and Go SDKs, typically involving client initialization with an API key and calling a specific logo retrieval function.

Node.js Quickstart

First, ensure you have your Clearbit API key. You can find this in your Clearbit account settings. Set it as an environment variable (recommended for security) or pass it directly during client initialization.


const clearbit = require('clearbit')(process.env.CLEARBIT_API_KEY);

async function getCompanyLogo(domain) {
  try {
    const logo = await clearbit.Logo.find({
      domain: domain
    });
    if (logo && logo.url) {
      console.log(`Logo URL for ${domain}: ${logo.url}`);
      return logo.url;
    } else {
      console.log(`No logo found for ${domain}`);
      return null;
    }
  } catch (error) {
    console.error(`Error fetching logo for ${domain}:`, error.message);
    if (error.type === 'resource_not_found') {
      console.log(`The domain '${domain}' was not found by Clearbit Logo API.`);
    } else if (error.type === 'invalid_api_key') {
      console.log('Please check your Clearbit API key.');
    } else {
      console.log('An unexpected error occurred.');
    }
    return null;
  }
}

// Example usage:
getCompanyLogo('stripe.com');
getCompanyLogo('nonexistentdomain12345.com');

Explanation:

  1. require('clearbit')(process.env.CLEARBIT_API_KEY);: This line initializes the Clearbit client. It's crucial to replace process.env.CLEARBIT_API_KEY with your actual API key, ideally loaded from environment variables for production environments to avoid hardcoding sensitive credentials.
  2. clearbit.Logo.find({ domain: domain });: This is the core call to the Logo API. It takes an object with a domain property, which is the company's domain you want to retrieve the logo for.
  3. Error Handling: The try...catch block is essential for handling potential API errors, such as an invalid domain, network issues, or an incorrect API key. Clearbit API errors often include a type property that can be used for specific error handling logic, as demonstrated in the example. This robust error handling is a common practice in API integrations, as highlighted in general HTTP status code documentation for web services.
  4. Response Structure: If a logo is found, the response object typically contains a url property, which is the direct link to the company's logo image.

This example provides a foundational understanding of how to integrate the Clearbit Logo API using its official SDK, demonstrating both successful retrieval and error management.

Community libraries

While Clearbit provides official SDKs for key languages, the open-source community often develops and maintains additional libraries or integrations. These community-contributed tools can sometimes offer support for languages not officially covered, provide alternative architectural patterns, or integrate Clearbit Logo functionality into specific frameworks or platforms.

When considering a community library, it is important to evaluate its maintenance status, documentation quality, and compatibility with the latest Clearbit Logo API version. Community projects may vary in their level of support and adherence to API changes. Developers should check the project's repository (e.g., on GitHub) for recent commits, open issues, and pull requests to gauge its activity and reliability. For instance, a search on GitHub for Clearbit Logo repositories might reveal community-driven efforts that extend the API's reach.

Examples of community contributions might include:

  • PHP clients: While not officially supported by Clearbit, community members might build PHP wrappers for the Clearbit Logo API, allowing Laravel or Symfony developers to integrate easily.
  • JavaScript front-end components: React, Vue, or Angular components that directly consume the Clearbit Logo API, potentially offering client-side logo fetching and display.
  • Serverless function examples: Implementations of Clearbit Logo integration within AWS Lambda, Google Cloud Functions, or Azure Functions, demonstrating best practices for serverless architectures.
  • Specialized framework integrations: Libraries designed to work specifically with content management systems (CMS) like WordPress or headless CMS platforms, providing plugins or modules for logo retrieval.

Before adopting a community library for production use, it is advisable to review its source code, understand its dependencies, and perform thorough testing to ensure it meets your project's security and performance requirements. Official Clearbit documentation remains the authoritative source for API specifications and best practices, even when using community-developed clients.