Free News library for python is able to fetch local news and category news in real time.
Please email mohammedalaazakitayyem@gmail.com if you find any bugs. This api works by : Newsi
This news API supports local news and category news.
- Top Headlines news
- Local news
- World news
- business news
- sports news
- world news
- politics news
- technology news
- entertainment news
- science news
pip install newsi
To get the country and its supported language
from newsi import Supported_language_and_countries
supported_language_and_countries = Supported_language_and_countries()
print(supported_language_and_countries)
Response example :
[{
"United States": [
{
"Country code": "us",
"Language code": "en",
"Language name": "English"
}
]
}]
Make a get request specifying the local of news you want
Field | Description |
---|---|
language | The 2-letter ISO-639-1 code of the language you want to get headlines for. examples: ar en es fr he ..... |
country | Find sources that display news in a specific country. examples: eg us es fr in ..... |
sort | The order to sort the articles in :top = Fetch the top news.last = Fetch the latest news. |
page | Use this to page through the results. |
limit | Use this to customize the number of stories per page default = 20Max = 100 |
from newsi import Local
local_news = Local("en","us","top",1,20)
print(local_news)
Response example :
[{
"_id": "93223cd39597de2f77da56f1e6774d53b70bfdc1ef8f13b3377b030f1a47b350",
"body": "✕ Close Donald Trump indictment - latest news\n\nSign up for the daily Inside Washington email for exclusive US coverage and analysis sent to your inbox Get our free Inside Washington email Please enter a valid email address Please enter a valid email address SIGN UP I would like to be emailed about offers, events and updates from The Independent. Read our privacy notice Thanks for signing up to the\n\nInside Washington email {{ #verifyErrors }} {{ message }} {{ /verifyErrors }} {{ ^verifyErrors }} Something went wrong. Please try again later {{ /verifyErrors }}\n\nDonald Trump has promised to share an “irrefutable” report on his baseless claims of election fraud in Georgia.\n\n“A Large, Complex, Detailed but Irrefutable REPORT on the Presidential Election Fraud which took place in Georgia is almost complete & will be presented by me at a major News Conference at 11.00am on Monday of next week,” Mr Trump said.\n\nThe former president and 18 of his allies have been indicted on a range of criminal charges relating to the former president’s attempts to alter Georgia‘s 2020 election results.\n\nHe described the extensive charge sheet produced by a grand jury in Fulton County as an attempt to stop him from running in next year’s election, saying that the “the witch hunt continues”.\n\nMr Trump has been charged with 13 counts including racketeering, filing false documents, and attempting to coerce public officers to violate their oaths, according to court documents.\n\nIt marks the fourth major indictment against Mr Trump in nearly as many months, and the second related directly to his actions during the 2020 election.\n\nMr Trump has been issued with an arrest warrant and ordered to surrender by 25 August.",
"hasBody": true,
"image": "https://lh6.googleusercontent.com/proxy/aO7jtu3L2CrM-dkYuyB1iGTMC0jUXCXfzuPIaWeKCyG0DVwTOpZn42CVkblpl3XqzcYu3ZRbDaiw55plsjYam2tXbvaZI7Lvws9MQIQGZYBmKbLC2X4PKtFLm5MvrQP33zlnyN1ZpoJv8NjW7SnsUksR167lLHwQIKs=s1200",
"link": "https://www.independent.co.uk/news/world/americas/us-politics/trump-indictment-arrest-warrant-georgia-latest-b2393765.html",
"publishedAt": "2023-08-16T08:31:32Z",
"publishedTimestamp": 1692174692,
"shortLink": "independent.co.uk",
"sourceName": "The Independent",
"title": "Trump claims mystery press conference report clears him of Georgia election charges"
}]
Make a get request specifying the Category of news you want
Field | Description |
---|---|
category | The category you want to get new for. Possible options:sport world business science_and_technology education entertainment health travel . |
language | The 2-letter ISO-639-1 code of the language you want to get headlines for. examples: ar en es fr he ..... |
country | Find sources that display news in a specific country. examples: .eg us es fr in ..... |
sort | The order to sort the articles in :top = Fetch the top news.last = Fetch the latest news. |
page | Use this to page through the results. |
from newsi import Category
category_news = Category("world","en","us","top",1,20)
print(category_news)
Response example :