Getting started overview
Integrating with Clearbit involves a series of steps designed to enable programmatic access to its data enrichment services. The process typically begins with account creation and API key retrieval, followed by making an initial authenticated request. Clearbit's API is primarily RESTful, supporting standard HTTP methods and JSON payloads for both requests and responses. Developers can interact with the API directly via HTTP clients like cURL, or utilize one of the officially supported Clearbit client libraries for languages such as Node.js, Ruby, and Python.
The core objective of the initial setup is to successfully authenticate with the Clearbit API and retrieve data. This typically involves using the API key as a Bearer token in the Authorization header for each request. Clearbit provides distinct API endpoints for its various products, including Enrichment, Prospector, and Reveal, each designed for specific data retrieval tasks such as looking up company details by domain or contact information by email address.
Before making any requests, it is advisable to review the Clearbit API reference documentation to understand the available endpoints, required parameters, and expected response formats. This preparation helps in constructing accurate requests and parsing the returned data effectively.
Quick-reference setup table
| Step | What to do | Where |
|---|---|---|
| 1. Create Account | Sign up for a Clearbit account. | Clearbit Signup Page |
| 2. Get API Key | Locate your secret API key in the dashboard. | Clearbit API Keys Documentation |
| 3. Choose Integration Method | Decide between direct HTTP requests (cURL) or an SDK. | Clearbit Libraries and SDKs |
| 4. Make First Request | Send an authenticated request to an API endpoint. | Clearbit Enrichment API Domain Lookup Example |
| 5. Handle Response | Process the JSON data returned by the API. | Clearbit API Responses Guide |
Create an account and get keys
To begin using Clearbit's API, the first step is to create an account. Clearbit offers various plans, with a Growth plan starting at $99/month. While there is no free tier, new users can explore the platform's capabilities by signing up and accessing their dashboard.
- Sign Up: Navigate to the Clearbit signup page. You will be prompted to provide basic information to create your account.
- Access Dashboard: After successful signup, you will be directed to your Clearbit dashboard. This is where you manage your account, view usage, and access API keys.
- Locate API Key: Your API key is essential for authenticating all requests to the Clearbit API. According to the Clearbit authentication documentation, API keys are found within your account settings or API section of the dashboard. Clearbit API keys are secret and should be treated as sensitive credentials. They grant full access to your account's API capabilities and data. It is recommended to store your API key securely and avoid hardcoding it directly into client-side code or public repositories.
- Understand Key Usage: Clearbit uses a single secret API key for authentication across all its services. This key is passed in the
Authorizationheader of your HTTP requests as a Bearer token. For example:Authorization: Bearer YOUR_API_KEY.
Clearbit's API key management emphasizes security. If you suspect your API key has been compromised, you should regenerate it immediately from your Clearbit dashboard to invalidate the old key and prevent unauthorized access.
Your first request
After obtaining your API key, you can make your first request to a Clearbit API endpoint. A common starting point is the Enrichment API's Company lookup by domain, which provides company information based on a website domain.
Using cURL (HTTP request)
This example demonstrates how to use cURL to query the Clearbit Enrichment API for company details using the domain clearbit.com. Replace YOUR_API_KEY with your actual Clearbit API key.
curl 'https://person.clearbit.com/v2/companies/find?domain=clearbit.com' \
-H 'Authorization: Bearer YOUR_API_KEY'
Expected successful response (truncated for brevity):
{
"id": "cb_xxxxxxxxx",
"name": "Clearbit",
"legalName": "Clearbit, Inc.",
"domain": "clearbit.com",
"url": "https://clearbit.com",
"tags": [
"Marketing Automation",
"SaaS",
"B2B"
],
"metrics": {
"alexaRank": 20000,
"employees": 200,
"marketCap": null,
"raised": 100000000,
"annualRevenue": null
},
"foundedYear": 2014,
"location": "San Francisco, CA, US",
"tech": [
"Google Analytics",
"Segment",
"Stripe"
],
"description": "Clearbit provides a suite of business intelligence APIs..."
// ... other fields
}
Using Node.js SDK
Clearbit provides an official Node.js library to simplify API interactions. First, install the library:
npm install clearbit
Then, use the following JavaScript code to make the same company lookup request:
const clearbit = require('clearbit')('YOUR_API_KEY');
clearbit.Company.find({
domain: 'clearbit.com'
})
.then(function (company) {
console.log('Company:', company.name);
console.log('Description:', company.description);
})
.catch(function (err) {
console.error('Error:', err);
});
Using Python SDK
For Python developers, the Clearbit Python library is available. Install it using pip:
pip install clearbit
Here's how to perform a company lookup:
import clearbit
clearbit.key = 'YOUR_API_KEY'
try:
company = clearbit.Company.find(domain='clearbit.com')
if company:
print(f"Company: {company['name']}")
print(f"Description: {company['description']}")
else:
print("Company not found.")
except clearbit.ClearbitError as e:
print(f"Error: {e}")
These examples demonstrate the fundamental process of authenticating and making a request. The structure for other Clearbit API endpoints, such as the Person API or Prospector API, follows similar patterns, requiring different parameters specific to their functionality.
Common next steps
After successfully making your first Clearbit API call, several common next steps can enhance your integration and leverage Clearbit's full capabilities:
- Explore Other Endpoints: Clearbit offers various APIs beyond company enrichment. Investigate the Person API for email-based contact enrichment, the Reveal API for identifying anonymous website visitors, and the Prospector API for finding new leads. Each serves distinct use cases in sales and marketing.
- Implement Webhooks: For real-time data updates or asynchronous processing, consider using Clearbit webhooks. Webhooks allow Clearbit to send data to your application when certain events occur (e.g., a data enrichment completes), reducing the need for polling and improving efficiency. This is a common pattern for integrating with external services, as detailed in general event-driven architecture documentation.
- Error Handling: Implement robust error handling in your application. The Clearbit API documentation on errors provides details on common error codes (e.g., 401 for unauthorized, 404 for not found, 429 for rate limits) and how to interpret them. Proper error handling ensures your application gracefully manages issues like invalid API keys or rate limit breaches.
- Rate Limiting: Be aware of Clearbit's API rate limits to prevent your application from being temporarily blocked. Design your integration to respect these limits, potentially using client-side rate limiting or retry mechanisms with exponential backoff.
- Secure API Key Management: Review your API key management strategy. Best practices include using environment variables for API keys in development and secure secrets management services (e.g., AWS Secrets Manager, Google Secret Manager) in production environments to prevent exposure.
- Monitor Usage: Regularly check your API usage within the Clearbit dashboard to monitor consumption against your plan limits and identify any unexpected spikes or patterns.
- Explore SDKs: If you started with cURL, consider migrating to one of the official Clearbit SDKs for your preferred language. SDKs often handle authentication, request formatting, and response parsing, simplifying integration and reducing development time.
Troubleshooting the first call
Encountering issues during your initial API call is common. Here are some troubleshooting steps for Clearbit API requests:
- Check API Key: Double-check that your API key is correct and hasn't been mistyped. Ensure there are no leading or trailing spaces. Verify it's the secret key, not a publishable key (if Clearbit had one, though it typically uses a single secret key).
- Authentication Header Format: Confirm the
Authorizationheader is correctly formatted asAuthorization: Bearer YOUR_API_KEY. A common mistake is missing the "Bearer" prefix or using incorrect casing. - Endpoint URL: Ensure the API endpoint URL is accurate. Check for typos in the domain, path, and query parameters. Refer to the Clearbit API reference for the exact endpoint structure.
- Required Parameters: Verify that all required parameters for the specific endpoint are included in your request. For example, the Company Enrichment API requires a
domainparameter. Missing parameters will result in an error. - HTTP Method: Confirm you are using the correct HTTP method (e.g., GET for lookups, POST for certain actions) as specified in the Clearbit documentation.
- Network Connectivity: Check your local network connection and ensure there are no firewalls or proxy settings blocking outbound requests to
person.clearbit.comor other Clearbit domains. - Rate Limits: If you receive a
429 Too Many Requestserror, you have hit Clearbit's rate limits. Pause your requests and implement a retry mechanism with exponential backoff. - Review Error Messages: Clearbit's API typically returns descriptive error messages in the JSON response body. Read these messages carefully, as they often pinpoint the exact issue. For example, an error indicating "invalid parameter" will guide you to check your request body or query string.
- SDK Specific Issues: If using an SDK, ensure it's the latest version and correctly initialized with your API key. Consult the SDK-specific documentation for common pitfalls.
- Clearbit Status Page: In rare cases, Clearbit's services might be experiencing an outage. Check the Clearbit Status Page to see if there are any reported issues.