Skip to main content
POST
Search companies using SQL query
Send exactly one of these with each request: Sending two is a 422 that names both. sql takes only SQL and es_query only a query object. The older query parameter still works (SQL as text, a query object as an object); new code should use the inputs above.
The same search as SQL:

Filters

Filter keys are the record’s own field names: the ones in every response and on the field reference. One grammar works for every field: Every field you give must hold. Free text (names, headlines, descriptions) matches the words in order; every other field matches the whole value. Case never matters, and places and websites take any common spelling (TX, us-tx and Texas are the same state). A company’s offices are a list: fields under locations given together must hold for the same office. The headquarters is the office marked primary, so “headquartered in Austin” is {"locations.city": "austin", "locations.primary": true}; without locations.primary, any office on record counts. A key that is not a field of the record is a 422 that names the closest real fields. Fields outside your plan are refused, as they are in SQL.

Combining Filters

To combine sets of fields, wrap them in a group, which is also how to rule something out: {"and": [...]} (all must hold), {"or": [...]} (any may hold) or {"not": {...}} (must not hold). Groups nest up to 3 levels, with up to 20 items in each.

Boolean Keywords

keywords takes a Boolean search string, written the way recruiters write one: words and "quoted phrases", with AND, OR and NOT in capitals and parentheses for grouping. Words side by side mean AND, and a lowercase “and” is just a word. NOT binds tightest, then AND, then OR, so python AND django OR flask means (python AND django) OR flask. It searches the company’s name, headline and description, and combines with every other filter.
A syntax error (an unclosed quote or parenthesis, an operator with nothing beside it) is a 422 that says where.

SQL

Write a SELECT * FROM companies WHERE ... query in sql. Do not include LIMIT or OFFSET clauses; use the limit and offset parameters instead.

Response Shape

  • matches: capped at the request’s limit (default 1, max 100).
  • total: how many rows match across the whole database, not just this page, so a request with limit: 1 tells you how big a list is (“fintech companies founded after 2018”). The Total-Count-Status header says how to read it: exact (selective queries), estimate (a broad query’s count ran out of time; total is a lower bound), or page (no count; total is the offset plus the rows returned). Search responses carry no match_metadata; only /company/enrich does. A broad query returns the same response shape with a lower-bound total, flagged by the header:
  • next_cursor: the cursor for the next page when more results follow (send it back as cursor, see Cursors below); null on the last page.
  • Industry filters: industry holds the lowercased LinkedIn industry names in Enums. A filter no stored value can match (an older LinkedIn name such as '%information technology%') returns an empty page at once, free, with a Search-Warning header naming the filter and the closest stored values.
  • Company name and city aliases: in SQL, a name_cleaned filter (=, LIKE or ILIKE) also matches the company’s other names: name_cleaned = 'meta' also finds “facebook” and “meta platforms”. A city or hq_city filter also matches the place’s other names: city = 'NYC' also finds “new york”. filters on name.cleaned and the locations places match them too, and the Search-Warning header names what was also matched. IN (...) lists and query objects (es_query) match without them.
  • Case: capitalization never changes the answer: on a direct text column =, <>, IN, NOT IN, LIKE and ~ all ignore case, so name = 'Stripe' finds “stripe”. Only a regular expression that asks about case (name_display ~ '^[A-Z]{2,5}$') stays case-sensitive.
  • Websites: a domain can be written as a URL: domain = 'https://www.stripe.com/' means 'stripe.com', in SQL and in a query object’s term and terms.
  • Field paths: a field can be named as the response writes it. headline.cleaned, name.display and locations.country_code are read as their columns.
  • Short patterns: a one- or two-character contains-pattern matches the whole word on names, industries and descriptions ('%hp%' finds “hp”, not “hpe” or “shopify”), a whole part of a domain (domain ILIKE '%ai%' finds open.ai and ai.com), and the letters anywhere on places and URLs. The Search-Warning header says which; write the full name, or match the domain’s full value with =. Tickers and exchanges are exempt.
  • Sort order: results come in a stable order, with legion_id as the final tie-break after your own ORDER BY, so the same request returns the same page and paging never repeats or skips a record while the data is unchanged.

Query Objects (es_query)

