Skip to content

Count Articles

The /v1/news/count endpoint returns only the number of articles matching your filters, without loading any article content. It accepts the same filters as /v1/news/everything, but runs a single count(*) query — much cheaper and faster when all you need is the total. It is useful for dashboards, sample-size estimation, and progress bars.

To use the API, you'll require an API key. You can obtain an API key by signing up for an account on the APITube website.

Endpoint

GET  /v1/news/count
POST /v1/news/count

Both methods are equivalent: filters can be passed as query parameters (GET) or as a JSON body (POST). The endpoint accepts the same filters as /v1/news/everything — see the Parameters reference and the Interactive Query Builder for the full list.

Query Parameters

The endpoint supports every filter available on /v1/news/everything. Some commonly used ones:

ParameterTypeRequiredDescription
titlestringNoFull-text search in article titles. Supports phrase search with proximity.
language.codestringNoFilter by language (ISO 639-1), e.g. en.
category.idstringNoFilter by category id.
source.idintegerNoFilter by source id.
published_at.startstringNoStart of period (ISO 8601 or YYYY-MM-DD).
published_at.endstringNoEnd of period (ISO 8601 or YYYY-MM-DD).
api_keystringYes*Your API key. Can also be provided via headers.

* Required if not provided in headers

Each request costs 1 point.

Response Format

json
{
  "status": "ok",
  "count": 0,
  "request_id": "string"
}

Response Fields

FieldTypeDescription
statusstringAlways ok on success.
countintegerNumber of articles matching the filters.
request_idstringUnique identifier for the request.

Request Examples

GET with query filters

bash
curl "https://api.apitube.io/v1/news/count?language.code=en&category.id=medtop:20000199&api_key=YOUR_API_KEY"
python
import requests

resp = requests.get(
    "https://api.apitube.io/v1/news/count",
    params={"language.code": "en", "category.id": "medtop:20000199", "api_key": "YOUR_API_KEY"},
)
print(resp.json())
javascript
const params = new URLSearchParams({
  "language.code": "en",
  "category.id": "medtop:20000199",
  api_key: "YOUR_API_KEY",
});
const resp = await fetch(`https://api.apitube.io/v1/news/count?${params}`);
console.log(await resp.json());
php
$query = http_build_query([
    "language.code" => "en",
    "category.id" => "medtop:20000199",
    "api_key" => "YOUR_API_KEY",
]);
$data = json_decode(file_get_contents("https://api.apitube.io/v1/news/count?$query"), true);
print_r($data);
go
package main

import (
	"encoding/json"
	"fmt"
	"io"
	"net/http"
	"net/url"
)

func main() {
	u, _ := url.Parse("https://api.apitube.io/v1/news/count")
	q := u.Query()
	q.Set("language.code", "en")
	q.Set("category.id", "medtop:20000199")
	q.Set("api_key", "YOUR_API_KEY")
	u.RawQuery = q.Encode()

	resp, _ := http.Get(u.String())
	defer resp.Body.Close()

	body, _ := io.ReadAll(resp.Body)
	var data map[string]any
	json.Unmarshal(body, &data)
	fmt.Println(data)
}
java
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;

public class Example {
    public static void main(String[] args) throws Exception {
        HttpClient client = HttpClient.newHttpClient();
        HttpRequest request = HttpRequest.newBuilder()
            .uri(URI.create("https://api.apitube.io/v1/news/count?language.code=en&category.id=medtop%3A20000199&api_key=YOUR_API_KEY"))
            .GET()
            .build();
        HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
        System.out.println(response.body());
    }
}
text
Write a script in your preferred language that calls the APITube News API:

GET https://api.apitube.io/v1/news/count?language.code=en&category.id=medtop:20000199

Read the API key from an environment variable (do not hardcode it), handle request
errors, and print the key fields of each result.
Docs: https://docs.apitube.io/platform/news-api/parameters

POST with JSON body

bash
curl -X POST "https://api.apitube.io/v1/news/count" \
  -H "X-API-Key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "title": "climate change",
    "language.code": "en",
    "published_at.start": "2026-01-01"
  }'
python
import requests

