curl --request GET \
--url https://api.clair.im/v1/news \
--header 'Authorization: Bearer <token>'import requests
url = "https://api.clair.im/v1/news"
headers = {"Authorization": "Bearer <token>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {Authorization: 'Bearer <token>'}};
fetch('https://api.clair.im/v1/news', 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.clair.im/v1/news",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.clair.im/v1/news"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("Authorization", "Bearer <token>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://api.clair.im/v1/news")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.clair.im/v1/news")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["Authorization"] = 'Bearer <token>'
response = http.request(request)
puts response.read_body{
"query": "\"central bank\" OR inflation -sports",
"language": "en",
"sort_by": "published_at",
"count": 50,
"items": [
{
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"title": "<string>",
"url": "<string>",
"source": {
"name": "<string>"
},
"description": "<string>",
"image_url": "<string>",
"authors": [
"<string>"
],
"language": "en",
"category": "general",
"published_at": "2023-11-07T05:31:56Z",
"collected_at": "2023-11-07T05:31:56Z",
"content": "<string>",
"content_available": true,
"content_truncated": true,
"is_update": true,
"relevance_score": 0.5
}
],
"next_cursor": "<string>"
}{
"error": "bad_cursor",
"detail": "cursor is invalid or belongs to a different search"
}{
"error": "bad_cursor",
"detail": "cursor is invalid or belongs to a different search"
}{
"error": "bad_cursor",
"detail": "cursor is invalid or belongs to a different search"
}{
"error": "bad_cursor",
"detail": "cursor is invalid or belongs to a different search"
}{
"error": "bad_cursor",
"detail": "cursor is invalid or belongs to a different search"
}Search the News API
News API search endpoint: keyword-first search and newest-first corpus walks with source, time, revision, sort, and cursor controls. GET /v1/news.
curl --request GET \
--url https://api.clair.im/v1/news \
--header 'Authorization: Bearer <token>'import requests
url = "https://api.clair.im/v1/news"
headers = {"Authorization": "Bearer <token>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {Authorization: 'Bearer <token>'}};
fetch('https://api.clair.im/v1/news', 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.clair.im/v1/news",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.clair.im/v1/news"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("Authorization", "Bearer <token>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://api.clair.im/v1/news")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.clair.im/v1/news")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["Authorization"] = 'Bearer <token>'
response = http.request(request)
puts response.read_body{
"query": "\"central bank\" OR inflation -sports",
"language": "en",
"sort_by": "published_at",
"count": 50,
"items": [
{
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"title": "<string>",
"url": "<string>",
"source": {
"name": "<string>"
},
"description": "<string>",
"image_url": "<string>",
"authors": [
"<string>"
],
"language": "en",
"category": "general",
"published_at": "2023-11-07T05:31:56Z",
"collected_at": "2023-11-07T05:31:56Z",
"content": "<string>",
"content_available": true,
"content_truncated": true,
"is_update": true,
"relevance_score": 0.5
}
],
"next_cursor": "<string>"
}{
"error": "bad_cursor",
"detail": "cursor is invalid or belongs to a different search"
}{
"error": "bad_cursor",
"detail": "cursor is invalid or belongs to a different search"
}{
"error": "bad_cursor",
"detail": "cursor is invalid or belongs to a different search"
}{
"error": "bad_cursor",
"detail": "cursor is invalid or belongs to a different search"
}{
"error": "bad_cursor",
"detail": "cursor is invalid or belongs to a different search"
}Authorizations
Clair dashboard key. Create keys at https://clair.im/dashboard/api-keys.
Query Parameters
Keyword query. Supports quoted phrases, uppercase OR, and minus-prefixed exclusions. Analyzed as English; a stopword-only query returns empty_query. For non-English slices prefer omitting q.
1 - 300Comma-separated exact names from GET /v1/sources, at most 50. Mutually exclusive with exclude_sources.
1 - 5000Comma-separated exact names from GET /v1/sources, at most 50. Mutually exclusive with sources.
1 - 5000Inclusive RFC 3339 lower bound on publisher time.
Inclusive RFC 3339 upper bound on publisher time. Must be later than or equal to from.
Result ordering. Relevance sorting requires q.
published_at, relevance Deterministic publisher-section category. Event facets such as elections, crime, conflict, and disasters are queried through q, not represented as mutually exclusive categories.
general, world, politics, business, technology, science, health, sports, entertainment, environment ISO 639-1 primary language code, or all. Defaults to en so existing clients keep an English feed.
2 - 16"en"
Include later revisions that share a publisher URL. The default returns only canonical records.
true, 1, yes, false, 0, no Maximum items in this page.
1 <= x <= 100Opaque next_cursor from the preceding page. Reuse it only with the exact query, filters, sort, and revision mode that created it.
1 - 1024Response
A page of news items.
The supplied query, or null for a chronological corpus walk.
"\"central bank\" OR inflation -sports"
The language filter applied to this page. en when omitted, or all.
"en"
published_at, relevance Number of items in this page.
0 <= x <= 100Show child attributes
Show child attributes
Opaque continuation token, or null when this traversal is complete.