Logo
Section 1 / 2

获取域名和Logo

学习并实践如何使用 Clearbit API 获取公司的域名和图标。

导入

学习并实践如何使用 Clearbit API 获取公司的域名和图标。

...
The name to domain endpoint

代码示例

1https://company.clearbit.com/v1/domains/find?name={公司名称}
字段名类型必填说明
namestring是要查询域名的公司名称。
1import fetch from 'node-fetch'; 2 3const API_KEY = 'Bearer {{API_KEY}}'; 4 5const endpointUrl = new URL('https://company.clearbit.com/v1/domains/find'); 6 7const headerParameters = { 8 authorization: API_KEY, 9 contentType: 'application/json', 10}; 11 12const queryParameters = new URLSearchParams({ 13 name: '{{NAME}}' 14}); 15 16const options = { 17 method: 'GET', 18 headers: headerParameters, 19}; 20 21async function fetchData() { 22 try { 23 endpointUrl.search = queryParameters; 24 const response = await fetch(endpointUrl, options); 25 26 // 自定义函数:打印 API 响应 27 printResponse(response); 28 } catch (error) { 29 30 // 自定义函数:打印错误信息 31 printError(error); 32 } 33} 34 35// 调用函数发起 API 请求 36fetchData();
字段名类型说明
domainstring公司的网站域名。
logostring公司 logo 的 URL 地址。
namestring公司名称。
...
The logo endpoint
字段名类型必填说明
domainstring是公司的网站域名。
sizeinteger否请求图像的尺寸,指图像最长边的像素长度,默认值为 128。
formatstring否请求图像的格式,可选 "png" 或 "jpg",默认值为 "png"。
greyscaleboolean否若为 true,则将图像去色处理,默认值为 false。
1const endpointUrl = new URL('https://logo.clearbit.com/{{DOMAIN}}'); 2 3async function fetchData() { 4 try { 5 console.log("<img src="+endpointUrl+" style='display: block; margin-left:auto ;margin-right:auto;'>") 6 } catch (error) { 7 // 自定义函数:打印错误信息 8 printError(error); 9 } 10} 11 12// 调用函数发起 API 请求 13fetchData();
字段名类型说明
logopng 或 jpg公司 logo 的图像。

风险 API

自动补全