Get trends with /v1/news/trends
Use /v1/news/trends to find the most common entities, categories, topics, industries or sources in the news. Choose a field to get its values with article counts and percentages. You can also request growth rates and comparisons with a previous period.
Each request costs 1 point. Using the prompt parameter adds 2 points for the translation step; prompt requires Basic or above.
A test key returns the usual format and numbers, including count, percentage and growth_rate. Each entry's value is replaced with [Upgrade subscription plan]. Use a test key to build response handling, then switch to a live key to see the rankings.
Endpoint
GET /v1/news/trends
POST /v1/news/trendsBase URL: https://api.apitube.io. You must send field. Other parameters filter the articles or change how results are grouped.
Fields you can aggregate
field | Aggregates by |
|---|---|
entity.id | People, organizations, brands, locations |
category.id | IPTC Media Topics categories |
topic.id | Topics |
industry.id | Industries |
source.id | Publishers |
Up to 5 fields per request, comma-separated. One field returns a flat trends array; several return trends keyed by field name.
Trend values include details about the field you chose. For example, an entity.id result includes the entity's name, type and wikidata_id.
Trending analysis and period comparison
You can add more detail to the counts:
trending=1addsgrowth_rateandtrending_scorefor the lasttrending_daysdays (default 14, maximum 30). Use them to find subjects gaining attention, even if their total article count is still low.compare=1adds the previous period of the same length and achangevalue. With comparison on,sort=changeandsort=trending_scorebecome available.
Use time_bucket to group each value's counts by hour, day, week or month. Use percentile to keep only values above a chosen percentile: for example, 90 keeps the top 10%.
Parameters
Prompt
Describe the news you want in plain language. The API chooses the filters.
| Parameter | Type | Required | Description |
|---|---|---|---|
prompt | string | No | Describe the news to analyse in plain language. You must still send field separately. A new translation costs 2 extra points. Requires Basic or above; Free and Starter return 403 ER0706. Range: 3–500 characters. |
Find articles Described in Plain Language
Find recent English-language articles about Tesla and Elon Musk using a plain-language request.
curl "https://api.apitube.io/v1/news/trends?field=entity.id&prompt=Tesla%20and%20Elon%20Musk%20news%20in%20English%20for%20the%20last%2010%20days&api_key=YOUR_API_KEY"
import requests
response = requests.get(
"https://api.apitube.io/v1/news/trends",
params={
"field": "entity.id",
"prompt": "Tesla%20and%20Elon%20Musk%20news%20in%20English%20for%20the%20last%2010%20days",
"api_key": "YOUR_API_KEY",
},
)
print(response.json())
const params = new URLSearchParams({ "field": "entity.id", "prompt": "Tesla%20and%20Elon%20Musk%20news%20in%20English%20for%20the%20last%2010%20days", "api_key": "YOUR_API_KEY" });
const response = await fetch(`https://api.apitube.io/v1/news/trends?${params}`);
const data = await response.json();
console.log(data);
$query = http_build_query(["field" => "entity.id", "prompt" => "Tesla%20and%20Elon%20Musk%20news%20in%20English%20for%20the%20last%2010%20days", "api_key" => "YOUR_API_KEY"]);
$response = file_get_contents("https://api.apitube.io/v1/news/trends?$query");
$data = json_decode($response, true);
print_r($data);
package main
import (
"encoding/json"
"fmt"
"io"
"net/http"
"net/url"
)
func main() {
u, _ := url.Parse("https://api.apitube.io/v1/news/trends")
q := u.Query()
q.Set("field", "entity.id")
q.Set("prompt", "Tesla%20and%20Elon%20Musk%20news%20in%20English%20for%20the%20last%2010%20days")
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)
}
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/trends?field=entity.id&prompt=Tesla%20and%20Elon%20Musk%20news%20in%20English%20for%20the%20last%2010%20days&api_key=YOUR_API_KEY"))
.GET()
.build();
HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
}
}
Write a script in your preferred language that calls the APITube News API:
GET https://api.apitube.io/v1/news/trends?field=entity.id&prompt=Tesla%20and%20Elon%20Musk%20news%20in%20English%20for%20the%20last%2010%20days
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/trends
Date and time
| Parameter | Type | Required | Description |
|---|---|---|---|
published_at | string | No | Exact date (creates 24-hour range). Format: YYYY-MM-DD or ISO 8601. Example: 2025-01-15. |
published_at.end | string | No | End of date range. Format: YYYY-MM-DD or ISO 8601. Combined with a title search the range may not exceed 31 days (ER0110). Example: 2025-01-31. |
published_at.start | string | No | Start of date range. Format: YYYY-MM-DD or ISO 8601. Combined with a title search the range may not exceed 31 days (ER0110). Example: 2025-01-01. |
Find articles within a specific date range
curl "https://api.apitube.io/v1/news/trends?field=entity.id&published_at.start=2022-01-01&published_at.end=2022-01-31&api_key=YOUR_API_KEY"
import requests
response = requests.get(
"https://api.apitube.io/v1/news/trends",
params={
"field": "entity.id",
"published_at.start": "2022-01-01",
"published_at.end": "2022-01-31",
"api_key": "YOUR_API_KEY",
},
)
print(response.json())
const params = new URLSearchParams({ "field": "entity.id", "published_at.start": "2022-01-01", "published_at.end": "2022-01-31", "api_key": "YOUR_API_KEY" });
const response = await fetch(`https://api.apitube.io/v1/news/trends?${params}`);
const data = await response.json();
console.log(data);
$query = http_build_query(["field" => "entity.id", "published_at.start" => "2022-01-01", "published_at.end" => "2022-01-31", "api_key" => "YOUR_API_KEY"]);
$response = file_get_contents("https://api.apitube.io/v1/news/trends?$query");
$data = json_decode($response, true);
print_r($data);
package main
import (
"encoding/json"
"fmt"
"io"
"net/http"
"net/url"
)
func main() {
u, _ := url.Parse("https://api.apitube.io/v1/news/trends")
q := u.Query()
q.Set("field", "entity.id")
q.Set("published_at.start", "2022-01-01")
q.Set("published_at.end", "2022-01-31")
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)
}
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/trends?field=entity.id&published_at.start=2022-01-01&published_at.end=2022-01-31&api_key=YOUR_API_KEY"))
.GET()
.build();
HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
}
}
Write a script in your preferred language that calls the APITube News API:
GET https://api.apitube.io/v1/news/trends?field=entity.id&published_at.start=2022-01-01&published_at.end=2022-01-31
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/trends
Find news using a relative time range
curl "https://api.apitube.io/v1/news/trends?field=entity.id&published_at.start=NOW-7DAYS&published_at.end=NOW&api_key=YOUR_API_KEY"
import requests
response = requests.get(
"https://api.apitube.io/v1/news/trends",
params={
"field": "entity.id",
"published_at.start": "NOW-7DAYS",
"published_at.end": "NOW",
"api_key": "YOUR_API_KEY",
},
)
print(response.json())
const params = new URLSearchParams({ "field": "entity.id", "published_at.start": "NOW-7DAYS", "published_at.end": "NOW", "api_key": "YOUR_API_KEY" });
const response = await fetch(`https://api.apitube.io/v1/news/trends?${params}`);
const data = await response.json();
console.log(data);
$query = http_build_query(["field" => "entity.id", "published_at.start" => "NOW-7DAYS", "published_at.end" => "NOW", "api_key" => "YOUR_API_KEY"]);
$response = file_get_contents("https://api.apitube.io/v1/news/trends?$query");
$data = json_decode($response, true);
print_r($data);
package main
import (
"encoding/json"
"fmt"
"io"
"net/http"
"net/url"
)
func main() {
u, _ := url.Parse("https://api.apitube.io/v1/news/trends")
q := u.Query()
q.Set("field", "entity.id")
q.Set("published_at.start", "NOW-7DAYS")
q.Set("published_at.end", "NOW")
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)
}
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/trends?field=entity.id&published_at.start=NOW-7DAYS&published_at.end=NOW&api_key=YOUR_API_KEY"))
.GET()
.build();
HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
}
}
Write a script in your preferred language that calls the APITube News API:
GET https://api.apitube.io/v1/news/trends?field=entity.id&published_at.start=NOW-7DAYS&published_at.end=NOW
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/trends
Languages
| Parameter | Type | Required | Description |
|---|---|---|---|
ignore.language.code | string | No | Exclude articles in these languages (comma-separated, max 3). Example: zh,ar. |
language.code | string | No | Comma-separated ISO 639-1 language codes (max 3). Example: en. |
Exclude French articles and publishers in France
curl "https://api.apitube.io/v1/news/trends?field=entity.id&ignore.source.country.code=fr&ignore.language.code=fr&api_key=YOUR_API_KEY"
import requests
response = requests.get(
"https://api.apitube.io/v1/news/trends",
params={
"field": "entity.id",
"ignore.source.country.code": "fr",
"ignore.language.code": "fr",
"api_key": "YOUR_API_KEY",
},
)
print(response.json())
const params = new URLSearchParams({ "field": "entity.id", "ignore.source.country.code": "fr", "ignore.language.code": "fr", "api_key": "YOUR_API_KEY" });
const response = await fetch(`https://api.apitube.io/v1/news/trends?${params}`);
const data = await response.json();
console.log(data);
$query = http_build_query(["field" => "entity.id", "ignore.source.country.code" => "fr", "ignore.language.code" => "fr", "api_key" => "YOUR_API_KEY"]);
$response = file_get_contents("https://api.apitube.io/v1/news/trends?$query");
$data = json_decode($response, true);
print_r($data);
package main
import (
"encoding/json"
"fmt"
"io"
"net/http"
"net/url"
)
func main() {
u, _ := url.Parse("https://api.apitube.io/v1/news/trends")
q := u.Query()
q.Set("field", "entity.id")
q.Set("ignore.source.country.code", "fr")
q.Set("ignore.language.code", "fr")
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)
}
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/trends?field=entity.id&ignore.source.country.code=fr&ignore.language.code=fr&api_key=YOUR_API_KEY"))
.GET()
.build();
HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
}
}
Write a script in your preferred language that calls the APITube News API:
GET https://api.apitube.io/v1/news/trends?field=entity.id&ignore.source.country.code=fr&ignore.language.code=fr
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/trends
Find articles in the English and French languages
curl "https://api.apitube.io/v1/news/trends?field=entity.id&language.code=en,fr&api_key=YOUR_API_KEY"
import requests
response = requests.get(
"https://api.apitube.io/v1/news/trends",
params={
"field": "entity.id",
"language.code": "en,fr",
"api_key": "YOUR_API_KEY",
},
)
print(response.json())
const params = new URLSearchParams({ "field": "entity.id", "language.code": "en,fr", "api_key": "YOUR_API_KEY" });
const response = await fetch(`https://api.apitube.io/v1/news/trends?${params}`);
const data = await response.json();
console.log(data);
$query = http_build_query(["field" => "entity.id", "language.code" => "en,fr", "api_key" => "YOUR_API_KEY"]);
$response = file_get_contents("https://api.apitube.io/v1/news/trends?$query");
$data = json_decode($response, true);
print_r($data);
package main
import (
"encoding/json"
"fmt"
"io"
"net/http"
"net/url"
)
func main() {
u, _ := url.Parse("https://api.apitube.io/v1/news/trends")
q := u.Query()
q.Set("field", "entity.id")
q.Set("language.code", "en,fr")
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)
}
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/trends?field=entity.id&language.code=en,fr&api_key=YOUR_API_KEY"))
.GET()
.build();
HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
}
}
Write a script in your preferred language that calls the APITube News API:
GET https://api.apitube.io/v1/news/trends?field=entity.id&language.code=en,fr
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/trends
Find business news in one language
curl "https://api.apitube.io/v1/news/trends?field=entity.id&language.code=zh,ko&category.id=medtop:04000000&api_key=YOUR_API_KEY"
import requests
response = requests.get(
"https://api.apitube.io/v1/news/trends",
params={
"field": "entity.id",
"language.code": "zh,ko",
"category.id": "medtop:04000000",
"api_key": "YOUR_API_KEY",
},
)
print(response.json())
const params = new URLSearchParams({ "field": "entity.id", "language.code": "zh,ko", "category.id": "medtop:04000000", "api_key": "YOUR_API_KEY" });
const response = await fetch(`https://api.apitube.io/v1/news/trends?${params}`);
const data = await response.json();
console.log(data);
$query = http_build_query(["field" => "entity.id", "language.code" => "zh,ko", "category.id" => "medtop:04000000", "api_key" => "YOUR_API_KEY"]);
$response = file_get_contents("https://api.apitube.io/v1/news/trends?$query");
$data = json_decode($response, true);
print_r($data);
package main
import (
"encoding/json"
"fmt"
"io"
"net/http"
"net/url"
)
func main() {
u, _ := url.Parse("https://api.apitube.io/v1/news/trends")
q := u.Query()
q.Set("field", "entity.id")
q.Set("language.code", "zh,ko")
q.Set("category.id", "medtop:04000000")
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)
}
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/trends?field=entity.id&language.code=zh,ko&category.id=medtop:04000000&api_key=YOUR_API_KEY"))
.GET()
.build();
HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
}
}
Write a script in your preferred language that calls the APITube News API:
GET https://api.apitube.io/v1/news/trends?field=entity.id&language.code=zh,ko&category.id=medtop:04000000
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/trends
Source
| Parameter | Type | Required | Description |
|---|---|---|---|
ignore.source.bias | string | No | Exclude publishers with these political biases, separated by commas. Values: left, center, right. Example: right. |
ignore.source.country.code | string | No | Exclude sources from these countries (comma-separated, max 3). Example: us. |
ignore.source.domain | string | No | Exclude these source domains (comma-separated, max 3). |
ignore.source.id | string | No | Exclude these source IDs (comma-separated, max 3). |
source.bias | string | No | Filter by publishers' political bias, separated by commas. Values: left, center, right. Example: left. |
source.country.code | string | No | Filter by source country ISO 3166-1 alpha-2 codes (comma-separated, max 3). Example: us. |
source.domain | string | No | Comma-separated source domains (max 3). Example: nytimes.com. |
source.id | string | No | Comma-separated source IDs (max 3). Example: 100. |
source.rank.opr.max | integer | No | Maximum Open PageRank score. Range: min 0. |
source.rank.opr.min | integer | No | Minimum Open PageRank score. Range: min 0. |
Find articles from a specific source (e.g., "theguardian.com")
curl "https://api.apitube.io/v1/news/trends?field=entity.id&source.domain=theguardian.com&api_key=YOUR_API_KEY"
import requests
response = requests.get(
"https://api.apitube.io/v1/news/trends",
params={
"field": "entity.id",
"source.domain": "theguardian.com",
"api_key": "YOUR_API_KEY",
},
)
print(response.json())
const params = new URLSearchParams({ "field": "entity.id", "source.domain": "theguardian.com", "api_key": "YOUR_API_KEY" });
const response = await fetch(`https://api.apitube.io/v1/news/trends?${params}`);
const data = await response.json();
console.log(data);
$query = http_build_query(["field" => "entity.id", "source.domain" => "theguardian.com", "api_key" => "YOUR_API_KEY"]);
$response = file_get_contents("https://api.apitube.io/v1/news/trends?$query");
$data = json_decode($response, true);
print_r($data);
package main
import (
"encoding/json"
"fmt"
"io"
"net/http"
"net/url"
)
func main() {
u, _ := url.Parse("https://api.apitube.io/v1/news/trends")
q := u.Query()
q.Set("field", "entity.id")
q.Set("source.domain", "theguardian.com")
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)
}
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/trends?field=entity.id&source.domain=theguardian.com&api_key=YOUR_API_KEY"))
.GET()
.build();
HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
}
}
Write a script in your preferred language that calls the APITube News API:
GET https://api.apitube.io/v1/news/trends?field=entity.id&source.domain=theguardian.com
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/trends
Find articles from multiple sources (e.g., "theguardian.com" and "nytimes.com")
curl "https://api.apitube.io/v1/news/trends?field=entity.id&source.domain=theguardian.com,nytimes.com&api_key=YOUR_API_KEY"
import requests
response = requests.get(
"https://api.apitube.io/v1/news/trends",
params={
"field": "entity.id",
"source.domain": "theguardian.com,nytimes.com",
"api_key": "YOUR_API_KEY",
},
)
print(response.json())
const params = new URLSearchParams({ "field": "entity.id", "source.domain": "theguardian.com,nytimes.com", "api_key": "YOUR_API_KEY" });
const response = await fetch(`https://api.apitube.io/v1/news/trends?${params}`);
const data = await response.json();
console.log(data);
$query = http_build_query(["field" => "entity.id", "source.domain" => "theguardian.com,nytimes.com", "api_key" => "YOUR_API_KEY"]);
$response = file_get_contents("https://api.apitube.io/v1/news/trends?$query");
$data = json_decode($response, true);
print_r($data);
package main
import (
"encoding/json"
"fmt"
"io"
"net/http"
"net/url"
)
func main() {
u, _ := url.Parse("https://api.apitube.io/v1/news/trends")
q := u.Query()
q.Set("field", "entity.id")
q.Set("source.domain", "theguardian.com,nytimes.com")
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)
}
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/trends?field=entity.id&source.domain=theguardian.com,nytimes.com&api_key=YOUR_API_KEY"))
.GET()
.build();
HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
}
}
Write a script in your preferred language that calls the APITube News API:
GET https://api.apitube.io/v1/news/trends?field=entity.id&source.domain=theguardian.com,nytimes.com
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/trends
Choose a source and language
curl "https://api.apitube.io/v1/news/trends?field=entity.id&source.domain=theguardian.com&language.code=en&api_key=YOUR_API_KEY"
import requests
response = requests.get(
"https://api.apitube.io/v1/news/trends",
params={
"field": "entity.id",
"source.domain": "theguardian.com",
"language.code": "en",
"api_key": "YOUR_API_KEY",
},
)
print(response.json())
const params = new URLSearchParams({ "field": "entity.id", "source.domain": "theguardian.com", "language.code": "en", "api_key": "YOUR_API_KEY" });
const response = await fetch(`https://api.apitube.io/v1/news/trends?${params}`);
const data = await response.json();
console.log(data);
$query = http_build_query(["field" => "entity.id", "source.domain" => "theguardian.com", "language.code" => "en", "api_key" => "YOUR_API_KEY"]);
$response = file_get_contents("https://api.apitube.io/v1/news/trends?$query");
$data = json_decode($response, true);
print_r($data);
package main
import (
"encoding/json"
"fmt"
"io"
"net/http"
"net/url"
)
func main() {
u, _ := url.Parse("https://api.apitube.io/v1/news/trends")
q := u.Query()
q.Set("field", "entity.id")
q.Set("source.domain", "theguardian.com")
q.Set("language.code", "en")
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)
}
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/trends?field=entity.id&source.domain=theguardian.com&language.code=en&api_key=YOUR_API_KEY"))
.GET()
.build();
HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
}
}
Write a script in your preferred language that calls the APITube News API:
GET https://api.apitube.io/v1/news/trends?field=entity.id&source.domain=theguardian.com&language.code=en
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/trends
Find articles with rank between 0.5 and 0.9
curl "https://api.apitube.io/v1/news/trends?field=entity.id&source.rank.opr.min=5&source.rank.opr.max=9&api_key=YOUR_API_KEY"
import requests
response = requests.get(
"https://api.apitube.io/v1/news/trends",
params={
"field": "entity.id",
"source.rank.opr.min": "5",
"source.rank.opr.max": "9",
"api_key": "YOUR_API_KEY",
},
)
print(response.json())
const params = new URLSearchParams({ "field": "entity.id", "source.rank.opr.min": "5", "source.rank.opr.max": "9", "api_key": "YOUR_API_KEY" });
const response = await fetch(`https://api.apitube.io/v1/news/trends?${params}`);
const data = await response.json();
console.log(data);
$query = http_build_query(["field" => "entity.id", "source.rank.opr.min" => "5", "source.rank.opr.max" => "9", "api_key" => "YOUR_API_KEY"]);
$response = file_get_contents("https://api.apitube.io/v1/news/trends?$query");
$data = json_decode($response, true);
print_r($data);
package main
import (
"encoding/json"
"fmt"
"io"
"net/http"
"net/url"
)
func main() {
u, _ := url.Parse("https://api.apitube.io/v1/news/trends")
q := u.Query()
q.Set("field", "entity.id")
q.Set("source.rank.opr.min", "5")
q.Set("source.rank.opr.max", "9")
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)
}
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/trends?field=entity.id&source.rank.opr.min=5&source.rank.opr.max=9&api_key=YOUR_API_KEY"))
.GET()
.build();
HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
}
}
Write a script in your preferred language that calls the APITube News API:
GET https://api.apitube.io/v1/news/trends?field=entity.id&source.rank.opr.min=5&source.rank.opr.max=9
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/trends
Categories
| Parameter | Type | Required | Description |
|---|---|---|---|
category.id | string | No | Category IDs, separated by commas (max 3). Use IPTC Media Topic IDs such as medtop:04000000. Example: medtop:04000000. |
ignore.category.id | string | No | Exclude these categories (comma-separated, max 3). |
Find articles from a specific category (e.g., "Sport")
Find articles in the "sport" category.
curl "https://api.apitube.io/v1/news/trends?field=entity.id&category.id=medtop:15000000&api_key=YOUR_API_KEY"
import requests
response = requests.get(
"https://api.apitube.io/v1/news/trends",
params={
"field": "entity.id",
"category.id": "medtop:15000000",
"api_key": "YOUR_API_KEY",
},
)
print(response.json())
const params = new URLSearchParams({ "field": "entity.id", "category.id": "medtop:15000000", "api_key": "YOUR_API_KEY" });
const response = await fetch(`https://api.apitube.io/v1/news/trends?${params}`);
const data = await response.json();
console.log(data);
$query = http_build_query(["field" => "entity.id", "category.id" => "medtop:15000000", "api_key" => "YOUR_API_KEY"]);
$response = file_get_contents("https://api.apitube.io/v1/news/trends?$query");
$data = json_decode($response, true);
print_r($data);
package main
import (
"encoding/json"
"fmt"
"io"
"net/http"
"net/url"
)
func main() {
u, _ := url.Parse("https://api.apitube.io/v1/news/trends")
q := u.Query()
q.Set("field", "entity.id")
q.Set("category.id", "medtop:15000000")
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)
}
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/trends?field=entity.id&category.id=medtop:15000000&api_key=YOUR_API_KEY"))
.GET()
.build();
HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
}
}
Write a script in your preferred language that calls the APITube News API:
GET https://api.apitube.io/v1/news/trends?field=entity.id&category.id=medtop:15000000
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/trends
Find articles in the Finance Category
Find articles in the "finance" category.
curl "https://api.apitube.io/v1/news/trends?field=entity.id&category.id=medtop:04000000&api_key=YOUR_API_KEY"
import requests
response = requests.get(
"https://api.apitube.io/v1/news/trends",
params={
"field": "entity.id",
"category.id": "medtop:04000000",
"api_key": "YOUR_API_KEY",
},
)
print(response.json())
const params = new URLSearchParams({ "field": "entity.id", "category.id": "medtop:04000000", "api_key": "YOUR_API_KEY" });
const response = await fetch(`https://api.apitube.io/v1/news/trends?${params}`);
const data = await response.json();
console.log(data);
$query = http_build_query(["field" => "entity.id", "category.id" => "medtop:04000000", "api_key" => "YOUR_API_KEY"]);
$response = file_get_contents("https://api.apitube.io/v1/news/trends?$query");
$data = json_decode($response, true);
print_r($data);
package main
import (
"encoding/json"
"fmt"
"io"
"net/http"
"net/url"
)
func main() {
u, _ := url.Parse("https://api.apitube.io/v1/news/trends")
q := u.Query()
q.Set("field", "entity.id")
q.Set("category.id", "medtop:04000000")
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)
}
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/trends?field=entity.id&category.id=medtop:04000000&api_key=YOUR_API_KEY"))
.GET()
.build();
HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
}
}
Write a script in your preferred language that calls the APITube News API:
GET https://api.apitube.io/v1/news/trends?field=entity.id&category.id=medtop:04000000
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/trends
Choose a category and language
Find articles in the "politics" category that are in French.
curl "https://api.apitube.io/v1/news/trends?field=entity.id&category.id=medtop:11000000&language.code=fr&api_key=YOUR_API_KEY"
import requests
response = requests.get(
"https://api.apitube.io/v1/news/trends",
params={
"field": "entity.id",
"category.id": "medtop:11000000",
"language.code": "fr",
"api_key": "YOUR_API_KEY",
},
)
print(response.json())
const params = new URLSearchParams({ "field": "entity.id", "category.id": "medtop:11000000", "language.code": "fr", "api_key": "YOUR_API_KEY" });
const response = await fetch(`https://api.apitube.io/v1/news/trends?${params}`);
const data = await response.json();
console.log(data);
$query = http_build_query(["field" => "entity.id", "category.id" => "medtop:11000000", "language.code" => "fr", "api_key" => "YOUR_API_KEY"]);
$response = file_get_contents("https://api.apitube.io/v1/news/trends?$query");
$data = json_decode($response, true);
print_r($data);
package main
import (
"encoding/json"
"fmt"
"io"
"net/http"
"net/url"
)
func main() {
u, _ := url.Parse("https://api.apitube.io/v1/news/trends")
q := u.Query()
q.Set("field", "entity.id")
q.Set("category.id", "medtop:11000000")
q.Set("language.code", "fr")
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)
}
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/trends?field=entity.id&category.id=medtop:11000000&language.code=fr&api_key=YOUR_API_KEY"))
.GET()
.build();
HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
}
}
Write a script in your preferred language that calls the APITube News API:
GET https://api.apitube.io/v1/news/trends?field=entity.id&category.id=medtop:11000000&language.code=fr
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/trends
Topics
| Parameter | Type | Required | Description |
|---|---|---|---|
ignore.topic.id | string | No | Exclude these topics (comma-separated, max 3). |
topic.id | string | No | Topic IDs, separated by commas (max 3). Find IDs with /v1/suggest/topics, for example industry.technology_news. Example: industry.technology_news. |
Find articles from a specific topic (e.g., "crypto_news")
Find articles in the "crypto news" topic.
curl "https://api.apitube.io/v1/news/trends?field=entity.id&topic.id=industry.crypto_news&api_key=YOUR_API_KEY"
import requests
response = requests.get(
"https://api.apitube.io/v1/news/trends",
params={
"field": "entity.id",
"topic.id": "industry.crypto_news",
"api_key": "YOUR_API_KEY",
},
)
print(response.json())
const params = new URLSearchParams({ "field": "entity.id", "topic.id": "industry.crypto_news", "api_key": "YOUR_API_KEY" });
const response = await fetch(`https://api.apitube.io/v1/news/trends?${params}`);
const data = await response.json();
console.log(data);
$query = http_build_query(["field" => "entity.id", "topic.id" => "industry.crypto_news", "api_key" => "YOUR_API_KEY"]);
$response = file_get_contents("https://api.apitube.io/v1/news/trends?$query");
$data = json_decode($response, true);
print_r($data);
package main
import (
"encoding/json"
"fmt"
"io"
"net/http"
"net/url"
)
func main() {
u, _ := url.Parse("https://api.apitube.io/v1/news/trends")
q := u.Query()
q.Set("field", "entity.id")
q.Set("topic.id", "industry.crypto_news")
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)
}
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/trends?field=entity.id&topic.id=industry.crypto_news&api_key=YOUR_API_KEY"))
.GET()
.build();
HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
}
}
Write a script in your preferred language that calls the APITube News API:
GET https://api.apitube.io/v1/news/trends?field=entity.id&topic.id=industry.crypto_news
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/trends
Industries
| Parameter | Type | Required | Description |
|---|---|---|---|
ignore.industry.id | string | No | Exclude these industries (comma-separated, max 3). |
industry.id | string | No | Comma-separated industry IDs (max 3). Example: 1. |
Entities, people, organizations, brands
| Parameter | Type | Required | Description |
|---|---|---|---|
entity.id | string | No | Comma-separated entity IDs (max 3). Example: 12345. |
ignore.entity.id | string | No | Exclude these entity IDs (comma-separated, max 3). |
Find articles about a specific entity (e.g., "Brad Pitt")
curl "https://api.apitube.io/v1/news/trends?field=entity.id&entity.id=1278268&api_key=YOUR_API_KEY"
import requests
response = requests.get(
"https://api.apitube.io/v1/news/trends",
params={
"field": "entity.id",
"entity.id": "1278268",
"api_key": "YOUR_API_KEY",
},
)
print(response.json())
const params = new URLSearchParams({ "field": "entity.id", "entity.id": "1278268", "api_key": "YOUR_API_KEY" });
const response = await fetch(`https://api.apitube.io/v1/news/trends?${params}`);
const data = await response.json();
console.log(data);
$query = http_build_query(["field" => "entity.id", "entity.id" => "1278268", "api_key" => "YOUR_API_KEY"]);
$response = file_get_contents("https://api.apitube.io/v1/news/trends?$query");
$data = json_decode($response, true);
print_r($data);
package main
import (
"encoding/json"
"fmt"
"io"
"net/http"
"net/url"
)
func main() {
u, _ := url.Parse("https://api.apitube.io/v1/news/trends")
q := u.Query()
q.Set("field", "entity.id")
q.Set("entity.id", "1278268")
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)
}
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/trends?field=entity.id&entity.id=1278268&api_key=YOUR_API_KEY"))
.GET()
.build();
HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
}
}
Write a script in your preferred language that calls the APITube News API:
GET https://api.apitube.io/v1/news/trends?field=entity.id&entity.id=1278268
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/trends
Find articles about multiple entities (e.g., "Brad Pitt" and "Angelina Jolie")
curl "https://api.apitube.io/v1/news/trends?field=entity.id&entity.id=1278268,1282301&api_key=YOUR_API_KEY"
import requests
response = requests.get(
"https://api.apitube.io/v1/news/trends",
params={
"field": "entity.id",
"entity.id": "1278268,1282301",
"api_key": "YOUR_API_KEY",
},
)
print(response.json())
const params = new URLSearchParams({ "field": "entity.id", "entity.id": "1278268,1282301", "api_key": "YOUR_API_KEY" });
const response = await fetch(`https://api.apitube.io/v1/news/trends?${params}`);
const data = await response.json();
console.log(data);
$query = http_build_query(["field" => "entity.id", "entity.id" => "1278268,1282301", "api_key" => "YOUR_API_KEY"]);
$response = file_get_contents("https://api.apitube.io/v1/news/trends?$query");
$data = json_decode($response, true);
print_r($data);
package main
import (
"encoding/json"
"fmt"
"io"
"net/http"
"net/url"
)
func main() {
u, _ := url.Parse("https://api.apitube.io/v1/news/trends")
q := u.Query()
q.Set("field", "entity.id")
q.Set("entity.id", "1278268,1282301")
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)
}
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/trends?field=entity.id&entity.id=1278268,1282301&api_key=YOUR_API_KEY"))
.GET()
.build();
HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
}
}
Write a script in your preferred language that calls the APITube News API:
GET https://api.apitube.io/v1/news/trends?field=entity.id&entity.id=1278268,1282301
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/trends
Find articles about an entity while ignoring another
curl "https://api.apitube.io/v1/news/trends?field=entity.id&entity.id=1278268&ignore.entity.id=315&api_key=YOUR_API_KEY"
import requests
response = requests.get(
"https://api.apitube.io/v1/news/trends",
params={
"field": "entity.id",
"entity.id": "1278268",
"ignore.entity.id": "315",
"api_key": "YOUR_API_KEY",
},
)
print(response.json())
const params = new URLSearchParams({ "field": "entity.id", "entity.id": "1278268", "ignore.entity.id": "315", "api_key": "YOUR_API_KEY" });
const response = await fetch(`https://api.apitube.io/v1/news/trends?${params}`);
const data = await response.json();
console.log(data);
$query = http_build_query(["field" => "entity.id", "entity.id" => "1278268", "ignore.entity.id" => "315", "api_key" => "YOUR_API_KEY"]);
$response = file_get_contents("https://api.apitube.io/v1/news/trends?$query");
$data = json_decode($response, true);
print_r($data);
package main
import (
"encoding/json"
"fmt"
"io"
"net/http"
"net/url"
)
func main() {
u, _ := url.Parse("https://api.apitube.io/v1/news/trends")
q := u.Query()
q.Set("field", "entity.id")
q.Set("entity.id", "1278268")
q.Set("ignore.entity.id", "315")
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)
}
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/trends?field=entity.id&entity.id=1278268&ignore.entity.id=315&api_key=YOUR_API_KEY"))
.GET()
.build();
HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
}
}
Write a script in your preferred language that calls the APITube News API:
GET https://api.apitube.io/v1/news/trends?field=entity.id&entity.id=1278268&ignore.entity.id=315
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/trends
Sentiment
| Parameter | Type | Required | Description |
|---|---|---|---|
entity.sentiment.polarity | string | No | Filter by the tone of coverage about an entity. Choose the entity with entity.id, person.name, organization.name, location.name, brand.name, event.name, disease.name, disaster.name or sport.name. Without one of these fields, the API returns 400 ER0293. One of: positive, negative, neutral. |
entity.sentiment.score.max | number | No | Maximum sentiment score toward the entity. Range: -1–1. |
entity.sentiment.score.min | number | No | Minimum sentiment score toward the entity. Range: -1–1. |
Article flags
| Parameter | Type | Required | Description |
|---|---|---|---|
is_breaking | boolean | No | Filter breaking news articles. |
is_duplicate | boolean | No | Filter duplicate/unique articles. |
Follow breaking news only
curl "https://api.apitube.io/v1/news/trends?field=entity.id&is_breaking=1&api_key=YOUR_API_KEY"
import requests
response = requests.get(
"https://api.apitube.io/v1/news/trends",
params={
"field": "entity.id",
"is_breaking": "1",
"api_key": "YOUR_API_KEY",
},
)
print(response.json())
const params = new URLSearchParams({ "field": "entity.id", "is_breaking": "1", "api_key": "YOUR_API_KEY" });
const response = await fetch(`https://api.apitube.io/v1/news/trends?${params}`);
const data = await response.json();
console.log(data);
$query = http_build_query(["field" => "entity.id", "is_breaking" => "1", "api_key" => "YOUR_API_KEY"]);
$response = file_get_contents("https://api.apitube.io/v1/news/trends?$query");
$data = json_decode($response, true);
print_r($data);
package main
import (
"encoding/json"
"fmt"
"io"
"net/http"
"net/url"
)
func main() {
u, _ := url.Parse("https://api.apitube.io/v1/news/trends")
q := u.Query()
q.Set("field", "entity.id")
q.Set("is_breaking", "1")
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)
}
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/trends?field=entity.id&is_breaking=1&api_key=YOUR_API_KEY"))
.GET()
.build();
HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
}
}
Write a script in your preferred language that calls the APITube News API:
GET https://api.apitube.io/v1/news/trends?field=entity.id&is_breaking=1
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/trends
Trends aggregation
| Parameter | Type | Required | Description |
|---|---|---|---|
compare | string | No | Enable period comparison. One of: 0, 1. |
compare_window | string | No | Period to compare against, required when compare=1. Examples: 24HOURS, 7DAYS, 1WEEK, 1w, 2m. |
field | string | Yes | Fields to count by, separated by commas (max 5). Required. One of: source.id, category.id, topic.id, industry.id, entity.id. |
mincount | integer | No | Minimum article count for a value to be included. Range: 1–10000. Default: 1. |
percentile | integer | No | Filter results above this percentile. Range: 1–100. |
time_bucket | string | No | Group counts by hour, day, week or month. One of: hour, day, week, month. |
trending | string | No | Enable trending analysis with growth rate calculation. One of: 0, 1. |
trending_days | integer | No | Number of days to include in trend analysis. Range: 7–30. Default: 14. |
Sorting
| Parameter | Type | Required | Description |
|---|---|---|---|
order | string | No | Sort order. One of: asc, desc. Default: desc. |
sort | string | No | Sort field (change and trending_score require compare=1). One of: count, value, growth_rate, change, trending_score. Default: count. |
Pagination
| Parameter | Type | Required | Description |
|---|---|---|---|
offset | integer | No | Offset for pagination. Range: min 0. Default: 0. |
per_page | integer | No | Number of results per field. Range: 1–100. Default: 10. |
Use the parameters listed here for supported behaviour. Other filters from /v1/news/everything may work, but they can change without an OpenAPI update and may be missing from generated SDKs.
Response format
{
"status": "ok",
"field": "entity.id",
"per_page": 10,
"offset": 0,
"total_count": 1500,
"total_articles": 45000,
"sort": "count",
"order": "desc",
"mincount": 1,
"trends": [
{
"value": { "id": 1034399, "name": "Germany", "type_id": 2, "wikidata_id": "Q183" },
"count": 523,
"percentage": 1.16,
"growth_rate": 2.5
}
],
"request_id": "a1b2c3d4-e5f6-7g8h-9i0j-k1l2m3n4o5p6"
}When you request several fields, trends contains a separate object for each field. Each object has its own total_count and total_articles. See both response formats in API Response Structure.
total_articles adds up the counts for all values of a field. An article with three categories contributes three to this total when you request field=category.id. Each value's percentage is its share of that total. Percentages add up to 100% within a field; compare them only within that field. Use /v1/news/count for the number of unique matching articles.
Request examples
curl "https://api.apitube.io/v1/news/trends?field=entity.id&per_page=10&language.code=en&api_key=YOUR_API_KEY"
import requests
response = requests.get(
"https://api.apitube.io/v1/news/trends",
params={"field": "entity.id", "per_page": 10, "language.code": "en"},
headers={"X-API-Key": "YOUR_API_KEY"},
)
for trend in response.json()["trends"]:
print(trend["value"]["name"], trend["count"], trend.get("growth_rate"))
const params = new URLSearchParams({
field: 'entity.id',
per_page: '10',
'language.code': 'en'
});
const response = await fetch(`https://api.apitube.io/v1/news/trends?${params}`, {
headers: { 'X-API-Key': 'YOUR_API_KEY' }
});
const data = await response.json();
console.table(data.trends.map(t => ({ name: t.value.name, count: t.count })));
$query = http_build_query([
'field' => 'entity.id',
'per_page' => 10,
'language.code' => 'en',
'api_key' => 'YOUR_API_KEY',
]);
$data = json_decode(file_get_contents("https://api.apitube.io/v1/news/trends?$query"), true);
foreach ($data['trends'] as $trend) {
echo $trend['value']['name'], ': ', $trend['count'], PHP_EOL;
}
What is rising fastest, not just what is biggest
curl "https://api.apitube.io/v1/news/trends?field=entity.id&trending=1&trending_days=7&sort=trending_score&api_key=YOUR_API_KEY"This week against last week
curl "https://api.apitube.io/v1/news/trends?field=topic.id&compare=1&compare_window=7&sort=change&api_key=YOUR_API_KEY"Two fields at once, as a daily series
curl "https://api.apitube.io/v1/news/trends?field=entity.id,category.id&time_bucket=day&api_key=YOUR_API_KEY"Errors
| Code | Status | Meaning |
|---|---|---|
ER0350 | 400 | field missing or not one of the five allowed values |
ER0175 | 401 | API key is missing or invalid |
ER0176 | 402 | No points left on the account |
ER0203 | 429 | Rate limit exceeded |
See HTTP response codes for the full error list.
Related
- Count articles — one number instead of a ranking.
- Faceting — aggregate inside a normal search response.
- Search articles — fetch the articles behind a trend.