Basic Search
The q parameter allows you to search through articles using specific terms and boolean operators.
1. Boolean Operators
You can combine search terms using AND and OR operators:
- AND operator - Returns results containing all specified terms:
https://api.newsdatahub.com/v1/news?q=apple AND banana
This ensures both terms appear in results
- OR operator - Returns results containing any of the specified terms:
https://api.newsdatahub.com/v1/news?q=apple OR banana
Results will contain either or both terms
Note: OR is the default operator when no boolean operator is specified. For example:
https://api.newsdatahub.com/v1/news?q=apple banana
Equivalent to:
https://api.newsdatahub.com/v1/news?q=apple OR banana
2. Exact Phrase Matching
Use quotation marks to search for exact phrases:
https://api.newsdatahub.com/v1/news?q="apple pie"
https://api.newsdatahub.com/v1/news?q="breaking news" AND technology
3. Exclusion
Use the minus (-) operator to exclude specific terms from results:
https://api.newsdatahub.com/v1/news?q=apple -banana
Returns articles about apple but excludes those containing banana
4. Complex Queries
You can combine these operators for more sophisticated searches:
Articles about technology startups, excluding finance
https://api.newsdatahub.com/v1/news?q="tech startup" AND innovation -finance
Articles about either electric vehicles or renewable energy, must include sustainability
https://api.newsdatahub.com/v1/news?q=("electric vehicles" OR "renewable energy") AND sustainability
Articles about AI in healthcare, excluding specific companies
https://api.newsdatahub.com/v1/news?q="artificial intelligence" AND healthcare -google