Get Started

Set up your credentials to get the API key for Clearbit.

To use the Clearbit APIs, we need to first create an account on Clearbit and then access the API key via a specific API URL.

Get the API Key

We can sign-up for our free Clearbit account on their official page. Please follow the steps below to successfully sign-up:

  1. Enter your email address and password, then click the “Next” button.

  2. Fill in your primary details like full name, job title, phone number, company name, and size, then check the agreement box and click the “Agree and Continue” button.

  3. After verification via the phone number, a successful sign-up will take you to the homepage of Clearbit.

The slides below will help you to visualize this process:

Get the API Key

Once signed up and logged in, follow the steps below to access your Clearbit API key:

  1. Click your Clearbit's username at the bottom-left corner.

  2. Upon clicking the username, you'll see a few options. Select and click "Support and guides."

  3. Now, select and click "API docs." You'll be taken to Clearbit's API documentation.

  4. Click "Authentication" to go to the section where you can view and access your API key.

  5. You can further explore your API keys (both secret and publishable, you can use any of these in this course) by clicking the "dashboard."

The slides below will help you to visualize this process:

Save the API key

Now that we’ve gotten our Clearbit API key, let’s check whether it works or not. Click the “Edit” button below, and then enter your API key in the field API_KEY. Don't forget to save the value by clicking “Save” so it’s available for us to use throughout the course.

import fetch from 'node-fetch';
const API_KEY = 'Bearer {{API_KEY}}';
const endpointUrl = new URL('https://company.clearbit.com/v1/domains/find');
const headerParameters = {
authorization: API_KEY,
contentType: 'application/json',
};
const queryParameters = new URLSearchParams({
name: 'Educative'
});
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 person 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.