@@ -25,7 +25,8 @@ def __init__(
2525 max_pages : Optional [int ] = 10 ** 10 ,
2626 debug : Optional [bool ] = False ,
2727 folder_path : Optional [str ] = None ,
28- include_headers : Optional [bool ] = False
28+ include_headers : Optional [bool ] = False ,
29+ accept_language : Optional [str ] = 'en' ,
2930 ) -> None :
3031 """Initializes newsdata client object for access Newsdata APIs."""
3132 self .apikey = apikey
@@ -39,6 +40,7 @@ def __init__(
3940 self .request_timeout = request_timeout
4041 # self.is_debug = debug
4142 self .include_headers = include_headers
43+ self .accept_language = accept_language
4244 self .set_base_url ()
4345 super ().__init__ (folder_path = folder_path )
4446 logger .info ("NewsDataApiClient initialized successfully." )
@@ -137,9 +139,15 @@ def __get_feeds(self, endpoint: str, query_params: dict) -> Dict[str, Any]:
137139 params = query_params .copy ()
138140 params ['apikey' ] = self .apikey
139141 url = f"{ endpoint } ?{ urlencode (params , quote_via = quote )} "
142+ headers = {'Accept-Language' :self .accept_language }
140143
141144 logger .info (f"Fetching data from URL: { url } " )
142- response = self .request_method .get (url = url , proxies = self .proxies , timeout = self .request_timeout )
145+ response = self .request_method .get (
146+ url = url ,
147+ proxies = self .proxies ,
148+ timeout = self .request_timeout ,
149+ headers = headers
150+ )
143151 logger .info (f"Time taken to fetch data: { time .perf_counter () - s_time :.2f} seconds" )
144152
145153 X_API_Limit_Remaining = response .headers .get ("X-API-Limit-Remaining" )
0 commit comments