Cliqz Logo Database

0.7.0 · active · verified Wed Apr 22

cliqz-logo-database is a JavaScript library providing programmatic access to a curated, local database of company and brand logos. It enables developers to retrieve a logo's URL and primary color information based on a given website URL. Currently at version 0.7.0, it ships with TypeScript types, facilitating its integration into modern TypeScript projects. The library's primary differentiator is its ability to offer an offline-first lookup for logos, circumventing the need for external API calls for recognized brands. It supports both ESM and CommonJS import patterns, offering flexibility across various JavaScript environments. While stable at its current version, being pre-1.0 suggests the API might evolve in future major releases, although active development status beyond maintenance is not explicitly stated.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to import and use the `getLogo` function to fetch logo information for various URLs. It includes type safety for the `Logo` object and handles cases where no logo is found, logging the details to the console.

import getLogo from 'cliqz-logo-database';

interface CliqzLogo {
  color: string;
  url: string;
}

function retrieveAndDisplayLogo(targetUrl: string): void {
  console.log(`Attempting to retrieve logo for: ${targetUrl}`);
  const logo: CliqzLogo | null = getLogo(targetUrl);

  if (logo) {
    console.log(`  Found logo!`);
    console.log(`    URL: ${logo.url}`);
    console.log(`    Primary Color: #${logo.color}`);
    // In a browser environment, you might embed it like this:
    // const img = document.createElement('img');
    // img.src = logo.url;
    // img.alt = `Logo for ${targetUrl}`;
    // document.body.appendChild(img);
  } else {
    console.warn(`  No logo found in the database for ${targetUrl}.`);
  }
}

retrieveAndDisplayLogo('https://cliqz.com');
retrieveAndDisplayLogo('https://github.com');
retrieveAndDisplayLogo('https://www.typescriptlang.org');
retrieveAndDisplayLogo('https://an-unknown-website.xyz');

view raw JSON →