q parameter accepts a rich query syntax for building precise searches:
exact phrase matching, boolean operators, wildcards, and proximity search. This
page describes each technique and how to combine them.
To apply these techniques in a working API call, see
Build search queries.
Exact match
Wrap a phrase in double quotes to search for it as an exact sequence of words. Without quotes, the API treats each word as a separate term and insertsAND
between them automatically.
Use exact match for names, titles, and any multi-word term you want treated as
a unit.
Escaping quotes in JSON
When passing exact match syntax inside a JSON string, escape the inner double quotes with a backslash:Boolean operators
Use boolean operators to combine or exclude terms. Theq parameter is a
string — the table below shows the exact value you pass:
Use parentheses to group terms and control evaluation order:
Wildcards
Use wildcards to match term variations:Wildcards cannot appear at the start of a term.
"*intelligence" is not valid.Proximity search
TheNEAR operator finds articles where two terms appear within a specified
number of words of each other. Use it when terms must be discussed in the same
context, not just anywhere in the article.
Syntax:
Limits:
- Maximum 4 words per phrase
- Maximum 3 phrases per
NEARoperation - Maximum distance of 100 words
Combining techniques
You can combine all techniques in a single query. The following examples show the exact value to pass in theq string:
Market research:
Comparison of techniques
Best practices
- Start broad and add filters to narrow results.
- Always quote multi-word terms to prevent automatic
ANDinsertion. - Use parentheses to group terms and make operator precedence explicit.
- Use
NEARwhen terms must appear in the same context, not just the same article. - Check
user_input.qin the response to verify how the API interpreted your query. - URL-encode the
qparameter when usingGETrequests to avoid issues with special characters.

