Authentication overview
Clearbit Logo provides a REST endpoint for retrieving company logos based on a given domain. Access to the Logo API is secured through a single, secret API key. This key serves as the primary credential for authenticating all requests, ensuring that only authorized applications can query and retrieve logo assets.
The authentication model for the Clearbit Logo API is designed for simplicity and direct integration. Developers are required to include their API key with each request, typically as a query parameter or an HTTP header, depending on the specific implementation or SDK used. Clearbit processes this key to validate the request against an active account, enabling access to the logo data. For comprehensive setup instructions, refer to the official Clearbit Logo API documentation.
Adherence to secure handling of this API key is critical, as its compromise could lead to unauthorized usage of the Clearbit Logo API. Clearbit recommends practices such as environment variables and secure secret management systems to protect the API key from exposure during development and deployment.
Supported authentication methods
The Clearbit Logo API exclusively supports API key authentication. This method involves a unique, secret string that must be passed with every API request to identify and authorize the calling application or user.
API keys are a common authentication mechanism for web APIs, offering a straightforward approach to control access and track usage. They are typically generated and managed within the service provider's dashboard or account settings. For the Clearbit Logo API, the API key is associated directly with your Clearbit account and its entitlements.
The following table outlines the specifics of the supported authentication method:
| Method | When to Use | Security Level |
|---|---|---|
| API Key | Direct application access, backend services, server-to-server communication | Moderate (requires secure storage and transmission via HTTPS) |
While API keys simplify authentication, their security relies heavily on correct implementation and storage practices. Unlike token-based systems such as OAuth 2.0, API keys do not inherently have scopes or short expiration times, making their protection paramount. For applications requiring more granular access control or user delegation, developers might implement an additional layer of authentication on their own services that in turn use the Clearbit API Key. Further details on API key security practices are available from sources like Google Developers on API key security.
Getting your credentials
To access the Clearbit Logo API, you need a Clearbit API key. This key is generated automatically when you create a Clearbit account. If you do not yet have an account, navigate to the Clearbit website and sign up.
Once you have an active Clearbit account, follow these steps to locate your API key:
- Log in to your Clearbit account dashboard.
- Navigate to the settings or API keys section. The exact path may vary but is typically accessible via your user profile or a dedicated 'API' link.
- Your secret API key will be displayed there. It is a long alphanumeric string.
It is crucial to treat this API key as sensitive information. Clearbit does not provide a mechanism to retrieve a lost or forgotten API key directly due to security protocols; however, you can usually generate a new one from your dashboard if needed. Always copy your API key directly from the dashboard to avoid transcription errors. Do not hardcode your API key directly into client-side code or publicly accessible repositories. Instead, utilize environment variables or secure configuration management systems.
Authenticated request example
This section demonstrates how to make an authenticated request to the Clearbit Logo API using your API key. The primary method for the Logo API is a GET request, where the API key is passed as a query parameter. The API returns a JSON object containing the URL to the company logo.
The Logo API endpoint requires a domain parameter to identify the company for which a logo is requested. The API key is then appended to the request URL.
GET https://logo.clearbit.com/:domain?apikey=YOUR_API_KEY
Replace :domain with the actual company domain (e.g., google.com) and YOUR_API_KEY with your secret Clearbit API key.
Example using curl:
curl "https://logo.clearbit.com/stripe.com?apikey=sk_YOUR_API_KEY_HERE"
In this example, stripe.com is the domain for which the logo is requested. The API key sk_YOUR_API_KEY_HERE would be replaced by your actual Clearbit API key. Upon a successful request, the API will return a 302 Found redirect to the logo image URL. You can use the -L flag with curl to follow redirects:
curl -L "https://logo.clearbit.com/stripe.com?apikey=sk_YOUR_API_KEY_HERE"
This curl command will directly return the image data for the Stripe logo, assuming successful authentication and a valid domain. For integrating into various programming languages, Clearbit provides official SDKs for Node.js, Ruby, Python, and Go, which abstract away the direct handling of API key placement in HTTP requests.
Security best practices
Securing your Clearbit Logo API key is essential to prevent unauthorized access and potential misuse. Adhering to established security practices helps protect both your data and your Clearbit account.
-
Environment Variables: Store your API key as an environment variable rather than hardcoding it directly into your application's source code. This prevents the key from being exposed in version control systems (e.g., Git repositories) and makes it easier to manage across different deployment environments (development, staging, production).
// Node.js example const clearbit = require('clearbit')(process.env.CLEARBIT_API_KEY); - Secret Management Systems: For more complex or enterprise-level applications, consider using a dedicated secret management system like HashiCorp Vault, AWS Secrets Manager, or Azure Key Vault. These services provide secure storage, fine-grained access control, and auditing capabilities for sensitive credentials.
- HTTPS-only Communication: Always ensure that all communication with the Clearbit Logo API occurs over HTTPS (TLS/SSL). Clearbit's API endpoints automatically enforce HTTPS. This encrypts your API key and request data in transit, protecting it from interception by malicious actors. Transmitting API keys over unencrypted HTTP is a significant security vulnerability.
- Restrict Access: Limit who has access to your Clearbit API key. Only authorized developers and systems should be able to retrieve or use it. Implement role-based access control (RBAC) within your organization to govern access to sensitive credentials.
- Regular Key Rotation: While Clearbit's API keys do not have built-in expiration, it is a good security practice to periodically rotate your API keys. If a key is compromised, rotating it immediately invalidates the old key and prevents further unauthorized access. You can generate a new API key from your Clearbit dashboard and update your applications accordingly.
- Do Not Expose in Client-Side Code: Never embed your Clearbit API key directly in client-side code (e.g., JavaScript in a web browser, mobile application frontends). Client-side code can be easily inspected, leading to the exposure of your key. All API calls requiring the key should be proxied through a secure backend server that manages and makes the API requests on behalf of the client.
- Monitor API Usage: Regularly monitor your Clearbit API usage metrics within your dashboard. Unusual spikes or patterns in usage could indicate a compromised key or unauthorized activity. Many API providers, including Clearbit, offer tools for monitoring API consumption to help detect anomalies.
- Secure Development Lifecycle: Integrate security considerations throughout your software development lifecycle. Conduct code reviews, security testing, and penetration testing to identify and address potential vulnerabilities related to API key handling and overall application security. Further guidance on securing API keys can also be found in resources dedicated to Twilio API key best practices.