Back to Blog
How to Fetch Real-Time News with TheNewsAPI.net
Jun 19, 2025

How to Fetch Real-Time News with TheNewsAPI.net

Tutorial

A comprehensive guide to integrating and using TheNewsAPI in your projects.

Getting Started with TheNewsAPI.net

To begin, make sure you have the following:

In this tutorial, we’ll retrieve the most recent news about “Bitcoin ETF” or “regulation” in English.

How to Fetch Crypto News with Python

Python is a popular choice for API integrations thanks to its simplicity and the robust requests library.

Requirements

  • Python 3.6 or newer
  • The requests library (install with pip install requests)

Sample Python Script

import requests
from urllib.parse import quote

api_key = 'YOUR_API_KEY'
url = 'https://api.thenewsapi.net/crypto'
q = quote("'bitcoin ETF' | regulation")
params = {'apikey': api_key, 'q': q, 'langs': 'en'}

response = requests.get(url, params=params)
if response.status_code == 200:
    for article in response.json()['data']['results']:
        print('Title:', article.get('title'))
        print('Source:', article.get('source'))
        print('Published:', article.get('published_at'))
else:
    print('Error:', response.status_code, response.json().get('message'))

How the Script Works

  • Imports the requests library for HTTP requests.
  • Sets your API key and search parameters (q for keyword, langs for language).
  • Sends a GET request and print articles if successful.

Running the Script

Execute python fetch_crypto_news.py in your terminal. You should see output similar to:

Title: Bitcoin ETF Approval Sparks Market Rally
Source: CoinDesk
Published: 2025-06-18T10:30:00Z

Quick Crypto News Fetching with Curl

Curl is great for testing APIs, using --data-urlencode to handle complex query parameters.

Example Curl Command

curl -G "https://api.thenewsapi.net/crypto" \
  --data-urlencode "apikey=YOUR_API_KEY" \
  --data-urlencode "q='bitcoin ETF' | regulation" \
  --data-urlencode "langs=en"

Using the Query Builder (No-Code Option)

TheNewsAPI.net’s Query Builder lets you construct complex API queries visually, right from your dashboard:

  1. Go to the Query Builder section after logging in.
  2. Choose your search terms, categories, and filters using the form.
  3. Preview matching articles in real time.
  4. Copy the generated API URL or code snippet for your project.

This tool is perfect for experimenting with different parameters or for those who prefer not to write code.

Advanced Query Features

Refine your news search with these optional parameters:

Parameter Description Example
from/to Date range (ISO 8601) from=2025-06-01
categories Filter by categories categories=defi,nft,bitcoin
sentiments Filter by sentiment sentiments=positive,neutral
sources Filter by sources sources=coindesk.com
langs Filter by language langs=en,zh
page/size Pagination page=1&size=10

For more details, visit the official documentation.

Common Issues & Troubleshooting

Issue Solution
Invalid API Key Double-check your key in the dashboard.
Rate Limits Review your plan’s quota on the pricing page.
No Results Try broader keywords (e.g., “crypto”) or adjust your filters.

Conclusion

With TheNewsAPI.net, you can easily integrate real-time news into your apps, dashboards, or research tools. Whether you prefer Python, curl, or a no-code solution, this platform makes it simple to stay informed and build smarter projects.

Ready to explore more? Check out the full documentation and start building today.


Share this article
Tags
#integration#Tutorial

Ready to get started?

Sign up now to access real-time news, analytics, and more. Power your next project with TheNewsAPI!

Get Started Free