File tree 2 files changed +20
-0
lines changed 2 files changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -178,6 +178,7 @@ def get_everything( # noqa: C901
178
178
self ,
179
179
q = None ,
180
180
qintitle = None ,
181
+ searchIn = None ,
181
182
sources = None ,
182
183
domains = None ,
183
184
exclude_domains = None ,
@@ -200,6 +201,10 @@ def get_everything( # noqa: C901
200
201
`documentation <https://newsapi.org/docs/endpoints/everything>`_ for search syntax and examples.
201
202
:type q: str or None
202
203
204
+ :param searchIn: The fields to restrict your q search to. Should be either title, content, or description. See the official News API
205
+ `documentation <https://newsapi.org/docs/endpoints/everything>`_ for search syntax and examples.
206
+ :type q: str or None
207
+
203
208
:param sources: A comma-seperated string of identifiers for the news sources or blogs you want headlines from.
204
209
Use :meth:`NewsApiClient.get_sources` to locate these programmatically, or look at the
205
210
`sources index <https://newsapi.org/sources>`_.
@@ -262,6 +267,16 @@ def get_everything( # noqa: C901
262
267
else :
263
268
raise TypeError ("keyword/phrase qintitle param should be of type str" )
264
269
270
+ # SearchIn
271
+ if searchIn is not None :
272
+ if is_valid_string (searchIn ):
273
+ if searchIn in ["title" , "content" , "description" ]:
274
+ payload ["searchIn" ] = searchIn
275
+ else :
276
+ raise ValueError (
277
+ f"searchIn param should be either title, content, or description. { searchIn } is given. "
278
+ )
279
+
265
280
# Sources
266
281
if sources is not None :
267
282
if is_valid_string (sources ):
Original file line number Diff line number Diff line change @@ -146,6 +146,11 @@ def test_api_get_everything(self):
146
146
with self .assertRaises (ValueError ):
147
147
self .api .get_everything (page = page )
148
148
149
+ # Raises a ValueError if searchIn param is not equal to either title, description, or content
150
+ searchIn = "date"
151
+ with self .assertRaises (ValueError ):
152
+ self .api .get_everything (searchIn = searchIn )
153
+
149
154
def test_api_get_sources (self ):
150
155
# Raise TypeError if language param is not of type str
151
156
language = 0
You can’t perform that action at this time.
0 commit comments