
Security News
Nx npm Packages Compromised in Supply Chain Attack Weaponizing AI CLI Tools
Malicious Nx npm versions stole secrets and wallet info using AI CLI tools; Socketβs AI scanner detected the supply chain attack and flagged the malware.
A fully-featured Ruby SDK for The Companies API, providing type-safe access to company data, locations, industries, technologies, job titles, lists, and more.
If you need more details about a specific endpoint, you can find the corresponding documentation in the API reference.
You can also contact us on our livechat if you have any questions.
Add this line to your application's Gemfile:
gem 'thecompaniesapi'
And then execute:
bundle install
Or install it yourself as:
gem install thecompaniesapi
Get your API token from your settings page and initialize our client with TheCompaniesAPI::Client.new
.
The API token is required to authenticate your requests and should be kept secure. Never commit your API token to version control or share it publicly.
require 'thecompaniesapi'
tca = TheCompaniesAPI::Client.new(api_token: 'your-api-token')
π Documentation
πΉοΈ Use case: How to build a company search engine with our API
π To learn more about our query system, please read our documentation.
# Search companies by industry and size
response = tca.search_companies(
query: [
{ attribute: 'about.industries', operator: 'or', sign: 'equals', values: ['computer-software'] },
{ attribute: 'about.totalEmployees', operator: 'or', sign: 'equals', values: ['10-50'] }
],
size: 25
)
companies = response['companies'] # Companies that match the query
meta = response['meta'] # Meta information
π Documentation
πΉοΈ Use case: Add a company search with autocomplete to your application
response = tca.search_companies_by_name(
name: 'The Companies API',
size: 2
)
companies = response['companies'] # Companies that match the name
meta = response['meta'] # Meta information
π Documentation
# Search 25 companies for a specific prompt
response = tca.search_companies_by_prompt(
prompt: 'SaaS Companies in the United States with more than 100 employees',
size: 25
)
companies = response['companies'] # Companies that match the prompt
meta = response['meta'] # Meta information
π Documentation
# Search 25 companies that are similar to Crisp and Intercom
response = tca.search_similar_companies(
domains: ['crisp.chat', 'intercom.com'],
size: 25
)
companies = response['companies'] # Companies that are similar to the domains
meta = response['meta'] # Meta information
π Documentation
# Count how many companies are in the computer-software industry
response = tca.count_companies(
query: [
{
attribute: 'about.industries',
operator: 'or',
sign: 'equals',
values: ['computer-software']
}
]
)
count = response # Number of companies that match the query
π Documentation
# Fetch company data from our database without enrichment (faster response)
response = tca.fetch_company(domain: 'microsoft.com')
company = response # The company profile
# Fetch company data and re-analyze it in real-time to get fresh, up-to-date information (slower but more accurate)
response = tca.fetch_company(
domain: 'microsoft.com',
refresh: true
)
company = response # The company profile
π Documentation
πΉοΈ Use case: Enrich your users at signup with the latest information about their company
# Fetch the company profile behind a professional email address
response = tca.fetch_company_by_email(email: 'jack@openai.com')
company = response # The company profile
π Documentation
# Fetch the company profile behind a social network URL
response = tca.fetch_company_by_social(linkedin: 'https://www.linkedin.com/company/apple')
company = response # The company profile
π Documentation
# Fetch the company email patterns for a specific domain
response = tca.fetch_company_email_patterns(domain: 'apple.com')
patterns = response # The company email patterns
π Documentation
# Ask what products a company offers using its domain
response = tca.ask_company(
domain: 'microsoft.com',
question: 'What products does this company offer?',
model: 'large', # 'small' is also available
fields: [
{
key: 'products',
type: 'array|string',
description: 'The products that the company offers'
}
]
)
answer = response['answer'] # Structured AI response
meta = response['meta'] # Meta information
π Documentation
# Get AI-generated strategic insights about a company
response = tca.fetch_company_context(domain: 'microsoft.com')
context = response['context'] # Includes market, model, differentiators, etc.
meta = response['meta'] # Meta information
π Documentation
# Analyze company distribution by business type
response = tca.fetch_companies_analytics(
attribute: 'about.businessType',
query: [
{
attribute: 'locations.headquarters.country.code',
operator: 'or',
sign: 'equals',
values: ['us', 'gb', 'fr']
}
]
)
analytics = response['data'] # Aggregated values
meta = response['meta'] # Meta information
π Documentation
# Export analytics to CSV
response = tca.export_companies_analytics(
format: 'csv',
attributes: ['about.industries', 'about.totalEmployees'],
query: [
{
attribute: 'technologies.active',
operator: 'or',
sign: 'equals',
values: ['shopify']
}
]
)
analytics = response['data'] # Aggregated values
meta = response['meta'] # Meta information
π Documentation
# Request an enrichment job on multiple companies
response = tca.request_action(
domains: ['microsoft.com', 'apple.com'],
job: 'enrich-companies',
estimate: false
)
actions = response['actions'] # Track this via fetch_actions
meta = response['meta'] # Meta information
π Documentation
# Fetch recent actions
response = tca.fetch_actions(
status: 'completed',
page: 1,
size: 5
)
actions = response['actions'] # Actions that match the query
meta = response['meta'] # Meta information
π Documentation
# Search industries by keyword
response = tca.search_industries(
search: 'software',
size: 10
)
industries = response['industries'] # Industries that match the keyword
meta = response['meta'] # Meta information
π Documentation
# Find industries similar to given ones
response = tca.search_industries_similar(industries: ['saas', 'fintech'])
similar = response['industries'] # Industries that are similar to the given ones
meta = response['meta'] # Meta information
π Documentation
# Search technologies by keyword
response = tca.search_technologies(
search: 'shopify',
size: 10
)
technologies = response['technologies'] # Technologies that match the keyword
meta = response['meta'] # Meta information
π Documentation
# Search cities by name
response = tca.search_cities(
search: 'new york',
size: 5
)
cities = response['cities'] # Cities that match the name
meta = response['meta'] # Meta information
π Documentation
# Search counties by name
response = tca.search_counties(
search: 'orange',
size: 5
)
counties = response['counties'] # Counties that match the name
meta = response['meta'] # Meta information
π Documentation
# Search states by name
response = tca.search_states(
search: 'california',
size: 5
)
states = response['states'] # States that match the name
meta = response['meta'] # Meta information
π Documentation
# Search countries by name
response = tca.search_countries(
search: 'france',
size: 5
)
countries = response['countries'] # Countries that match the name
meta = response['meta'] # Meta information
π Documentation
# Search continents by name
response = tca.search_continents(
search: 'asia',
size: 5
)
continents = response['continents'] # Continents that match the name
meta = response['meta'] # Meta information
π Documentation
# Enrich "chief marketing officer"
response = tca.enrich_job_titles(name: 'chief marketing officer')
job_title = response # Contains department, seniority, etc.
π Documentation
# Fetch your lists
response = tca.fetch_lists
lists = response['lists'] # Lists that match the query
meta = response['meta'] # Meta information
π Documentation
# Create a list of companies
response = tca.create_list(
name: 'My SaaS List',
type: 'companies'
)
new_list = response # The new list
π Documentation
# Fetch companies in a list
response = tca.fetch_companies_in_list(list_id: 1234)
companies = response['companies'] # Companies that match the list
meta = response['meta'] # Meta information
π Documentation
# Add companies to a list
response = tca.toggle_companies_in_list(
list_id: 1234,
companies: ['apple.com', 'stripe.com']
)
list = response # The updated list
π Documentation
# Fetch your team details
response = tca.fetch_team
team = response # Your team details
π Documentation
# Check API health status
response = tca.fetch_api_health
health = response # The health of the API
π Documentation
# Fetch OpenAPI schema
response = tca.fetch_open_api
schema = response # The OpenAPI schema
MIT License Β© TheCompaniesAPI
FAQs
Unknown package
We found that thecompaniesapi demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago.Β It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Malicious Nx npm versions stole secrets and wallet info using AI CLI tools; Socketβs AI scanner detected the supply chain attack and flagged the malware.
Security News
CISAβs 2025 draft SBOM guidance adds new fields like hashes, licenses, and tool metadata to make software inventories more actionable.
Security News
A clarification on our recent research investigating 60 malicious Ruby gems.