Query Google News articles by keyword and get structured JSON back (title, original article link, source outlet, publication time) — useful for news monitoring, digests, or giving an AI agent the latest coverage. For web search, see the Google Search API page.
Authorization: Bearer YOUR_API_KEY header with your developer key (an X-Dev-Key header is also accepted), or a logged-in web session; never place keys in URL query strings (they end up in server logs).GET only, with every parameter in the query string.GET https://www.myai168.com/en/api/google/news| Parameter | Required | Default | Description |
|---|---|---|---|
q | Required | — | Search keywords (string); news search operators are allowed (see the next question). URL-encode it when it contains spaces, non-ASCII text or symbols. |
hl | Optional | en (by site language) | Language of the news, e.g. en / zh-TW / ja. |
gl | Optional | US (by site language) | Regional edition (country code, case-insensitive), e.g. US / TW / JP. |
ceid | Optional | Derived from gl and hl | Google News edition code in "country:language" form (e.g. US:en, TW:zh-Hant). You normally leave it out; use it only for a special edition. |
num | Optional | 10 | Number of results, 1–20; out-of-range values are clamped and non-numeric values fall back to the default. |
When hl, gl or ceid fails format validation the default is used instead (no error); the values that took effect are echoed in the response.
curl -G "https://www.myai168.com/en/api/google/news" \
-H "Authorization: Bearer YOUR_API_KEY" \
--data-urlencode "q=TSMC" \
-d "hl=en" \
-d "gl=us" \
-d "num=5"
import requests
r = requests.get(
"https://www.myai168.com/en/api/google/news",
headers={"Authorization": "Bearer YOUR_API_KEY"},
params={"q": "TSMC", "hl": "en", "gl": "us", "num": 5},
timeout=180,
)
r.raise_for_status()
data = r.json()
for item in data["results"]:
print(item["date"], item["source"], item["title"], item["link"])
print("cost:", data["cost"], "credits:", data["credits"])
Node.js 18+ has fetch built in; save the file as .mjs.
const params = new URLSearchParams({ q: "TSMC", hl: "en", gl: "us", num: "5" });
const res = await fetch("https://www.myai168.com/en/api/google/news?" + params, {
headers: { Authorization: "Bearer YOUR_API_KEY" },
});
const data = await res.json();
if (!res.ok) throw new Error(data.error);
for (const item of data.results) console.log(item.date, item.source, item.title, item.link);
console.log("cost:", data.cost, "credits:", data.credits);
Resolving the original article URLs is done article by article, so a large num can take more than a minute; use a generous timeout (180 seconds in the example) or a smaller num.
The content of q is passed to Google News as is, so these operators narrow a search:
| Operator | Effect | Example (content of q) |
|---|---|---|
when: | Only recent coverage: when:1h one hour, when:1d one day, when:7d seven days. | semiconductor when:1d |
after: / before: | A date range (YYYY-MM-DD). | semiconductor after:2026-09-01 before:2026-09-30 |
site: | Only a given news site. | semiconductor site:reuters.com |
intitle: | The headline must contain the word. | intitle:semiconductor |
"..." | Match the exact phrase. | "advanced packaging" |
OR / - | Match either term / exclude a term. | TSMC OR Intel -stock |
curl -G "https://www.myai168.com/en/api/google/news" \
-H "Authorization: Bearer YOUR_API_KEY" \
--data-urlencode "q=semiconductor when:1d" \
-d "num=10"
curl -G "https://www.myai168.com/en/api/google/news" \
-H "Authorization: Bearer YOUR_API_KEY" \
--data-urlencode "q=semiconductor site:reuters.com" \
-d "hl=en" -d "gl=US"
Passing hl and gl is enough; ceid is derived as shown:
| Edition | hl | gl | Derived ceid |
|---|---|---|---|
| Taiwan (Traditional Chinese) | zh-TW | TW | TW:zh-Hant |
| Hong Kong (Traditional Chinese) | zh-HK | HK | HK:zh-Hant |
| United States (English) | en | US | US:en |
| Japan (Japanese) | ja | JP | JP:ja |
| China (Simplified Chinese) | zh-CN | CN | CN:zh-Hans |
when:1d and de-duplicate by link, so you do not keep receiving the same old articles.num: the response is faster and uses fewer credits.Success is HTTP 200 with a JSON object; the response headers also carry X-Cost-Points (credits charged) and X-Credits-Remaining (balance after the charge). Results keep the order Google News returned them in.
{
"q": "TSMC",
"hl": "en",
"gl": "US",
"ceid": "US:en",
"num": 5,
"count": 5,
"results": [
{"title": "...", "link": "https://example.com/news/123", "source": "Example News", "date": "Thu, 01 Oct 2026 08:30:00 GMT"}
],
"cost": 12,
"credits": 12345
}
| Field | Description |
|---|---|
q / hl / gl / ceid / num | The query parameters that took effect (gl is always upper-cased). |
count | Number of items in results. |
results[].title | Headline (with the trailing " - source" removed). |
results[].link | The original article URL; when it cannot be resolved, the Google News redirect link (starting with https://news.google.com/). |
results[].source | Name of the source outlet. |
results[].date | Publication time in RFC 822 format (GMT), e.g. Thu, 01 Oct 2026 08:30:00 GMT; in Python parse it with email.utils.parsedate_to_datetime. |
cost | Credits charged for this call (the number in the example is illustrative). |
credits | Balance after the charge. |
You are charged only when results come back, and the charge grows with the number of results returned; an empty search returns HTTP 200 with count 0 and cost 0. Errors are never charged.
On errors the body is JSON with an error string field, for example:
{"error": "News search failed. Please try again later.", "q": "...", "cost": 0, "credits": 12345}
| HTTP status | Meaning |
|---|---|
400 | The q parameter is missing. |
401 | Missing or invalid key (repeated failures from the same IP are temporarily blocked), or the key has reached its credit limit (API key credit limit reached!). |
402 | Insufficient credits (You need to top up!); the search is not run. |
404 | The external API is not enabled on this site. |
405 | A method other than GET was used. |
500 | The search service is not fully configured; contact the site administrator. |
502 | The news search failed temporarily — never charged; the response also carries q, cost: 0 and credits. |