# Fetch news articles into a Python script with one POST

In Python, requests.post to https://api.routergrowth.com/v1/run with a Bearer key and a body naming news.search, the query, a location such as Germany and a language. result.articles is a list of dicts with title, source, domain, snippet, url and published_at, and result.location_resolved shows how the location was read.

HTML page: https://www.routergrowth.com/tools/web-scraping/news-api-python
Part of: [Web search and scraping tools](https://www.routergrowth.com/tools/web-scraping.md)

## The call

[`news.search`](https://www.routergrowth.com/catalog/news.search): Google News articles for a query and location: title, source, snippet, URL and publication time.

Price on this network: $0.0035 per search. The exact quote is shown before every run.

## What a real run returned

Run on 2026-10-26: 10 records in 4.6 s for $0.004. Personal fields are masked. Ten English articles on offshore wind with location Germany (code 2276): a cable vessel, an RWE sale, German grid plans and Vietnam projects; one article came with no time.

| published | domain | title |
|---|---|---|
| 2026-10-26 | www.offshorewind.biz | Prysmian's New Cable-Laying Vessel Performing Sea Trials |
| 2026-10-12 | www.rwe.com | RWE completes sale of shares in Five Estuaries Offshore Wind Farm |
|  | www.enerdata.net | Denmark’s CIP moves forward with 1 GW offshore wind in Vietnam |

## How to do it

1. **Read the key from the environment.** key = os.environ['ROUTERGROWTH_API_KEY'], sent as Authorization: Bearer.
2. **POST the query.** requests.post(url, json={'capability': 'news.search', 'input': {'query': 'offshore wind', 'location': 'Germany', 'language': 'en'}}, headers=headers, timeout=60).
3. **Load result.articles.** pandas.DataFrame(r.json()['result']['articles']) gives one row per article.
4. **Parse the times.** pandas.to_datetime on published_at; empty strings become NaT, so filter or fill them.

## Ask it like this

- Write a Python script that pulls offshore wind news for Germany, the UK and Denmark each morning and appends new URLs to a CSV. (`news.search`)
- In Python, fetch news on our category, then scrape the top three articles and save them as markdown files. (`news.search`, `web.scrape`)

## Connect

MCP server: `https://api.routergrowth.com/mcp`

```bash
claude mcp add --transport http routergrowth https://api.routergrowth.com/mcp
```

```bash
npm install -g routergrowth && routergrowth setup
routergrowth run -c news.search -i '{"query": "offshore wind", "location": "Germany", "language": "en", "limit": 8}'
```

```bash
curl -X POST https://api.routergrowth.com/v1/run \
  -H "Authorization: Bearer $ROUTERGROWTH_API_KEY" \
  -d '{"capability": "news.search", "input": {"query": "offshore wind", "location": "Germany", "language": "en", "limit": 8}}'
```

## Worth knowing

- **Check location_resolved.** It shows the location code and name the query used. matched false means the location was not recognized.
- **Some times are empty.** An article can come back with an empty published_at. Keep it, but sort it last.
- **Ten at a time.** Articles are fetched in tens, so a limit of 8 can return 10. Slice the list in code.

## Questions

### Is there a Python package?

None is needed. requests or httpx and your key are enough.

### What format is published_at?

A string such as 2026-10-26 06:59:39 +00:00, which pandas.to_datetime reads.

### Can I run several queries at once?

Yes. Send them concurrently; each query is its own run.

### What happens when a call fails?

The response says why and nothing is charged. Retry once or skip that query.

## Related

- [Convert a web page into clean markdown your model can read](https://www.routergrowth.com/tools/web-scraping/website-to-markdown.md)
- [Search the web from code and get citable sources back as JSON](https://www.routergrowth.com/tools/web-scraping/web-search-api.md)
- [Ground an agent in sources from the domains you trust](https://www.routergrowth.com/tools/web-scraping/web-search-api-for-llm.md)
- [Turn a public page into agent ready text with a single request](https://www.routergrowth.com/tools/web-scraping/api.md)
- [Scrape public pages from a Python script with one POST request](https://www.routergrowth.com/tools/web-scraping/api-python.md)
- [Get the latest headlines on a listed company from its name and ticker](https://www.routergrowth.com/tools/web-scraping/stock-news-api.md)
- [Pull news articles on any topic into your code as JSON](https://www.routergrowth.com/tools/web-scraping/news-api.md)
- [Get the articles Google News lists for a query, in one API call](https://www.routergrowth.com/tools/web-scraping/google-news-api.md)
- [Read a public Amazon product page from your agent, with no scraper to maintain](https://www.routergrowth.com/tools/web-scraping/amazon.md)
