Authentication πŸ—
Understand how to authenticate using your unique API key
​
The Authentication is done via the x-api-key HTTP Header.
For example, if your API key is your_key_1
Python SDK
cURL
Node.js
Go
PHP
Ruby
1
from newscatcherapi import NewsCatcherApiClient
2
​
3
API_KEY = 'your_key_1'
4
​
5
newscatcherapi = NewsCatcherApiClient(x_api_key=API_KEY)
6
​
7
news_articles = newscatcherapi.get_search(q="Tesla")
Copied!
1
curl -XGET 'https://api.newscatcherapi.com/v2/search?q=Tesla' -H 'x-api-key: your_key_1'
Copied!
1
var axios = require("axios").default;
2
​
3
var options = {
4
method: 'GET',
5
url: 'https://api.newscatcherapi.com/v2/search',
6
params: {q: 'Bitcoin', lang: 'en', sort_by: 'relevancy', page: '1'},
7
headers: {
8
'x-api-key': 'your_key_1'
9
}
10
};
11
​
12
axios.request(options).then(function (response) {
13
console.log(response.data);
14
}).catch(function (error) {
15
console.error(error);
16
});
Copied!
1
package main
2
​
3
import (
4
"fmt"
5
"net/http"
6
"io/ioutil"
7
)
8
​
9
func main() {
10
​
11
url := "https://api.newscatcherapi.com/v2/search?q=Tesla&lang=en&sort_by=relevancy&page=1"
12
​
13
req, _ := http.NewRequest("GET", url, nil)
14
​
15
req.Header.Add("x-api-key", "your_key_1")
16
​
17
res, _ := http.DefaultClient.Do(req)
18
​
19
defer res.Body.Close()
20
body, _ := ioutil.ReadAll(res.Body)
21
​
22
fmt.Println(res)
23
fmt.Println(string(body))
24
​
25
}
Copied!
1
<?php
2
​
3
$client = new http\Client;
4
$request = new http\Client\Request;
5
​
6
$request->setRequestUrl('https://api.newscatcherapi.com/v2/search');
7
$request->setRequestMethod('GET');
8
$request->setQuery(new http\QueryString([
9
'q' => 'Google',
10
'lang' => 'en',
11
'sort_by' => 'relevancy',
12
'page' => '1'
13
]));
14
​
15
$request->setHeaders([
16
'x-api-key' => 'your_key_1'
17
]);
18
​
19
$client->enqueue($request)->send();
20
$response = $client->getResponse();
21
​
22
echo $response->getBody();
Copied!
1
require "uri"
2
require "net/http"
3
​
4
url = URI("https://api.newscatcherapi.com/v2/search?q=\"Elon Musk\"&lang=en&countries=US,CA")
5
​
6
https = Net::HTTP.new(url.host, url.port)
7
https.use_ssl = true
8
​
9
request = Net::HTTP::Get.new(url)
10
request["X-API-KEY"] = "enter-your-api-key-here"
11
​
12
response = https.request(request)
13
puts response.read_body
Copied!
Get your API key by registering at app.newscatcherapi.com​
Be mindful of your account type while making calls. Different types have different limits on the total API calls you can make, the number of calls/second, and the publication dates of the articles. Here's a table for quick reference:
Free Trial
Pro
Enterprise
10,000 calls
250,000 calls/mo
custom limits
1 API call/second
5 API calls/second
custom limits
upto 2 week old articles
all available articles
all available articles
You can check your account type in the dashboard​
​
Copy link