Get News Headlines By Keyword Search
Get near real time news articles by searching using a keyword or a keyphrase.
Categories:
This API endpoint is excellent for running queries with multiple keywords or keyphrases.
Fetch near real time news articles by searching using a keyword or keyphrase
Input
import requests
url = "https://specrom-news-api.p.rapidapi.com/"
payload = {
"api_type": "news_by_keyword_search",
"keyword": "Donald Trump"
}
headers = {
"content-type": "application/json",
"X-RapidAPI-Key": "API_key",
"X-RapidAPI-Host": "specrom-news-api.p.rapidapi.com"
}
response = requests.request("POST", url, json=payload, headers=headers)
print(response.text)
POST / HTTP/1.1
Content-Type: application/json
X-Rapidapi-Key: API_key
X-Rapidapi-Host: specrom-news-api.p.rapidapi.com
Host: specrom-news-api.p.rapidapi.com
Content-Length: 96
{
"api_type": "news_by_keyword_search",
"keyword": "Donald Trump"
}
Parameter | Description |
---|---|
api_type | news_by_keyword_search |
country | two digit country code |
keyword | Search using the keyword or keyphrase. In case of a keyphrase containing more than two words (say Donald Trump), the keyphrase searched will be “Donald AND Trump”. |
Output
[
{
"source_url":"",
"source name":"",
"published_date":"2023-04-12T10:01:50Z",
"title":"Trump Leads DeSantis In Our New 2024 Republican Primary Polling Average",
"matched_text":"Donald Trump",
"url_id":"W2KracEB6QSg2AMRzLoV0JlBt5QiEJiIoMNEgq9l7vYR4F5yktDFc32OboItXqVpM80wmoALot3dO1a4YNQWuI/Ip4i2Ez2XIpgXyX1yz5RTuzkfMiNOVA4RAZzso5tMkzucFHXVOjNAECDOswQ0Dv1iqTt8JthEm4asfBCGdlqbxLG8vgkThGMlSfxKFNMdz8CpwbKAvYlnAJE2pXKPei1srKjY9Ce1Q0fKpG9HjEhIm06bsEtEtfBRDm8ApfpQLXhvpP20DNJuRHp+QaUNZqFIW6tbBxKac9YCepD5Ac/EpZAI+Ho3tu8h/JPwKoo8SV2ZkEBQGq6E3gutpF0arOpZN1fkkihSETsV0uCXSA==z0JGhuTDznqBaiJ6cMa0QA==k3ZkWXy8+3HBa/h2NQJI4A=="
},
{
"source_url":"",
"source name":"",
"published_date":"2023-04-17T05:07:24Z",
"title":"Trump news – latest: SNL mocks Trump for claim NYPD ‘cried’ during arrest",
"matched_text":"Donald Trump",
"url_id":"UcP9TICRECQitflcKckLSuPVuVymb1DSxJxLopzwZjfaTlzjvtj0vQIwavE4smL7pEUdjKCxAeIqHOPqUYbAYINA88tUx1cQAzxplf5+bcibNJlG+I7rzqTe/6yuch+mGJejhSdzRwUMAfkzQ1FAO4uyzUueVOmPYa+SAnJA/xR5MPKyoJA45rvWLkrUMKptw4vW6eLKAch7lZX976IFqy6Yt3+7vONHBNdN+1QQIjhN1yzJ9hEkww9QWiIbyCPh4z1hgj82AoMApw96nj5LX1LqqGxa/m1WeMFyi02JTf8g0YxcoFoyL0uFjg42y0Cm5vmaXu9FZYwd/aoCFZHzUUP+VfLeA31g7wGRA7096GKbDbhrQU8Xbu2hwLQAMqQidjM1hcE8ShPysXbiKxStKaRG1X256aTIXGSG3EqrRU6M38uwXdeiZs3rypRed5DjUhtxjSdMdvXihhZJKVWT1zCoUzXRTRvfWwfinkLUDTczUcA75/owNrRDq0EVRdvkjzS4JA==btCc5KU/AkvM/Rb1sPfo7g==J5YrGi3Qg8ZgePxkRBF2sg==vuJWPkwttgAi+hWMLJBcng=="
},
.
.
.
(output truncated)
]
Parameter | Description |
---|---|
source url | web domain of the media outlet |
source name | name of the media outlet |
publishedAt | date of the news article |
title | title of the news article |
matched_text | input keyword |
url_id | unique url_id of the news article. Use our separate endpoint called fetch news article by url_id to fetch complete details such as full_text, author, url etc. of the news article |