Wern Ancheta

Adventures in Web Development.

Getting Information About Any Company With Clearbit's Company API

| Comments

In this tutorial I’ll be showing you how you can get information from any company using the Clearbit Company API.

Start by signing up for an account on the Clearbit website. An API key will be assigned to your account after signing up. This allows you to make a request to their API.

Next, install Guzzle on your working directory. Guzzle is an HTTP library for PHP. It is used to easily make requests to any API.

1
composer require guzzlehttp/guzzle:~6.0

Include the vendor autoload file on your file and create a new Guzzle client with the following base uri: https://company.clearbit.com/.

1
2
3
4
5
<?php
require_once 'vendor/autoload.php';

$client = new GuzzleHttp\Client(array('base_uri' => 'https://company.clearbit.com/'));
?>

To use the API, make a get request to the v1/companies/domain/ endpoint followed by the domain name of the company that you want. Pass in the auth as an option. This allows you to specify the API key which you got from Clearbit.

1
2
3
4
5
<?php
$response = $client->get('v1/companies/domain/google.com', array(
    'auth' => array('YOUR-CLEARBIT-API-KEY', '')
));
?>

You can then get the response body by calling the getBody method in the response. In the example below, the response is converted to an array using the json_decode method.

1
2
3
4
5
6
<?php
$data = json_decode($response->getBody(), true);
?>
<pre>
<?php print_r($data); ?>
</pre>

The output will look something like the following.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
Array
(
[id] => 1d396c21-e421-4dd9-988e-55a8200c6e10
[name] => Google
[legalName] => Google Inc
[domain] => google.com
[domainAliases] => Array
    (
        [0] => covet.com
        [1] => appspotchat.com
        [2] => ggh-uae.com
        [3] => remail.com
        [4] => orkut.com
        [5] => goolge.com
        [6] => picasa.com
        [7] => blogspot.ru
        [8] => sparkbuy.com
        [9] => pushlife.com
        [10] => greenparrotpictures.com
        [11] => phonetic-arts.com
        [12] => omnisio.com
        [13] => googlecloud.com
        [14] => weardrobe.com
        [15] => ojos-inc.com
        [16] => akwan.com.br
        [17] => appliedsemantics.com
        [18] => gemail.com.br
        [19] => wosix.com
        [20] => firstinwireless.com
        [21] => cloudmarket.me
        [22] => riya.com
        [23] => teronamanagement.com
        [24] => sxz.co
        [25] => womenfitnessinsider.com
        [26] => webtocracy.org
        [27] => webtocracy.com
        [28] => webtocracy.net
        [29] => superapple.org
        [30] => storktechnology.com
        [31] => sourful.com
        [32] => snapchatdeals.com
        [33] => quarterthree.com
        [34] => puwak.com
        [35] => nudevilla.com
        [36] => nemzis.com
        [37] => ryanstull.com
        [38] => mckayfamily.org
        [39] => marksearle.net
        [40] => opentolink.com
        [41] => lewispi.com
        [42] => levkova.com
        [43] => katenka.net
        [44] => imize.net
        [45] => google.us
        [46] => com.google
        [47] => gogle.com
        [48] => oingo.com
        [49] => googlesyndication.com
        [50] => ggoogle.com
        [51] => google.io
        [52] => blogspot.ae
        [53] => gogole.com
        [54] => hijab.pw
        [55] => industrial-perception.com
        [56] => googlr.com
        [57] => googleadservices.com
        [58] => talkbin.com
        [59] => picnik.com
        [60] => postrank.com
        [61] => appjet.com
        [62] => google.co
        [63] => zabrinalee.com
        [64] => blu-ray.us
        [65] => picasa.net
        [66] => googleproductforums.com
        [67] => googlelabs.com
        [68] => googlee.com
        [69] => gooogle.com
        [70] => diychef.com
        [71] => googl.com
        [72] => gmail.co
        [73] => blogger.ch
        [74] => mozingo.me
        [75] => orkut.org
        [76] => lifescapeinc.com
        [77] => firehunt.com
        [78] => google.info
        [79] => veremey.net
        [80] => docverse.com
    )

[url] => http://google.com
[site] => Array
    (
        [url] => http://google.com
        [title] => Google
        [h1] => 
        [metaDescription] => Search the world's information, including webpages, images, videos and more. Google has many special features to help you find exactly what you're looking for.
        [metaAuthor] => 
    )

[category] => Array
    (
        [sector] => Consumer Discretionary
        [industryGroup] => Media
        [industry] => Media
        [subIndustry] => Publishing
    )

[tags] => Array
    (
    )

[description] => Google’s mission is to organize the world’s information and make it universally accessible and useful.
[location] => 1600 Amphitheatre Parkway, Mountain View, CA 94043, USA
[geo] => Array
    (
        [streetNumber] => 1600
        [streetName] => Amphitheatre Parkway
        [subPremise] => 
        [city] => Mountain View
        [state] => California
        [country] => United States
        [postalCode] => 94043
        [lat] => 37.4224206
        [lng] => -122.0843021
    )

[logo] => https://logo.clearbit.com/google.com
[facebook] => Array
    (
        [handle] => google
        [likes] => 
    )

[linkedin] => Array
    (
        [handle] => company/google
    )

[twitter] => Array
    (
        [handle] => google
        [id] => 20536157
        [bio] => News and updates from Google
        [followers] => 11873983
        [following] => 448
        [location] => Mountain View, CA
        [site] => http://t.co/twxHxOtTvy
        [avatar] => https://pbs.twimg.com/profile_images/522909800191901697/FHCGSQg0_normal.png
    )

[angellist] => Array
    (
        [id] => 32203
        [handle] => google
        [description] => Google’s mission is to organize the world’s information and make it universally accessible and useful.
        [followers] => 7097
        [blogUrl] => http://googleblog.blogspot.com/
    )

[crunchbase] => Array
    (
        [handle] => google
    )

[emailProvider] => 
[type] => public
[ticker] => 
[phone] => +1 650-253-0000
[metrics] => Array
    (
        [alexaUsRank] => 1
        [alexaGlobalRank] => 1
        [googleRank] => 9
        [employees] => 10000
        [marketCap] => 
        [raised] => 1700000000
    )

[tech] => Array
    (
        [0] => google_analytics
        [1] => double_click
        [2] => google_adwords
        [3] => doubleclick
        [4] => google_apps
    )

)

Comments