Package Exports
- @thecompaniesapi/sdk
- @thecompaniesapi/sdk/package.json
Readme
@thecompaniesapi/sdk
A TypeScript SDK for The Companies API, providing type-safe access to the API.
Features
- Type-safe API client with full TypeScript support from our OpenAPI schema
- Search companies using our complete search engine API
- Enrich companies on demand using actions or sync enrichment requests
- Manage your lists of companies
- Request and track specific actions
- Get analytics about a search query or a list
- Ask question on any company and get structured answers
Installation
npm install @thecompaniesapi/sdk
# or
yarn add @thecompaniesapi/sdk
# or
pnpm add @thecompaniesapi/sdkUsage
Get your API key from your settings page.
import { createClient } from '@thecompaniesapi/sdk'
// Create a base client
const tca = createClient({
apiKey: 'your-api-key',
})Examples
Fetch a company data
// Fetch a company data if it exists in our database
const { data } = await tca.fetchCompany({
domain: 'microsoft.com'
})
// Fetch a company data and enrich it if it doesn't exist
const { data } = await tca.fetchCompany({
domain: 'microsoft.com',
sync: true
})Searching companies
const { data } = await tca.searchCompanies({
query: [
{
attribute: 'about.industries',
operator: 'or',
sign: 'equals',
values: ['higher-education']
}
],
size: 3
})Add companies to your lists
// Create a new list
const { data: myNewList } = await tca.createList({
name: 'My list',
})
// Add companies to the list
const { data } = await tca.addCompaniesToList({
listId: myNewList.id,
companies: ['microsoft.com', 'apple.com']
})License
MIT License © TheCompaniesAPI