Authentication
Learn how to authenticate your requests to The Companies API.
The Companies API uses API tokens to authenticate requests. They are permanent, never expire, and safe for long-term purposes.
You can manage your API tokens in your settings or on this page below.
Your API tokens carry many privileges, so keep them secure!
Signup to access all the features
Get your API token and start implementing the API in your product with 500 free credits.
No credit card required
API tokens
There are multiple ways to authenticate your HTTPS requests to the API.
- By adding an
Authorization
header. TheAuthorization
header is formatted as such:Authorization: Basic MY-API-TOKEN
(replaceMY-API-TOKEN
with one of yours). - By sending the API token as a
GET
parameter. Like this?token=MY-API-TOKEN
(mostly used to quickly test an endpoint). - You can also authenticate your requests using our SDKs for your favorite programming languages. The JavaScript SDK is already available.
Code examples
Select your favorite language:
// Example 1 : With our SDK
import createClient from '@thecompaniesapi/sdk'
const tca = createClient({ apiToken: 'YOUR_API_TOKEN' })
const response = await tca.fetchCompany({
domain: 'thecompaniesapi.com'
})
const company = response.data // The company profile
// Example 2 : With a GET parameter
const response = await fetch('https://api.thecompaniesapi.com/v2/companies/thecompaniesapi.com?token=YOUR_API_TOKEN')
const company = response.data // The company profile
// Example 3 : With an Authorization header
const response = await fetch('https://api.thecompaniesapi.com/v2/companies/thecompaniesapi.com', {
headers: {
'Authorization': 'Basic YOUR_API_TOKEN'
}
})
const company = response.data // The company profile