Autocomplete

Learn and practice how to use Clearbit's autocomplete API.

In this lesson, we'll explore Clearbit's autocomplete API.

The autocomplete API

Clearbit's autocomplete endpoint allows users to auto-complete company names and get the relevant results. This endpoint takes an incomplete name of the company and returns the domain and logo of all the best-matched companies.

The base URL for this endpoint is as follows:

https://autocomplete.clearbit.com/v1/companies/suggest?query={partial_name_of_company}

Request parameters

This endpoint supports the following request parameters:

Name

Type

Category

Description

query

string

required

This is the partial name of the company we want the domain and logo for.

Using the autocomplete

Let's make a call to this endpoint using the code widget below. Enter the partial name of the company in place of {{PARTIAL_NAME}} in line 13. Now, click "run" to fetch the domain and logo of all the corresponding companies.

Press + to interact
import fetch from 'node-fetch';
const API_KEY = 'Bearer {{API_KEY}}';
const endpointUrl = new URL('https://autocomplete.clearbit.com/v1/companies/suggest');
const headerParameters = {
authorization: API_KEY,
contentType: 'application/json',
};
const queryParameters = new URLSearchParams({
query:'{{PARTIAL_NAME}}'
});
const options = {
method: 'GET',
headers: headerParameters,
};
async function fetchData() {
try {
endpointUrl.search = queryParameters;
const response = await fetch(endpointUrl, options);
// Custom function for printing the API response
printResponse(response);
} catch (error) {
// Custom function for printing the error message
printError(error);
}
}
// Calling function to make API call
fetchData();

In the code above:

  • Line 1: We import the node-fetch library.

  • Line 5: We define the URL for the autocomplete endpoint.

  • Lines 7–10: We define the header parameters for the request, including the required API key parameter.

  • Lines 12–14: We define the query parameters for the request.

  • Lines 16–19: We set the options for the API call, specifying the HTTP request type as GET.

  • Lines 21–33: We define a function called fetchData to make the API call.

  • Lines 22–27: Within a try block, we make a call to the API, printing the response to the console.

  • Lines 28–32: We catch all errors and exceptions within a catch block and print them to the console.

  • Line 36: We invoke the fetchData function.

Response parameters

The table below explains some attributes of the output JSON response of this endpoint.

Name

Type

Description

domain

string

This is the website domain of the company.

logo

string

This is the URL to the logo of the company.

name

string

This is the name of the company.