JavaScript SDK
Use the official JavaScript SDK for Node.js and browser apps.
Install
npm install @companydata/protool-sdk
Initialize client
import { ApiClient } from '@companydata/protool-sdk'
const client = new ApiClient({
baseUrl: 'https://app.companydata.com',
auth: {
type: 'apiKey',
apiKey: process.env.COMPANYDATA_API_KEY ?? '',
},
timeoutMs: 15000,
retry: {
maxRetries: 2,
},
})
Make your first request
const result = await client.company.search({
countryCode: 'NL',
search: 'BoldData',
page: 1,
pageSize: 25,
})
console.log(result.data)
Export with scroll pagination
let page = await client.company.exportWithScroll({
countryCode: 'NL',
pageSize: 1000,
})
while (page.hasMoreRecords) {
// process page.data
page = await client.company.exportWithScroll({
scrollId: page.scrollId,
pageSize: 1000,
})
}
Lookup endpoints
const cities = await client.lookup.cities({
search: 'ams',
countries: 'NL',
limit: 100,
})
console.log(cities.data)
Handle API errors
import { ApiError } from '@companydata/protool-sdk'
try {
await client.company.search({
countryCode: 'NL',
search: 'BoldData',
})
} catch (error) {
if (error instanceof ApiError) {
console.error(error.status, error.code, error.requestId)
} else {
console.error(error)
}
}
Notes
- The SDK package supports Node.js and browser runtimes.
- Main SDK methods map to:
client.company.search->/api/company/searchclient.company.export->/api/company/exportclient.company.exportWithScroll->/api/company/export?useScroll=trueclient.lookup.*->/api/cities|provinces|regions|countries
- For endpoint-specific filters and response field definitions, see Company API and Response Fields.