Quick and easy examples to get you started with the newsdata.io API. Fetch news articles, headlines, and crypto updates in just a few lines of Python.
Examples are grouped by the NewsData.io endpoint they demonstrate.
Latest news (latest_api)
latest_headlines.py- Get the latest tech news from the USnews_with_images.py- Fetch news with images onlydomain_specific_news.py- Pull articles from specific domainsmulti_country_news.py- Query several countries/languages at once + deduplicateai_insights_news.py- Show the AI fields: sentiment, ai_tag, ai_region, ai_org, keywordsfull_content_pagination.py- Full article body + automatic multi-page pagination
Crypto news (crypto_api)
crypto_news.py- Track cryptocurrency-related articles by coin + sentimentcrypto_sentiment_tags.py- Filter by coin, crypto AI tags and sentimentcrypto_history.py- Historical crypto news over a date range
News archive (archive_api)
archive_endpoint.py- Search historical news archivesarchive_full_content.py- Archive search by category + sentiment over a date range
News sources (sources_api)
news_sources.py- Discover which publishers NewsData.io indexes
Market / financial news (market_api)
financial_market_news.py- Stock-ticker filtered business news with sentiment
News count (count_api)
news_count.py- Article volume over time (trend analytics, no article payload)
-
Get your API key from newsdata.io
-
Install dependencies
pip install -r requirements.txt
-
Set up your API key
cp .env.example .env # Edit .env and add your API key -
Run any example
python latest_headlines.py
Each script is self-contained and shows a different use case. Pick one, run it, and see what you get. Modify the parameters to fit your needs.
Check out the newsdata.io documentation for all available parameters and features.