Count API

An Overview of what the Count API offers within Datastreamer

The Count API returns the number of documents that match a query, without returning the documents themselves. It supports internal data sources and rejects external data sources. Use it to size a result set before paging through it.

📘

Requires Searchable Storage

The Count API is an API offering of Searchable Storage, and requires Searchable Storage in your pipeline.

Endpoint Details

EndpointTypeDescriptionStatus
https://api.platform.datastreamer.io/api/countPOSTCentral endpoint for the Count API, which returns the total count of results for the provided parameters.Live

Send your API key in the apikey header.

Request Object Details

A sample request looks like:

curl --request POST \
  --url https://api.platform.datastreamer.io/api/count \
  --header 'apikey: <API_KEY>' \
  --header 'content-type: application/json' \
  --data '{
  "query": {
    "query": "coffee",
    "data_sources": [
      "twitter_auto"
    ]
  }
}'

API Reference: Count

Data Sources and Query are used within the JSON request body to filter out the results as per the requirements. Apache Lucene based syntax is used to write the queries within the query parameter of the request body. The format and content of the query is the same as the Search API format.

Response Details

Based on the data_sources provided in the request body as well as the query; the response of the Count API is the total number of documents available at the sources provided. The individual results are not provided by the Count API endpoint.

{
    "total": {
        "value": 267252
    }
}

total.value is the number of matching documents. The response may also include total.relation; do not require that field when parsing Count responses.

The Count endpoint can return HTTP 429 when its per-key rate limit is reached. Its current error body contains error and a string status value of "429".


Did this page help you?