news

Search for enriched real-time news context

Search for any news, up to the last 5 minutes or in our extensive historical archive filled with 100s of millions of articles.

Geared toward low-latency applications, where time is of the essence. For example, this endpoint is commonly used for quickly getting news context for an LLM.

This endpoint is also commonly used for synthetic data curation. For example, say you are fine-tuning a model for sports. You could filter with classification="Sports" and build a dataset of sports articles.

News articles come with an abundance of valuable metadata, including full summaries, sentiment, entities, reporting voice, page rank, language, and much much more.

An example of this data in action can be found and interacted with at https://asknews.app/chat

get/v1/news/search

Query parameters

querystring

Query string that can be any phrase, keyword, question, or paragraph. If method='nl', then this will be used as a natural language query. If method='kw', then this will be used as a direct keyword query. This is not required, if it is not passed, then the search is based on the remaining filters only.

Query string that can be any phrase, keyword, question, or paragraph. If method='nl', then this will be used as a natural language query. If method='kw', then this will be used as a direct keyword query. This is not required, if it is not passed, then the search is based on the remaining filters only.

n_articlesinteger

Number of articles to return

Number of articles to return

start_timestampinteger nullable

Timestamp to start search from

Timestamp to start search from

end_timestampinteger nullable

Timestamp to end search at

Timestamp to end search at

time_filter'crawl_date' | 'pub_date'

Control which date type to filter on. 'crawl_date' is the date the article was crawled, 'pub_date' is the date the article was published.

Control which date type to filter on. 'crawl_date' is the date the article was crawled, 'pub_date' is the date the article was published.

return_type'string' | 'dicts' | 'both'

Type of return value. 'string' means that the return is prompt-optimized and ready to be immediately injected into any prompt. 'dicts' means that the return is a structured dictionary, containing additional metadata (like a classic news api). Can be 'string' or 'dicts', or 'both'. 'string' guarantees the lowest-latency response 'dicts' requires more I/O, therefore increases latency (very slightly, depending on your network connection).

Type of return value. 'string' means that the return is prompt-optimized and ready to be immediately injected into any prompt. 'dicts' means that the return is a structured dictionary, containing additional metadata (like a classic news api). Can be 'string' or 'dicts', or 'both'. 'string' guarantees the lowest-latency response 'dicts' requires more I/O, therefore increases latency (very slightly, depending on your network connection).

historicalboolean

Search on archive of historical news. Defaults to False, meaning that the search will only look through the most recent news (48 hours)

Search on archive of historical news. Defaults to False, meaning that the search will only look through the most recent news (48 hours)

method'nl' | 'kw' | 'both'

Method to use for searching. 'nl' means Natural Language, which is a string that can be any phrase, keyword, question, or paragraph that will be used for semantic search on the news. 'kw' means Keyword, which can also be any keyword(s), phrase, or paragraph, however the search is a direct keyword search on the database. 'both' means both methods will be used and results will be ranked according to IRR. 'both' may reduce latency by 10 pct in exchange for improved accuracy.

Method to use for searching. 'nl' means Natural Language, which is a string that can be any phrase, keyword, question, or paragraph that will be used for semantic search on the news. 'kw' means Keyword, which can also be any keyword(s), phrase, or paragraph, however the search is a direct keyword search on the database. 'both' means both methods will be used and results will be ranked according to IRR. 'both' may reduce latency by 10 pct in exchange for improved accuracy.

similarity_score_thresholdnumber

Similarity score threshold to determine which articles to return. Lower means less similar results are allowed.

Similarity score threshold to determine which articles to return. Lower means less similar results are allowed.

integer
OR
string uuid

Offset for pagination. The n_articles is your page size, while your offset is the number of articles to skip to get to your page of interest. For example, if you want to get page 3 for n_article page size of 10, you would set offset to 20.

categoriesstring[]

Categories of news to filter on

Categories of news to filter on

doc_start_delimiterstring

Document start delimiter for string return.

Document start delimiter for string return.

doc_end_delimiterstring

Document end delimiter for string return.

Document end delimiter for string return.

provocative'unknown' | 'low' | 'medium' | 'high' | 'all'

Filter articles based on how provocative they are deemed based on the use of provocative language and emotional vocabulary.

Filter articles based on how provocative they are deemed based on the use of provocative language and emotional vocabulary.

