jeffersongoncalves/laravel-clearbit
Laravel Clearbit is a simple integration for the Clearbit API, making it easy to look up and enrich company and person data in Laravel apps. Configure your API credentials and use Clearbit endpoints for lead enrichment, company details, and customer intelligence.
composer require clearbit/laravel-clearbit (verify the vendor name against the README — this is a thin HTTP client wrapper, so the package name tells you little about scope).php artisan vendor:publish --tag=clearbit-config. You get a single config/clearbit.php holding the API key plus, typically, per-endpoint base URLs and a timeout.CLEARBIT_API_KEY=sk_... to .env and to every environment you actually deploy. The package auto-registers its service provider; there's no manual providers entry unless you're on an old skeleton.@method annotations (fastest way to see the whole API surface), then the README's example blocks. The underlying client class is usually a handful of public methods, so reading it end-to-end takes five minutes and beats guessing at return shapes.User at registration from their email domain. In a listener on Registered, call the combined person+company lookup, persist the raw payload as JSON on the user, and extract a few columns (company name, domain, role, location) for segmentation. Do it in a queued job — enrichment latency is 300–1500 ms and you don't want that in the signup response.Wrap it, don't call it from controllers. Bind a thin LeadEnricher service around the facade so you can swap in a fake, add logging, and centralise credit accounting. The facade is convenient but static calls scattered across controllers are the usual path to an unmaintainable integration.
Combined lookup is the default, not the exception. If you need both person and company data for one email, use the combined endpoint — it's one request and one credit charge instead of two. Reach for the person-only or company-only endpoints when you genuinely need just one side.
Cache on the natural key with a real TTL. Enrichment responses are credits, and the data doesn't change fast. Cache by lowercased email for person lookups and by domain for company lookups, 30–90 days. Laravel's Cache::remember around your wrapper is enough; add a clearbit: prefix so you can flush it independently. Invalidate on explicit re-enrichment requests, not on every login.
Store the raw payload, project the columns. Cast a clearbit_data JSON column (or a dedicated enrichments table keyed by subject) and derive typed columns from it. Vendor payloads gain fields over time, and having the original lets you backfill new columns without re-spending credits.
Handle "no match" as a first-class outcome. A 404 means Clearbit has nothing for that email/domain — common for small companies and personal addresses. Your wrapper should return null (or a typed result object with a found flag) rather than letting an exception bubble into your registration flow. Log the miss at debug level so you can measure your hit rate.
IP reveal belongs behind a guard. Anonymous-visitor identification by IP is the highest-risk, lowest-precision feature here: shared NATs, VPNs, and mobile carriers produce wrong companies. Gate it to sessions with meaningful activity (e.g. 3+ pageviews in 10 minutes), cache the IP → company mapping for 24h, and never let it block the request. Also treat "reveal" as enrichment of a data subject, not just a lookup.
Prospector is a batch tool, not a request-cycle tool. Search is paginated and expensive; drive it from an artisan command or queued job, persist results to your own table, and paginate against your table from the UI. Never page through Prospector from a web request.
Respect the rate limit with Laravel primitives. Add ->middleware('throttle:clearbit') to the job, or a RateLimited job middleware, and configure the limiter in a service provider. A naive foreach ($users as $user) { enrich($user); } will burst straight into 429s on any real import.
Test with Http::fake(). The package almost certainly uses the Laravel HTTP client underneath, so faking responses by URL pattern is trivial and you should never hit the live API in tests. Keep a small fixture set: a hit, a 404 miss, a 202 pending, and a 429.
saving model events, or in a Blade partial that renders per row. Instrument your wrapper with a counter in local/staging so a refactor's cost is visible before it hits production.Http::retry(3, 200, throw: false)); a 401 or 404 retried three times just triples your latency and log noise.config('clearbit.api_key') out of dd() output, error trackers, and any endpoint that dumps config. php artisan config:cache in production after any config change, or your new key won't be picked up.gmail.com and outlook.com will resolve to the consumer mail provider, not the user's employer. Filter free-mail domains before enrichment so you don't waste credits or worse, store "Google" as everyone's employer.Macroable trait on the client if the package ships one — that's the clean way to add your own methods without forking.How can I help you explore Laravel packages today?