Skip to content

Commit 0aec05e

Browse files
authored
Merge pull request #4 from bytesview/new_updates
added deprecated warning
2 parents 85ca957 + 969403a commit 0aec05e

2 files changed

Lines changed: 32 additions & 2 deletions

File tree

newsdataapi/newsdataapi_client.py

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import requests,time
2+
from warnings import warn
23
from newsdataapi import constants
34
from typing import Optional,Union
45
from datetime import datetime,timezone
@@ -159,6 +160,7 @@ def news_api(
159160
Sending GET request to the news api.
160161
For more information about parameters and input, Please visit our documentation page: https://newsdata.io/documentation
161162
"""
163+
warn('This method is deprecated and will be removed in upcomming updates, Instead use latest_api()', DeprecationWarning, stacklevel=2)
162164
params = {
163165
'apikey':self.apikey,'q':q,'qInTitle':qInTitle,'country':country,'category':category,'language':language,'domain':domain,'timeframe':str(timeframe) if timeframe else timeframe,
164166
'size':size,'domainurl':domainurl,'excludedomain':excludedomain,'timezone':timezone,'full_content':full_content,'image':image,'video':video,'prioritydomain':prioritydomain,
@@ -173,7 +175,35 @@ def news_api(
173175
if scroll == True:
174176
return self.__get_feeds_all(url=f'{constants.LATEST_URL}?{URL_parameters_encoded}',max_result=max_result)
175177
else:
176-
return self.__get_feeds(url=f'{constants.LATEST_URL}?{URL_parameters_encoded}')
178+
return self.__get_feeds(url=f'{constants.LATEST_URL}?{URL_parameters_encoded}')
179+
180+
def latest_api(
181+
self, q:Optional[str]=None, qInTitle:Optional[str]=None, country:Optional[Union[str, list]]=None, category:Optional[Union[str, list]]=None,
182+
language:Optional[Union[str, list]]=None, domain:Optional[Union[str, list]]=None, timeframe:Optional[Union[int,str]]=None, size:Optional[int]=None,
183+
domainurl:Optional[Union[str, list]]=None, excludedomain:Optional[Union[str, list]]=None, timezone:Optional[str]=None, full_content:Optional[bool]=None,
184+
image:Optional[bool]=None, video:Optional[bool]=None, prioritydomain:Optional[str]=None, page:Optional[str]=None, scroll:Optional[bool]=False,
185+
max_result:Optional[int]=None, qInMeta:Optional[str]=None, tag:Optional[Union[str,list]]=None, sentiment:Optional[str]=None,
186+
region:Optional[Union[str,list]]=None,excludefield:Optional[Union[str,list]]=None
187+
)->dict:
188+
"""
189+
Sending GET request to the latest api.
190+
For more information about parameters and input, Please visit our documentation page: https://newsdata.io/documentation
191+
"""
192+
params = {
193+
'apikey':self.apikey,'q':q,'qInTitle':qInTitle,'country':country,'category':category,'language':language,'domain':domain,'timeframe':str(timeframe) if timeframe else timeframe,
194+
'size':size,'domainurl':domainurl,'excludedomain':excludedomain,'timezone':timezone,'full_content':full_content,'image':image,'video':video,'prioritydomain':prioritydomain,
195+
'page':page,'qInMeta':qInMeta,'tag':tag, 'sentiment':sentiment, 'region':region,'excludefield':excludefield
196+
}
197+
URL_parameters = {}
198+
for key,value in params.items():
199+
if value is not None:
200+
URL_parameters.update(self.__validate_parms(param=key,value=value))
201+
202+
URL_parameters_encoded = urlencode(URL_parameters, quote_via=quote)
203+
if scroll == True:
204+
return self.__get_feeds_all(url=f'{constants.LATEST_URL}?{URL_parameters_encoded}',max_result=max_result)
205+
else:
206+
return self.__get_feeds(url=f'{constants.LATEST_URL}?{URL_parameters_encoded}')
177207

178208
def archive_api(
179209
self, q:Optional[str]=None, qInTitle:Optional[str]=None, country:Optional[Union[str, list]]=None, category:Optional[Union[str, list]]=None,

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
setup(
88
name='newsdataapi',
9-
version='0.1.16',
9+
version='0.1.17',
1010
packages=['newsdataapi'],
1111
description='Python library for newsdata client-API Call',
1212
long_description=long_description,

0 commit comments

Comments
 (0)