Skip to main content
POST
/
company
/
search
Search companies using SQL query
curl --request POST \
  --url https://api.example.com/company/search \
  --header 'API-Key: <api-key>' \
  --header 'Content-Type: application/json' \
  --data @- <<EOF
{
  "query": "SELECT * FROM companies WHERE industry ILIKE '%software%' AND size='1001-5000'",
  "limit": 10
}
EOF
{
  "matches": [
    {
      "company": {
        "legion_id": "c8a1b2c3-d4e5-6f7a-8b9c-0d1e2f3a4b5c",
        "name": {
          "cleaned": "stripe inc",
          "raw": [
            "Stripe, Inc."
          ]
        },
        "domain": "stripe.com",
        "industry": "financial services",
        "type": "private",
        "size": "5001-10000",
        "founded": 2010,
        "linkedin_url": "https://www.linkedin.com/company/stripe",
        "linkedin_id": "2135371",
        "legion_employee_count": 8500,
        "legion_average_tenure": 28.4,
        "legion_employee_growth_rate": {
          "1m": 0.012,
          "3m": 0.035,
          "6m": 0.068,
          "12m": 0.125
        },
        "last_seen": "2026-01",
        "num_sources": 5
      }
    }
  ],
  "total": 1
}

Query Format

Write a SELECT * FROM companies WHERE ... query. Do not include a LIMIT clause — use the limit parameter instead.
{
  "query": "SELECT * FROM companies WHERE industry ILIKE '%software%' AND legion_employee_count > 100",
  "limit": 5
}

Available Columns

Text Columns

ColumnDescription
name_cleanedCompany name
domainPrimary website domain
industryIndustry classification
headline_cleanedLinkedIn headline
description_cleanedCompany description

Numeric Columns

ColumnDescription
foundedYear founded
linkedin_followersLinkedIn follower count
linkedin_employee_countEmployee count from LinkedIn
legion_employee_countEmployee count from Data Legion
legion_average_tenureAverage employee tenure (months)

Enum Columns

ColumnValues
typeprivate, public, nonprofit, government_agency, educational
size1-10, 11-50, 51-200, 201-500, 501-1000, 1001-5000, 5001-10000, 10001+

Workforce Analytics Columns

ColumnDescription
legion_new_hire_count_1m / 3m / 6m / 12mNew hires in last 1/3/6/12 months
legion_attrition_count_1m / 3m / 6m / 12mDepartures in last 1/3/6/12 months
legion_employee_growth_rate_1m / 3m / 6m / 12mGrowth rate (%)
legion_turnover_rate_1m / 3m / 6m / 12mTurnover rate (%)

Cross-Table Columns

These columns search across related tables and are automatically rewritten to subqueries:
ColumnDescription
ticker_symbol / tickerStock ticker symbol
exchangeStock exchange
social_urlSocial media URLs
alt_domainAlternative domains

Example Queries

-- Software companies with 100+ employees
SELECT * FROM companies WHERE industry ILIKE '%software%' AND legion_employee_count > 100

-- Public companies in healthcare
SELECT * FROM companies WHERE type = 'public' AND industry ILIKE '%health%'

-- Fast-growing companies (20%+ growth in last 6 months)
SELECT * FROM companies WHERE legion_employee_growth_rate_6m > 20

-- Companies with high turnover
SELECT * FROM companies WHERE legion_turnover_rate_12m > 30 AND legion_employee_count > 50

Authorizations

API-Key
string
header
required

Body

application/json

Request model for SQL query-based company search.

query
string
required

SQL query against company data (must not contain LIMIT)

Required string length: 1 - 10000
limit
integer
required

Maximum results to return

Required range: 1 <= x <= 100
titlecase
boolean
default:false

If true, format text fields in title case (names, company names, locations). Raw fields, IDs, URLs, codes, and confidence fields are excluded.

include_fields
string | null

Comma-separated list of fields to include in response. If omitted, all fields are returned.

exclude_fields
string | null

Comma-separated list of fields to exclude from response. Applied after include_fields filter.

pretty_print
boolean
default:false

If true, pretty-print JSON response with indentation.

Response

Success - query executed and results returned

matches
CompanyMatchResponse · object[]
required
total
integer
required