A comprehensive guide to integrating and using TheNewsAPI in your projects.
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.
Python is a popular choice for API integrations thanks to its simplicity and the robust requests library.
pip install requests
)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'))
requests
library for HTTP requests.q
for keyword, langs
for language).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
Curl is great for testing APIs, using --data-urlencode
to handle complex query parameters.
curl -G "https://api.thenewsapi.net/crypto" \ --data-urlencode "apikey=YOUR_API_KEY" \ --data-urlencode "q='bitcoin ETF' | regulation" \ --data-urlencode "langs=en"
TheNewsAPI.net’s Query Builder lets you construct complex API queries visually, right from your dashboard:
This tool is perfect for experimenting with different parameters or for those who prefer not to write code.
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.
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. |
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.
Sign up now to access real-time news, analytics, and more. Power your next project with TheNewsAPI!
Get Started Free