APITube Help Center

How to Use AND, OR and NOT in News Search

Require, alternate or exclude conditions with the query parameter

Kent Hudson

Written by Kent Hudson

June 27, 2026

Updated October 16, 2026

Open this example in the API Playground ↗

How to use AND, OR and NOT in search

Use query to combine search conditions. AND requires both, OR accepts either, and NOT excludes a match. Parentheses group conditions. A bare keyword searches the headline:

curl "https://api.apitube.io/v1/news/everything?query=bitcoin AND ethereum&api_key=YOUR_API_KEY"

Send your key through api_key or X-API-Key. URL-encode spaces, quotes and parentheses when sending query; use your HTTP client’s query-parameter handling rather than inserting raw text into a URL.

What does the query parameter do?

It adds Boolean logic to supported search fields. query=tesla means query=title:tesla. NOT takes priority over AND, which takes priority over OR. Parentheses override that order.

Flat parameters still combine with the query using AND:

curl "https://api.apitube.io/v1/news/everything?read_time.min=2&query=title:bitcoin&api_key=YOUR_API_KEY"

How to combine keywords with AND

Use AND when both conditions must match. A space between conditions also means AND:

curl "https://api.apitube.io/v1/news/everything?query=tesla AND recall&api_key=YOUR_API_KEY"

How to match either keyword with OR

Use OR for alternatives. A field can apply to a grouped list:

curl "https://api.apitube.io/v1/news/everything?query=title:(tesla OR ford)&api_key=YOUR_API_KEY"

Use (a OR b) AND c when both alternatives should also require c.

How to exclude keywords with NOT

NOT, or the - prefix, excludes the condition immediately after it:

curl "https://api.apitube.io/v1/news/everything?query=tesla AND NOT lawsuit&api_key=YOUR_API_KEY"

It can apply to other supported fields, such as NOT source.country.code:ru. See dedicated exclusions for the flat-parameter form.

How to group conditions with parentheses

Group alternatives so NOT can exclude the whole group:

curl "https://api.apitube.io/v1/news/everything?query=tesla AND NOT (recall OR lawsuit)&api_key=YOUR_API_KEY"

Queries allow up to 10 levels of nesting, 64 conditions and 4,000 characters. Exceeding limits returns 400 ER0703.

How to run boolean logic across other fields

Use supported field names for language, source, category, dates and other conditions:

curl "https://api.apitube.io/v1/news/everything?query=title:(tesla OR ford) AND language.code:en AND NOT source.country.code:ru&api_key=YOUR_API_KEY"

Quote values with special characters, for example category.id:"medtop:04000000". Boolean title-affix names use dots, such as title.starts_with; their flat-parameter equivalents use underscores, such as title_starts_with.

See language filters and the parameter reference.

What operators are not supported

Fuzzy matching (term~2), wildcards (ter* or te?t), boosts (term^3) and regular expressions return 400 ER0704. Bare keywords do not search article bodies.

For partial headlines, use Boolean fields title.starts_with, title.ends_with or title.pattern, or their flat equivalents.

Common Questions

Does a bare keyword search the article body?

No. It searches the headline. Use a supported structured field when you need another condition.

Is a space the same as AND or OR?

AND. Write OR explicitly to accept alternatives.

Can I still use my flat filters with query?

Yes. Both must match. For example, a minimum read time can accompany a Boolean headline search.

Why does my fuzzy or wildcard query fail?

Those operators are unsupported (ER0704). Unknown fields return ER0702; malformed syntax, such as an unclosed group, returns ER0701. Check field names, quotes and parentheses.


Related Articles