Get articles with faceting for analytics

Use faceting to get aggregated counts grouped by fields for analytics dashboards

Eingabeparameter

ParameterDescriptionTypeDefaultRequired
facetEnable faceting (set to true or 1).booleanYes
facet.fieldComma-separated list of fields to facet on.stringYes
facet.limitMaximum number of facet values per field.integer10No
api_keyYour API key.stringYes
per_pageMaximum number of articles to retrieve.integer20No

Workflow examples

Request with basic faceting by source:
curl -X GET "https://api.apitube.io/v1/news/everything?facet=true&facet.field=source.id&api_key=YOUR_API_KEY"
Request with multiple facet fields:
curl -X GET "https://api.apitube.io/v1/news/everything?facet=true&facet.field=source.id,language.id,sentiment.overall.polarity&api_key=YOUR_API_KEY"
Request for sentiment analysis by source:
curl -X GET "https://api.apitube.io/v1/news/everything?category.id=medtop:04000000&facet=true&facet.field=source.id,sentiment.overall.polarity&facet.limit=10&api_key=YOUR_API_KEY"

Rezept für cURL

curl --location --globoff --request POST 'https://api.apitube.io/v1/news/everything?facet=1&facet.field=source.id%2Csentiment.overall.polarity&api_key=YOUR_API_KEY&per_page=10' \
--header 'Content-Type: application/json'

Rezept für Python

import requests

url = "https://api.apitube.io/v1/news/everything"

querystring = {
    "facet": true,
    "facet.field": "source.id,sentiment.overall.polarity",
    "api_key": "YOUR_API_KEY",
    "per_page": 10
}
response = requests.request("GET", url, params=querystring)

print(response.text)

Rezept für Javascript

import axios from "axios"

const options = {
		method: 'GET',
		url: 'https://api.apitube.io/v1/news/everything',
		params: {
    "facet": true,
    "facet.field": "source.id,sentiment.overall.polarity",
    "api_key": "YOUR_API_KEY",
    "per_page": 10
}};

axios.request(options).then(function (response) {
		console.log(response.data);
}).catch(function (error) {
		console.error(error);
});

Rezept für PHP

require 'vendor/autoload.php';

use GuzzleHttp\Client;

$client = new Client();
$response = $client->request('GET', 'https://api.apitube.io/v1/news/everything', [
	'query' => [
    'facet' => 1,
    'facet.field' => 'source.id,sentiment.overall.polarity',
    'api_key' => 'YOUR_API_KEY',
    'per_page' => 10,
],
]);

echo $response->getBody();

Rezept für Java

OkHttpClient client = new OkHttpClient().newBuilder().build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "");
Request request = new Request.Builder()
		.url("https://api.apitube.io/v1/news/everything?facet=1&facet.field=source.id%2Csentiment.overall.polarity&api_key=YOUR_API_KEY&per_page=10")
		.method("POST", body)
		.addHeader("Content-Type", "application/json")
		.build();
Response response = client.newCall(request).execute();
		
  • CNN
  • Techcrunch
  • Vox
  • Apple
  • Microsoft
  • IBM
  • Bloomberg
  • Spotify