Query Syntax

Understand the query syntax to search for news articles effectively

AllNewsAPI supports powerful query syntax that allows you to search for news articles with precision. Learn how to use operators to refine your searches.

Info
  • Always URL-encode your query string
  • Use quotes around special characters
  • Combine operators for precise results

The simplest way to search is to provide keywords. The API will return articles containing those keywords.

Basic Search

Use quotation marks to search for an exact phrase. This ensures the words appear together in the specified order.

Phrase Search

AND Operator

By default, spaces between words act as AND operators. You can also use AND explicitly.

AND Operator

OR Operator

Use OR to find articles containing either term. Note: OR takes precedence over AND.

OR Operator

NOT Operator

Use NOT to exclude articles containing specific terms.

NOT Operator

Combining Operators

You can combine operators for complex queries. Use parentheses to control precedence.

Combined Operators

Examples of valid queries

QueryExpected Result
googleNews articles that contain the word google
google OR androidNews articles that contain the word google or the word android
"google android"News articles that contain the word google android in the same exact order
"windows 8" AND "windows 10"News articles that contain both words: windows 8 and windows 10
iphone AND (13 OR 14)News articles that contain the word Iphone and one of 13 or 14
android NOT googleNews articles that contain the word android but not the word google