Instead of SQL, send es_query: a query object in the Elasticsearch query syntax. It suits code that builds filters, and it uses the field names of the response itself.
  • Supported: bool (must, should, filter, must_not, minimum_should_match), term, terms, match, match_phrase, range, exists, prefix, wildcard and nested. Anything else, such as scripts, aggregations, regexp, fuzzy, query_string or boosts, returns a 400; so does a parameter a supported type doesn’t take (such as boost inside term).
  • Fields: the response’s own paths (domain, industry, locations.city), on fields your contract covers. A trial account searches only the fields its responses include.
  • Case: term, terms, prefix and wildcard ignore case. match and match_phrase search the words of a text field. wildcard takes * and ?, but not at the start of the pattern.
  • locations (offices) is an array: a filter on locations.* matches when any one office matches, and wrapping several filters in nested makes them hold for the same office.
  • Limits: up to 10 levels deep, 100 leaf filters and 1,000 values in one terms; at most 1,020 conditions once lists are expanded. minimum_should_match is a count up to 100 or a percentage.
  • As text: a query object can also be sent as JSON text, which is how a GET request carries one (?es_query={"term":{"industry":"banking"}}, URL-encoded); filters works the same way. Prefer POST: a GET puts the query in the URL. A whole Elasticsearch search body, {"query": {...}}, is read as the query inside it.
  • Refused: keys other than the documented parameters (such as aggs, sort or size) are a 422 that names them, and any query type or parameter not listed above is a 400.
Everything else works as it does with SQL: the sort order, limit, offset and cursor, field selection, credits and the response shape.

Pagination

To page through results beyond the first 100, set offset to the number of rows to skip. Maximum offset is 10,000.
Order is stable within a data build (see Sort order above) and can change with a new build, so finish paging within one session rather than across days.

Cursors

To read deeper than offset allows, or to export a whole result set, page with a cursor. A page with more results after it carries next_cursor; send it back as cursor, without offset, with the same search. On the last page next_cursor is null, even when the page is full.
A cursor belongs to one search on one dataset build. A cursor from a different query, or from before a new build, returns a 400 saying so: start again from the first page. A cursor works for SQL, query objects and filters alike.

Available Columns

Text Columns

Numeric Columns

Enum Columns

Workforce Analytics Columns

Every window ends at the release’s as-of month, not the release date; see Data Freshness.

Location Columns

Filter by where a company has offices. The plain columns match any current office; the hq_ columns match only the headquarters. They take =, IN (...) and LIKE / ILIKE, ignoring case. A state or country can be written as its code or its name, in any case: state_code = 'CA' or 'California' means 'US-CA', state = 'TX' means 'texas', country = 'US' or 'USA' means 'united states', and country_code = 'usa' means 'US'. A bare state code is read as a US state unless the query names another country. A city name can repeat across countries, so pair it with a country or state when that matters: city = 'london' AND country_code = 'GB'. A company matches when any one of its offices does, so city = 'austin' AND state_code = 'US-TX' can match a company with an office in each. Filtering on locations needs the locations field in your plan.

Cross-Table Columns

These columns search across related tables and are automatically rewritten to subqueries: A cross-table column matches when any one of the company’s related rows matches. It supports ILIKE patterns (LIKE matches the same way) with % as the wildcard (ticker ILIKE 'MS%' matches tickers starting with MS), = for an exact match that ignores case (ticker_symbol = 'aapl', alt_domain = 'google.com') and IN (...) for any of several values. To exclude, wrap the filter: NOT (exchange = 'nasdaq'). Other operators on these columns, such as ~*, NOT ILIKE or NOT IN (...), return a 400 that lists the supported forms.

Example Queries

Authorizations

API-Key
string
header
required

Body

application/json

Request model for Company Search: sql, es_query or filters, and the page.

query
deprecated

Deprecated: send sql or es_query. A SQL SELECT statement when text, a query object when an object (or text starting with "{"); still accepted as before.

sql
string | null

A SQL SELECT statement (no LIMIT or OFFSET clause: use limit and offset).

es_query
Es Query · object | null

A query object in the Elasticsearch query DSL, naming the response's field paths (bool, term, terms, match, match_phrase, range, exists, prefix, wildcard, nested). A GET may send it as JSON text.

filters
Filters · object

The company record's own field names; every one given must hold.

limit
integer
default:1

Maximum number of results to return (replaces LIMIT in query) (default: 1, max: 100)

Required range: 1 <= x <= 100
offset
integer
default:0

Number of results to skip for pagination (0-10000). Stable within a build; ordering may change across builds.

Required range: 0 <= x <= 10000
cursor
string | null

Continue a search from the previous page's next_cursor: the next page in the same order, past offset's 10,000-row reach, for deep pages and exports. Send the same query, and no offset. A cursor works for the dataset build it came from; after a new build, start again.

Maximum string length: 65536
titlecase
boolean
default:false

If true, format text fields in title case

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

Company Search response: a page of matches.

matches
CompanyMatchResponse · object[]
required

List of matches sorted by confidence (descending).

total
integer
required

For /company/search and /company/discover, the total number of rows matching the query's WHERE clause across the database (not just this page). On search/discover, if the exact count exceeds its time budget (broad, low-selectivity queries) it falls back to the matches counted before the budget ran out (a lower bound), and if that does not cover this page, to the offset plus the rows returned; the response header Total-Count-Status reports which (exact, estimate, or page).

next_cursor
string | null

The cursor for the next page when more results follow: send it as cursor, with the same query (on Discover it reruns the same search). Null on the last page.