Google News API
Google News API uses /api/v1/search?engine=google_news
API endpoint to scrape real-time results.
Google News API offers an automated news aggregation service. It collects headlines from various sources globally, categorizes similar articles and presents them based on each user's interests. The API provides access to multiple links for each news story, allowing users to choose their topic of interest and select from different publishers' versions of the story. The selection and ranking of articles are performed by algorithms that assess factors such as the frequency and location of online appearance. It also prioritizes attributes like timeliness, relevance, diversity, and location. The system is impartial, enabling access to a wide range of perspectives for any story. Google is continuously improving News by adding new sources and enhancing its technology, extending its reach to more regions worldwide.
API Parameters
Search Query
-
- Name
-
q
- Required
- Required
- Description
-
Parameter defines the query you want to search. You can use anything that you would use in a regular Google search. e.g.
inurl:
,site:
,intitle:
. We also support advanced search query parameters such asas_dt
andas_eq
.
Device
-
- Name
-
device
- Required
- Optional
- Description
-
The default parameter
desktop
defines the search on a desktop device. Themobile
parameter defines the search on a mobile device. Thetablet
parameter defines the search on a tablet device.
Geographic Location
-
- Name
-
location
- Required
- Optional
- Description
-
Parameter defines from where you want the search to originate. If several locations match the location requested, we'll pick the most popular one. Head to the Locations API if you need more precise control.
-
- Name
-
uule
- Required
- Optional
- Description
-
Parameter is the Google encoded location you want to use for the search. SearchApi automatically generated the
uule
parameter when you use thelocation
parameter but we allow you to overwrite it directly.uule
andlocation
parameters can't be used together.
Localization
-
- Name
-
google_domain
- Required
- Optional
- Description
-
The default parameter
google.com
defines the Google domain of the search. Check the full list of supported Googlegoogle_domain
domains.
-
- Name
-
gl
- Required
- Optional
- Description
-
The default parameter
us
defines the country of the search. Check the full list of supported Googlegl
countries.
-
- Name
-
hl
- Required
- Optional
- Description
-
The default parameter
en
defines the interface language of the search. Check the full list of supported Googlehl
languages.
-
- Name
-
lr
- Required
- Optional
- Description
-
The lr parameter restricts search results to documents written in a particular language or a set of languages. The accepted format for this parameter is
lang_{2-letter country code}
. For instance, to filter documents written in Japanese, the value should be set tolang_jp
. To incorporate multiple languages, a value likelang_it|lang_de
restricts the search to documents written in either Italian or German. Google identifies the document language based on the top-level domain (TLD) of the document's URL, any language meta tags present, or the language utilized within the document's body text. Check the full list of supported Googlelr
languages.
-
- Name
-
cr
- Required
- Optional
- Description
-
The cr parameter restricts search results to documents originating in a particular country. Google determines the country of a document by the top-level domain (TLD) of the document's URL or by Web server's IP address geographic location. Check the full list of supported Google
cr
countries.
Filters
-
- Name
-
time_period
- Required
- Optional
- Description
-
This parameter restricts results to URLs based on date. Supported values are:
last_hour
- data from the past hour.last_day
- data from the past 24 hours.last_week
- data from the past week.last_month
- data from the past month.last_year
- data from the past year.- Using
time_period_min
ortime_period_max
parameters, you can specify a custom time period.
time_period_min
andtime_period_max
parameters could be used separately as well.
-
- Name
-
time_period_min
- Required
- Optional
- Description
-
This parameter specifies the start of the time period. It could be used in combination with the
time_period_max
parameter. The value should be in the formatMM/DD/YYYY
.
-
- Name
-
time_period_max
- Required
- Optional
- Description
-
This parameter specifies the end of the time period. It could be used in combination with the
time_period_min
parameter. The value should be in the formatMM/DD/YYYY
.
-
- Name
-
sort_by
- Required
- Optional
- Description
-
By default, news results are sorted by relevance. To get the most recent articles, set it to
most_recent
.
-
- Name
-
nfpr
- Required
- Optional
- Description
-
This parameter controls whether results from queries that have been auto-corrected for spelling errors are included. To exclude these auto-corrected results, set the value to
1
. By default, the value is0
, meaning auto-corrected results are included.
-
- Name
-
filter
- Required
- Optional
- Description
-
This parameter controls whether the "Duplicate Content" and "Host Crowding" filters are enabled. Set the value to
1
to enable these filters, which is the default setting. To disable these filters, set the value to0
.
-
- Name
-
safe
- Required
- Optional
- Description
-
This parameter toggles the SafeSearch feature for the results. SafeSearch operates by filtering out adult content from your search results. Google's filters use proprietary technology to check keywords, phrases and URLs. While no filters are 100 percent accurate, SafeSearch will remove the overwhelming majority of adult content from your search results. Set the value to
active
to enable SafeSearch. To disable it, set the value tooff
. By default, SafeSearch is disabled.
Pagination
-
- Name
-
num
- Required
- Optional
- Description
-
This parameter specifies the number of results to display per page. Use in combination with the
page
parameter to implement pagination functionality.
-
- Name
-
page
- Required
- Optional
- Description
-
This parameter indicates which page of results to return. By default, it is set to
1
. Use in combination with the num parameter to implement pagination.
Engine
-
- Name
-
engine
- Required
- Required
- Description
-
Parameter defines an engine that will be used to retrieve real-time data. It must be set to
google_news
.
API key
-
- Name
-
api_key
- Required
- Required
- Description
-
The
api_key
authenticates your requests. Use it as a query parameter (https://www.searchapi.io/api/v1/search?api_key=YOUR_API_KEY
) or in the Authorization header (Bearer YOUR_API_KEY
).
API Examples
Full Response
https://www.searchapi.io/api/v1/search?engine=google_news&location=New+York%2CUnited+States&q=Jeff+Bezos+news
- Python
- Node
- Ruby
- Java
- Go
- PHP
- Bash
- R
- Kotlin
- Swift
- C#
- C
- C++
- requests
import requests
url = "https://www.searchapi.io/api/v1/search"
params = {
"engine": "google_news",
"q": "Jeff Bezos news",
"location": "New York,United States"
}
response = requests.get(url, params=params)
print(response.text)
{
"search_metadata": {
"id": "search_KQrlGNWjgNE7ub7GpZVeALdm",
"status": "Success",
"created_at": "2023-06-15T12:00:53Z",
"request_time_taken": 1.45,
"parsing_time_taken": 0.03,
"total_time_taken": 1.48,
"request_url": "https://www.google.com/search?q=Jeff+Bezos+news&oq=Jeff+Bezos+news&gl=us&hl=en&uule=w+CAIQICIWTmV3IFlvcmssVW5pdGVkIFN0YXRlcw&tbm=nws&ie=UTF-8",
"html_url": "https://www.searchapi.io/api/v1/searches/search_KQrlGNWjgNE7ub7GpZVeALdm.html",
"json_url": "https://www.searchapi.io/api/v1/searches/search_KQrlGNWjgNE7ub7GpZVeALdm"
},
"search_parameters": {
"engine": "google",
"q": "Jeff Bezos news",
"location": "New York",
"location_used": "New York,United States",
"google_domain": "google.com",
"hl": "en",
"gl": "us"
},
"search_information": {
"query_displayed": "Jeff Bezos news",
"total_results": 14400,
"time_taken_displayed": 0.35,
"detected_location": "New York"
},
"organic_results": [
{
"position": 1,
"title": "Larry Ellison Overtakes Jeff Bezos As World’s Third-Richest Person",
"link": "https://www.forbes.com/sites/dereksaul/2023/06/14/larry-ellison-overtakes-jeff-bezos-as-worlds-third-richest-person/",
"source": "Forbes",
"date": "19 hours ago",
"snippet": "The Oracle boss and GOP megadonor Ellison now trails just his friend Elon Musk on the list of richest Americans.",
"favicon": "data:image/png;base64,...",
"thumbnail": "data:image/jpeg;base64,..."
},
...
],
"top_stories": [
{
"title": "Jeff Bezos and Lauren Sánchez Enjoy a Walk In Portofino",
"link": "https://people.com/jeff-bezos-and-lauren-sanchez-go-for-walk-in-portofino-7515121",
"source": "People",
"date": "1 day ago",
"thumbnail": "data:image/jpeg;base64,..."
},
...
],
"top_stories_more_link": {
"link": "https://www.google.com/search?gl=us&hl=en&q=Jeff+Bezos+news&ie=UTF-8&tbm=nws&oq=Jeff+Bezos+news&uule=w+CAIQICIWTmV3IFlvcmssVW5pdGVkIFN0YXRlcw&story=GiYSJEplZmYgQmV6b3MgYW5kIExhdXJlbiBTYW5jaGV6IHBob3RvczIxCif4gJuGvvGDnsMB_5v5mYPQmt08n8jdroHJuPzJAdeS5Pycj7W2qAEQn6WB7wcYBVgC&fcs=AGY3Bfsod9t7KXSk4CwIx9PtWPdnlSruIg&sa=X&ved=2ahUKEwi0oreQncX_AhW1EVkFHXsJBzAQ7IUHegQIGhAF"
},
"pagination": {
"current": 1,
"next": "https://www.google.com/search?q=Jeff+Bezos+news&sca_esv=574427856&hl=en&gl=us&tbm=nws&ei=dccvZfOSNc-u0PEPwfesEA&start=10&sa=N&ved=2ahUKEwizoZnqxP-BAxVPFzQIHcE7CwIQ8NMDegQIBBAW",
"other_pages": {
"2": "https://www.google.com/search?q=Jeff+Bezos+news&sca_esv=574427856&hl=en&gl=us&tbm=nws&ei=dccvZfOSNc-u0PEPwfesEA&start=10&sa=N&ved=2ahUKEwizoZnqxP-BAxVPFzQIHcE7CwIQ8tMDegQIBBAE",
...
}
}
}