string[]
OR
'Objective' | 'Subjective' | 'Investigative' | 'Narrative' | 'Analytical' | 'Advocacy' | 'Conversational' | 'Satirical' | 'Emotive' | 'Explanatory' | 'Persuasive' | 'Sensational' | 'Unknown' | 'all'

Type of reporting voice to filer by.

string[]
OR
string

filter by domain url of interest. This can be a single domain or a list of domains. For example, 'npr.org' or ['nature.com', 'npr.org']

string[]
OR
string

blacklist of domains that must be excluded from resultsThis can be a single domain url or a list of domain urls.

podcasts'include' | 'only' | 'none'

Control whether podcasts are included in search results. 'include' searches news and podcasts, 'only' searches podcasts only, and 'none' excludes podcasts.

Control whether podcasts are included in search results. 'include' searches news and podcasts, 'only' searches podcasts only, and 'none' excludes podcasts.

page_rankinteger nullable

Maximum allowed page rank for returned articles.

Maximum allowed page rank for returned articles.

diversify_sourcesboolean

Ensure that the return set of articles are selected from diverse sources. This adds latency to the search, but attempts to balance the representation of sources by country and source origins. In summary, a net is cast around your search, then the diversity of sources is analyzed, and your final result matches the large net diversity distribution. This means that your search accuracy is reduced, but you gain more diverse perspectives.

Ensure that the return set of articles are selected from diverse sources. This adds latency to the search, but attempts to balance the representation of sources by country and source origins. In summary, a net is cast around your search, then the diversity of sources is analyzed, and your final result matches the large net diversity distribution. This means that your search accuracy is reduced, but you gain more diverse perspectives.

strategy'latest news' | 'news knowledge' | 'default'

Strategy to use for searching. 'latest news' automatically setsmethod='nl', historical=False, and looks within the past 24 hours. 'news knowledge' automatically sets method='kw', historical=True, and looks within the past 60 days. 'news knowledge' will increase latency due to the larger search space in the archive. Use 'default' if you want to control start_timestamp, end_timestamp, historical, and method.

Strategy to use for searching. 'latest news' automatically setsmethod='nl', historical=False, and looks within the past 24 hours. 'news knowledge' automatically sets method='kw', historical=True, and looks within the past 60 days. 'news knowledge' will increase latency due to the larger search space in the archive. Use 'default' if you want to control start_timestamp, end_timestamp, historical, and method.

hours_backinteger

Can be set to easily control the look back on the search. This is the same as controlling the 'start_timestamp' parameter. The difference is that this is not a timestamp, it is the number of hours back to look from the current time. Defaults to 24 hours.

Can be set to easily control the look back on the search. This is the same as controlling the 'start_timestamp' parameter. The difference is that this is not a timestamp, it is the number of hours back to look from the current time. Defaults to 24 hours.

string_guaranteestring[] nullable

If defined, the search will only occur on articles that contain strings in this list.

If defined, the search will only occur on articles that contain strings in this list.

string_guarantee_op'AND' | 'OR'

Operator to use for string guarantee list.

Operator to use for string guarantee list.

reverse_string_guaranteestring[] nullable

If defined, the search will only occur on articles that do not contain strings in this list.

If defined, the search will only occur on articles that do not contain strings in this list.

entity_guaranteestring[] nullable

Entity guarantee to filter by. This is a list of strings, where each string includes entity type and entity value separated by a colon. The first element is the entity type and the second element is the entity value. For example ['Location:Paris', 'Person:John']

Entity guarantee to filter by. This is a list of strings, where each string includes entity type and entity value separated by a colon. The first element is the entity type and the second element is the entity value. For example ['Location:Paris', 'Person:John']

reverse_entity_guaranteestring[] nullable

Reverse entity guarantee to filter by. This is a list of strings, where each string includes entity type and entity value separated by a colon. The first element is the entity type and the second element is the entity value. For example ['Location:Paris', 'Person:John']

Reverse entity guarantee to filter by. This is a list of strings, where each string includes entity type and entity value separated by a colon. The first element is the entity type and the second element is the entity value. For example ['Location:Paris', 'Person:John']

entity_guarantee_op'AND' | 'OR'

Operator to use for entity guarantee list.

Operator to use for entity guarantee list.

return_graphsboolean

Return graphs for the articles. Only available to Analyst tier and above.