resp = requests.post(
    "https://api.apitube.io/v1/news/count",
    headers={"X-API-Key": "YOUR_API_KEY"},
    json={"title": "climate change", "language.code": "en", "published_at.start": "2026-01-01"},
)
print(resp.json())
javascript
const resp = await fetch("https://api.apitube.io/v1/news/count", {
  method: "POST",
  headers: { "X-API-Key": "YOUR_API_KEY", "Content-Type": "application/json" },
  body: JSON.stringify({
    title: "climate change",
    "language.code": "en",
    "published_at.start": "2026-01-01",
  }),
});
console.log(await resp.json());
php
$ch = curl_init("https://api.apitube.io/v1/news/count");
curl_setopt_array($ch, [
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_POST => true,
    CURLOPT_HTTPHEADER => ["X-API-Key: YOUR_API_KEY", "Content-Type: application/json"],
    CURLOPT_POSTFIELDS => json_encode([
        "title" => "climate change",
        "language.code" => "en",
        "published_at.start" => "2026-01-01",
    ]),
]);
$data = json_decode(curl_exec($ch), true);
print_r($data);
go
package main

import (
	"bytes"
	"encoding/json"
	"fmt"
	"io"
	"net/http"
)

func main() {
	payload, _ := json.Marshal(map[string]any{
		"title": "climate change",
		"language.code": "en",
		"published_at.start": "2026-01-01",
	})

	req, _ := http.NewRequest("POST", "https://api.apitube.io/v1/news/count", bytes.NewBuffer(payload))
	req.Header.Set("X-API-Key", "YOUR_API_KEY")
	req.Header.Set("Content-Type", "application/json")

	resp, _ := http.DefaultClient.Do(req)
	defer resp.Body.Close()

	body, _ := io.ReadAll(resp.Body)
	var data map[string]any
	json.Unmarshal(body, &data)
	fmt.Println(data)
}
java
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;

public class Example {
    public static void main(String[] args) throws Exception {
        String payload = "{\"title\": \"climate change\", \"language.code\": \"en\", \"published_at.start\": \"2026-01-01\"}";
        HttpClient client = HttpClient.newHttpClient();
        HttpRequest request = HttpRequest.newBuilder()
            .uri(URI.create("https://api.apitube.io/v1/news/count"))
            .header("X-API-Key", "YOUR_API_KEY")
            .header("Content-Type", "application/json")
            .POST(HttpRequest.BodyPublishers.ofString(payload))
            .build();
        HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
        System.out.println(response.body());
    }
}
text
Write a script in your preferred language that calls the APITube News API:

POST https://api.apitube.io/v1/news/count
Body (JSON):
{
    "title": "climate change",
    "language.code": "en",
    "published_at.start": "2026-01-01"
  }

Read the API key from an environment variable (do not hardcode it), handle request
errors, and print the key fields of each result.
Docs: https://docs.apitube.io/platform/news-api/parameters

Using Bearer token

shell
curl -H "Authorization: Bearer YOUR_API_KEY" \
  "https://api.apitube.io/v1/news/count?source.id=1024"

Response Example

json
{
  "status": "ok",
  "count": 12345,
  "request_id": "req_abc123def456"
}

Error Responses

Invalid or Missing API Key

json
{
  "status": "not_ok",
  "request_id": "req_abc123def456",
  "errors": [
    {
      "status": 401,
      "code": "ER0175",
      "message": "API key is invalid or missing.",
      "links": { "about": "https://docs.apitube.io/platform/news-api/http-response-codes" },
      "timestamp": "2026-05-24T14:30:00Z"
    }
  ]
}

Status Code: 401

No Points on Account

json
{
  "status": "not_ok",
  "request_id": "req_abc123def456",
  "errors": [
    {
      "status": 402,
      "code": "ER0176",
      "message": "You have no points on your account.",
      "links": { "about": "https://docs.apitube.io/platform/news-api/http-response-codes" },
      "timestamp": "2026-05-24T14:30:00Z"
    }
  ]
}

Status Code: 402

Rate Limit Exceeded

json
{
  "status": "not_ok",
  "request_id": "req_abc123def456",
  "errors": [
    {
      "status": 429,
      "code": "ER0203",
      "message": "Rate limit exceeded.",
      "links": { "about": "https://docs.apitube.io/platform/news-api/http-response-codes" },
      "timestamp": "2026-05-24T14:30:00Z"
    }
  ]
}

Status Code: 429