GuidesNEWS
Free news API without an API key
Prefix https://proxy.cors.dev/ to a publisher RSS feed and you have a free news API: no key, no signup, 600 requests per minute, feeds up to 6 MiB. Most news feeds send no Access-Control-Allow-Origin header, so fetch() from your page fails with a CORS error. The 27 feeds below, from the BBC, The Guardian, Al Jazeera, Sky News, NPR and others, were checked through the proxy with item counts and sizes; 24 need it and 3 work without it.
Why news APIs break in the browser
News API services and news feeds fail in a browser for different reasons. NewsAPI.org's free Developer plan allows 100 requests per day, delays articles by 24 hours and enables CORS for localhost only, so an app that works on your machine breaks once it is deployed; paid plans start at $449 per month. Keyed services also put the key in your page, where anyone can copy it.
Publisher RSS feeds need no key and update throughout the day; the BBC feeds set a ttl of 15 minutes. Most of them send no CORS header, so the browser hides the response from your script. Through cors.dev the request runs on a server and the feed comes back with Access-Control-Allow-Origin set to your origin.
Merge several feeds into one headline list
This fetches three feeds in parallel, keeps whatever loads if one fails, and sorts the items by date. It reads title, link, pubDate and the Media RSS thumbnail that many of these feeds include.
// Markup: <ul id="headlines"></ul>
const feeds = {
BBC: 'https://feeds.bbci.co.uk/news/world/rss.xml',
'Al Jazeera': 'https://www.aljazeera.com/xml/rss/all.xml',
'The Guardian': 'https://www.theguardian.com/world/rss',
};
const MEDIA = 'http://search.yahoo.com/mrss/';
async function readFeed(source, url) {
const response = await fetch('https://proxy.cors.dev/' + url, { credentials: 'omit' });
if (!response.ok) {
throw new Error(`${source}: ${response.headers.get('X-Cors-Error') ?? response.status}`);
}
const xml = new DOMParser().parseFromString(await response.text(), 'application/xml');
if (xml.querySelector('parsererror')) throw new Error(`${source}: not valid XML`);
return [...xml.querySelectorAll('item')].map((item) => {
const media =
item.getElementsByTagNameNS(MEDIA, 'thumbnail')[0] ?? item.getElementsByTagNameNS(MEDIA, 'content')[0];
return {
source,
title: item.querySelector('title')?.textContent.trim() ?? '',
link: item.querySelector('link')?.textContent.trim() ?? '',
date: new Date(item.querySelector('pubDate')?.textContent ?? 0),
image: media?.getAttribute('url') ?? null,
};
});
}
async function headlines(limit = 20) {
const results = await Promise.allSettled(Object.entries(feeds).map(([source, url]) => readFeed(source, url)));
for (const result of results) {
if (result.status === 'rejected') console.warn(result.reason);
}
return results
.flatMap((result) => (result.status === 'fulfilled' ? result.value : []))
.sort((a, b) => b.date - a.date)
.slice(0, limit);
}
const list = document.querySelector('#headlines');
headlines().then((items) => {
list.replaceChildren(
...items.map((item) => {
const entry = document.createElement('li');
const link = document.createElement('a');
if (/^https?:/.test(item.link)) link.href = item.link;
link.textContent = item.title;
const time = item.date.toLocaleTimeString([], { hour: '2-digit', minute: '2-digit' });
entry.append(link, ` (${item.source}, ${time})`);
return entry;
}),
);
});Write text with textContent and only accept http and https links, since feed content comes from a third party. For Atom feeds, more fields and safe rendering in detail, see fetch an RSS feed in JavaScript.
News feeds that work from the browser
Each feed was fetched through https://proxy.cors.dev/ with an Origin header. Item counts and sizes change through the day. Needs cors.dev means the publisher sends no CORS header your origin can use.
| Feed | Needs cors.dev | URL | Items | Size |
|---|---|---|---|---|
| BBC News top stories | Yes | https://feeds.bbci.co.uk/news/rss.xml | 31 | 25 KB |
| BBC World | Yes | https://feeds.bbci.co.uk/news/world/rss.xml | 31 | 24 KB |
| BBC Technology | Yes | https://feeds.bbci.co.uk/news/technology/rss.xml | 21 | 15 KB |
| BBC Business | Yes | https://feeds.bbci.co.uk/news/business/rss.xml | 53 | 39 KB |
| BBC Sport | Yes | https://feeds.bbci.co.uk/sport/rss.xml | 71 | 57 KB |
| Al Jazeera | Yes | https://www.aljazeera.com/xml/rss/all.xml | 25 | 17 KB |
| The Guardian World | Yes | https://www.theguardian.com/world/rss | 45 | 152 KB |
| The Guardian Technology | Yes | https://www.theguardian.com/uk/technology/rss | 32 | 120 KB |
| Sky News | Yes | https://feeds.skynews.com/feeds/rss/home.xml | 9 | 12 KB |
| NPR News | Yes, allows apps.npr.org only | https://feeds.npr.org/1001/rss.xml | 10 | 14 KB |
| CBS News | Yes | https://www.cbsnews.com/latest/rss/main | 30 | 27 KB |
| The Wall Street Journal World | Yes | https://feeds.a.dj.com/rss/RSSWorldNews.xml | 20 | 13 KB |
| Euronews | Yes | https://www.euronews.com/rss | 50 | 33 KB |
| Le Monde in English | Yes | https://www.lemonde.fr/en/rss/une.xml | 14 | 19 KB |
| Der Spiegel International | Yes | https://www.spiegel.de/international/index.rss | 20 | 21 KB |
| Times of India | Yes | https://timesofindia.indiatimes.com/rssfeedstopstories.cms | 48 | 51 KB |
| NDTV | Yes | https://feeds.feedburner.com/ndtvnews-top-stories | 20 | 29 KB |
| ABC News Australia | Yes | https://www.abc.net.au/news/feed/51120/rss.xml | 25 | 87 KB |
| UN News | Yes | https://news.un.org/feed/subscribe/en/news/all/rss.xml | 30 | 34 KB |
| TechCrunch | Yes, allows techcrunch.com only | https://techcrunch.com/feed/ | 20 | 17 KB |
| Ars Technica | Yes | https://feeds.arstechnica.com/arstechnica/index | 20 | 76 KB |
| The Verge | Yes | https://www.theverge.com/rss/index.xml | 10 | 30 KB |
| Engadget | Yes | https://www.engadget.com/rss.xml | 20 | 37 KB |
| Hacker News front page | Yes | https://hnrss.org/frontpage | 20 | 17 KB |
| The New York Times | No, sends * | https://rss.nytimes.com/services/xml/rss/nyt/HomePage.xml | 15 | 35 KB |
| DW English | No, sends * | https://rss.dw.com/xml/rss-en-all | 136 | 84 KB |
| Fox News latest | No, sends * | https://moxie.foxnews.com/google-publisher/latest.xml | 25 | 166 KB |
NPR and TechCrunch do send a CORS header, but only for their own sites, so your page still needs cors.dev. The New York Times, DW and Fox News send Access-Control-Allow-Origin: *; call those directly. To check a feed that is not listed:
# No output: the feed sends no CORS header, so your page needs the proxy
curl -s -o /dev/null -D - -H 'Origin: https://example.com' \
https://feeds.bbci.co.uk/news/rss.xml | grep -i access-control-allow-origin
# access-control-allow-origin: * means fetch() works without a proxy
curl -s -o /dev/null -D - -H 'Origin: https://example.com' \
https://rss.nytimes.com/services/xml/rss/nyt/HomePage.xml | grep -i access-control-allow-originFeeds that do not work through the proxy
- Google News RSS: news.google.com feeds do not work through cors.dev: Google answers the proxy with 503 and its automated queries error page.
- CNN: the rss.cnn.com feeds are served over plain HTTP and fail over HTTPS. cors.dev fetches http:// targets, so request the http:// feed URL through it.
- Yahoo News and France 24: Yahoo answers 403, and France 24 returns an HTML page instead of the feed.
- CNBC: the proxy cannot reach its feed host and answers 502
upstream_unreachable, but CNBC sendsAccess-Control-Allow-Origin: *, so call it directly.
Limits
- cors.dev free tier: GET and HEAD, 600 requests per minute per client IP, no daily or monthly quota, responses up to 6 MiB. Every feed in the table is under 200 KB, and the biggest one checked, The Guardian International at 395 KB, still fits.
- Headers: send a plain
fetch()with no custom headers. The free tier forwards onlyAccept,Accept-Language,If-None-Match,If-Modified-SinceandRange, and answers 400header_not_allowedwhen your code or HTTP library addsAuthorizationor an API key header such asX-Api-Key. - Polling: refresh every 5 to 15 minutes and cache between visits; feeds do not change every second.
- Reuse: a feed is free to read, not free to republish. Show headlines with a link back, and check the terms of the publisher before you use full text or images in a product.
Good questions.
Is there a free news API with no API key?
Yes: the RSS feeds that publishers such as the BBC, The Guardian, Al Jazeera and NPR provide for their readers. They are free, need no key or signup, and update throughout the day. From a browser, put https://proxy.cors.dev/ in front of most of them, because they send no CORS header.
Why does NewsAPI work on localhost but fail after I deploy?
NewsAPI.org's free Developer plan enables CORS for localhost only, so browser requests from your deployed domain are refused. It also limits you to 100 requests per day with a 24-hour delay. Switch to publisher RSS feeds through proxy.cors.dev, or call NewsAPI from a server or pay for a plan.
Can I send my NewsAPI key through cors.dev?
The free tier forwards an apiKey parameter in the URL but refuses an X-Api-Key header with a 400 error. Either way a key in browser code is public, so keyed news APIs belong on a server.
Does Google News RSS work through a CORS proxy?
Not through cors.dev. Google answers the proxy with 503 and its automated queries error page for news.google.com feeds, so use publisher feeds instead.
Do the feeds include images?
Many do, as a Media RSS thumbnail or content element with a url attribute: the BBC, The Guardian, Sky News and The New York Times among them. Load that URL in an img tag; images do not need the proxy.
How often should I refresh a news feed?
Every 5 to 15 minutes is plenty. The BBC feeds set a ttl of 15 minutes, and at 600 requests per minute per client IP the proxy is not what limits you.