Return graphs for the articles. Only available to Analyst tier and above.

return_geoboolean

Return GeoCoordinates associated with locations discussed inside the articles. Only available to Analyst tier and above.

Return GeoCoordinates associated with locations discussed inside the articles. Only available to Analyst tier and above.

languagesstring[] nullable

Languages to filter by. This is the two-letter 'set 1' of the ISO 639-1 standard. For example: English is 'en'.

Languages to filter by. This is the two-letter 'set 1' of the ISO 639-1 standard. For example: English is 'en'.

countriesstring[] nullable

Source countries to filter by (this is only for the publisher location, not the locations mentioned in articles. For Locations mentioned in articles, refer to entity_guarantee), countries must be the two-letter ISO country codeFor example: United States is 'US', France is 'FR', Sweden is 'SE'.

Source countries to filter by (this is only for the publisher location, not the locations mentioned in articles. For Locations mentioned in articles, refer to entity_guarantee), countries must be the two-letter ISO country codeFor example: United States is 'US', France is 'FR', Sweden is 'SE'.

countries_blackliststring[] nullable

Source countries to blacklist from search (this is only for the publisher location, not the locations mentioned in articles. For Locations mentioned in articles, refer to reverse_entity_guarantee), countries must be the two-letter ISO country codeFor example: United States is 'US', France is 'FR', Sweden is 'SE'.

Source countries to blacklist from search (this is only for the publisher location, not the locations mentioned in articles. For Locations mentioned in articles, refer to reverse_entity_guarantee), countries must be the two-letter ISO country codeFor example: United States is 'US', France is 'FR', Sweden is 'SE'.

continentsstring[] nullable

Continents to filter by.

Continents to filter by.

sentiment'negative' | 'neutral' | 'positive' nullable

Sentiment to filter articles by.

Sentiment to filter articles by.

premiumboolean

Include premium sources.

Include premium sources.

authorsstring[] nullable

Authors to filter articles by.

Authors to filter articles by.

try_cache'1h' | '6h' | '12h' | '24h' | '3d' | '7d' nullable

Enable response caching with the specified TTL. When a cached response is returned, usage is charged at 0.25x the normal rate. Valid values: '1h' (1 hour), '6h' (6 hours), '12h' (12 hours), '24h' (24 hours), '3d' (3 days), '7d' (7 days).

Enable response caching with the specified TTL. When a cached response is returned, usage is charged at 0.25x the normal rate. Valid values: '1h' (1 hour), '6h' (6 hours), '12h' (12 hours), '24h' (24 hours), '3d' (3 days), '7d' (7 days).

geo_latnumber nullable

Latitude for geo-radius filter. Must be provided together with geo_lon and geo_radius. Filters articles whose coordinates fall within the specified circle.

Latitude for geo-radius filter. Must be provided together with geo_lon and geo_radius. Filters articles whose coordinates fall within the specified circle.

geo_lonnumber nullable

Longitude for geo-radius filter. Must be provided together with geo_lat and geo_radius.

Longitude for geo-radius filter. Must be provided together with geo_lat and geo_radius.

geo_radiusnumber nullable

Radius in meters for geo-radius filter. Must be provided together with geo_lat and geo_lon.

Radius in meters for geo-radius filter. Must be provided together with geo_lat and geo_lon.

geo_polygonstring nullable

JSON string defining a polygon for geo filtering. Must contain an 'exterior' key with a list of {lon, lat} points. The first and last point must be the same. Optionally include 'interiors' as a list of rings (each a list of {lon, lat} points) to exclude areas. Example: {"exterior": [{"lon": -70, "lat": -70}, {"lon": 60, "lat": -70}, {"lon": 60, "lat": 60}, {"lon": -70, "lat": 60}, {"lon": -70, "lat": -70}]}

JSON string defining a polygon for geo filtering. Must contain an 'exterior' key with a list of {lon, lat} points. The first and last point must be the same. Optionally include 'interiors' as a list of rings (each a list of {lon, lat} points) to exclude areas. Example: {"exterior": [{"lon": -70, "lat": -70}, {"lon": 60, "lat": -70}, {"lon": 60, "lat": 60}, {"lon": -70, "lat": 60}, {"lon": -70, "lat": -70}]}

Response

A string or a list of dictionaries

as_stringstring nullable

Changes

No recorded changes to this endpoint across all 1 revision of this API.