Count companies a search would match
curl --request POST \
--url https://api.datalegion.ai/company/search/count \
--header 'API-Key: <api-key>' \
--header 'Content-Type: application/json' \
--data '
{
"filters": {
"industries": [
"software development"
],
"sizes": [
"51-200"
]
}
}
'import requests
url = "https://api.datalegion.ai/company/search/count"
payload = { "filters": {
"industries": ["software development"],
"sizes": ["51-200"]
} }
headers = {
"API-Key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'API-Key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({filters: {industries: ['software development'], sizes: ['51-200']}})
};
fetch('https://api.datalegion.ai/company/search/count', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.datalegion.ai/company/search/count",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'filters' => [
'industries' => [
'software development'
],
'sizes' => [
'51-200'
]
]
]),
CURLOPT_HTTPHEADER => [
"API-Key: <api-key>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.datalegion.ai/company/search/count"
payload := strings.NewReader("{\n \"filters\": {\n \"industries\": [\n \"software development\"\n ],\n \"sizes\": [\n \"51-200\"\n ]\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("API-Key", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.datalegion.ai/company/search/count")
.header("API-Key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"filters\": {\n \"industries\": [\n \"software development\"\n ],\n \"sizes\": [\n \"51-200\"\n ]\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.datalegion.ai/company/search/count")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["API-Key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"filters\": {\n \"industries\": [\n \"software development\"\n ],\n \"sizes\": [\n \"51-200\"\n ]\n }\n}"
response = http.request(request)
puts response.read_body{
"total": 123,
"total_status": "about",
"generated_query": {}
}{
"error": "<string>",
"message": "<string>",
"details": {}
}{
"error": "<string>",
"message": "<string>",
"details": {}
}{
"error": "<string>",
"message": "<string>",
"details": {}
}{
"error": "<string>",
"message": "<string>",
"details": {}
}{
"error": "<string>",
"message": "<string>",
"details": {}
}{
"error": "<string>",
"message": "<string>",
"details": {}
}Company
Company Search Count API
Count the companies a company search would match, free and without returning records, to size a list before you buy it.
POST
/
company
/
search
/
count
Count companies a search would match
curl --request POST \
--url https://api.datalegion.ai/company/search/count \
--header 'API-Key: <api-key>' \
--header 'Content-Type: application/json' \
--data '
{
"filters": {
"industries": [
"software development"
],
"sizes": [
"51-200"
]
}
}
'import requests
url = "https://api.datalegion.ai/company/search/count"
payload = { "filters": {
"industries": ["software development"],
"sizes": ["51-200"]
} }
headers = {
"API-Key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'API-Key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({filters: {industries: ['software development'], sizes: ['51-200']}})
};
fetch('https://api.datalegion.ai/company/search/count', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.datalegion.ai/company/search/count",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'filters' => [
'industries' => [
'software development'
],
'sizes' => [
'51-200'
]
]
]),
CURLOPT_HTTPHEADER => [
"API-Key: <api-key>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.datalegion.ai/company/search/count"
payload := strings.NewReader("{\n \"filters\": {\n \"industries\": [\n \"software development\"\n ],\n \"sizes\": [\n \"51-200\"\n ]\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("API-Key", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.datalegion.ai/company/search/count")
.header("API-Key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"filters\": {\n \"industries\": [\n \"software development\"\n ],\n \"sizes\": [\n \"51-200\"\n ]\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.datalegion.ai/company/search/count")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["API-Key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"filters\": {\n \"industries\": [\n \"software development\"\n ],\n \"sizes\": [\n \"51-200\"\n ]\n }\n}"
response = http.request(request)
puts response.read_body{
"total": 123,
"total_status": "about",
"generated_query": {}
}{
"error": "<string>",
"message": "<string>",
"details": {}
}{
"error": "<string>",
"message": "<string>",
"details": {}
}{
"error": "<string>",
"message": "<string>",
"details": {}
}{
"error": "<string>",
"message": "<string>",
"details": {}
}{
"error": "<string>",
"message": "<string>",
"details": {}
}{
"error": "<string>",
"message": "<string>",
"details": {}
}Send what Company Search takes (
A count is rounded, so adding or removing one record almost never changes it. For an exact total, run the search itself: its
filters, sql or es_query) and get back how many companies it matches, rounded, without any records. A count costs no credits, so you can size a list and work out what it would cost (one credit per record returned) before you search.
{ "filters": { "industry": "software development", "locations.city": "austin" } }
{ "total": 1200, "total_status": "about" }
Reading the Total
total is rounded, and total_status (also the Total-Count-Status response header) says how to read it:
| total_status | Meaning | Say it as |
|---|---|---|
about | The count, rounded: to the nearest 10 under 100, else to two significant figures | ”about 1,200” |
at_least | Counting ran out of time on a very broad search; total is a lower bound | ”1,200 or more” |
under | Fewer than 10 match, possibly none | ”fewer than 10” |
total is exact for selective queries.
A count describes a list, not one record: it refuses (400, free) filters on fields that identify a single company: legion_id, its name, domain, LinkedIn URL and ticker. Whether a field is filled is fine, for example “public companies with a ticker”: "tickers.symbol": {"exists": true}; only a specific value is refused. To look one up, use Company Enrichment.
Sent as filters, the response also carries generated_query, the query object the filters compiled to.
Limits
- Free: no credits are used.
- Works with zero credits left: a count needs an active plan that includes search (a trial counts too), not a balance, so you can size a list before you buy more. An expired plan answers 402; a plan without search, 403.
- 10 counts a minute and 100 an hour per account (5 and 30 on a free trial), for each of person and company. Higher limits are available on request.
- The same field rules as search: a filter on a field outside your plan is refused, and opted-out records are never counted.
- GET works too, with
filters,sqlores_queryas query parameters (filtersandes_queryas JSON text). Prefer POST.
Body
application/json
Request model for a company search's count.
Response
Success - the rounded count of matching companies
How many records a search would match, rounded.