Skip to main content
News API supports a rich query syntax in the q parameter: boolean operators (AND, OR, NOT), proximity search (NEAR), wildcards, and exact phrase matching. This guide shows you how to put them together and make the API call. For the full syntax reference, see Advanced querying.

Before you begin

Make sure you have the following:
  • An active News API key
  • The Newscatcher SDK installed for your language, or cURL for quick testing

Steps

1

Build a boolean query

Use AND, OR, and NOT to combine terms. Use parentheses to control evaluation order. The q parameter is a string — examples below show the exact value you pass:
Always quote multi-word terms: "Tesla NOT \"Elon Musk\"".Without quotes, the API inserts AND between standalone words — "AI OR artificial intelligence" becomes "AI OR artificial AND intelligence", which returns a 422 (mixed operators at the same level).See Automatic AND insertion.
Pass your query in the q parameter:
2

Build a proximity query

The NEAR operator finds articles where two terms appear within a specified number of words of each other. Use it when you need terms to be discussed in the same context, not just anywhere in the article.Syntax:
3

Validate your query

If you’re using the Python SDK, run validate_query() before making the API call. It catches syntax errors locally without consuming an API call:
Validation is especially useful for LLM-generated queries and user input. See Validate queries with Python SDK for bulk validation and the full rules reference.
4

Refine your results

Check total_hits and user_input in the response to understand what the API matched and how it interpreted your query:
If results are off, try the following:
  • Too broad — add AND terms or narrow with NOT, or reduce the NEAR distance
  • Too few — broaden with OR, increase the NEAR distance, or use wildcards (technolog*)
  • Wrong interpretation — check user_input.q to see how the API parsed your query

See also