We’ve got big news: following on from AYLIEN’s acquisition by Quantexa in February, we are delighted to say that AYLIEN is now Quantexa News Intelligence. You may have noticed that the website and blog have been updated to reflect this rebranding, but that’s not the only development that has happened post-acquisition. We are also excited to announce a significant new product release that will improve Quantexa News API in several core areas, specifically: 

  1. New advanced search functionality — add more precision to your queries to find exactly the news that matters to your organization 
  2. Error handling and debugging — ensure that your queries are running as you intend them to, and pinpoint exactly where errors may be occurring 
  3. Improved query legibility — A more user friendly of writing and editing queries using flat parameters, combined with the power of AQL searchability  
  4. A new Autocomplete endpoint with improved sorting – a new version of our helper endpoint that is significantly more accurate when matching entities and sources 
  5. Enhanced security through bearer authentication – adhering to OAuth standards 

Note: In the code examples below, you will notice that the URL remains api.aylien.com.This will change to a Quantexa URL in March 2024.  

Note: All changes to News API are reflected in our updated technical documentation

1. New advanced search functionality 

Quantexa News API users can now create advanced Boolean logic between News API parameters and within nested objects (parameters with sub-fields). This advanced querying functionality can be applied across all fields, enabling new query patterns far beyond previous capabilities, which until this release only applied to Entities and Smart Tagger. For example, customers can now exclude stock news from queries by using Boolean operators. 

Another example of what is now possible is multilingual search, i.e. querying for specific text in articles of all languages. Let’s say that we want to search for the text ‘money laundering’ across all articles. The ‘text’ field applies to only the original language of the article, therefore the ‘translations’ field is also required to search for ‘money laundering’ as a translated piece of text in translated articles. In previous versions of the API it would not be possible to get the desired results because ‘AND’ logic automatically applies between each parameter, e.g.  

https://api.aylien.com/news/stories?text=("money laundering")&translations.en.body=("money laundering"&cursor=*&published_at.end=NOW&published_at.start=NOW-7DAYS/DAY' 

 

The above query doesn’t return the required results because the piece of text would need to appear as ‘money laundering’ in the original article and the translated article. As ‘money laundering’ is a predominantly English language term, it is likely that few articles (if any) will be returned, due to the conditions of the AND operator.  

This query is only made possible by using an ‘OR’ condition leveraging Quantexa News API's latest update, as follows:  

aql=(text:"money laundering") OR (translations.en.body:"money laundering")

 

2. Error handling and debugging 

An important improvement in the user experience of Quantexa News API is the inclusion of error handling and debugging, which was previously minimal. For example, basic syntax errors, such as misspelling a parameter name, did not return an error when submitted as a flat parameter. Instead, it ignored invalid user input and continued to execute the query, filtering by the other parameters.  

In this example, the query parameter 'source.location.country[]': ['US'] is wrong, as it is missing the ‘s’ in ‘locations’ — an easy mistake to make. In the previous version of the API, this mistake would not trigger an error even though it is misspelled. Without an error message, the user will not know that this parameter has been ignored unless they notice it when viewing the response, which is not always obvious if multiple parameters are being used.  

However, when the same query is parsed in Quantexa’s latest version of the News API, the following error message is returned, making the user aware that there has been an error, and making the debugging process straightforward:  

{'errors': [{'code': 'KB400', 'detail': 'Unsupported query parameter', 'id': 'stories_params_source.location.country', 'links': {'about': 'https://docs.aylien.com/newsapi/#error-codes-amp-responses ', 'docs': 'https://docs.aylien.com/newsapi '}, 'status': 400, 'title': 'Bad Request', 'type': 'http://httpstatus.es/400 '}]} 

 

3. Improved query legibility 

Quantexa News API utilizes its own Lucene-based query language, called AQL, which is required to create the powerful queries described in point 1 (above). In the previous version of the News API these AQL queries needed to be composed in a single string, which could become lengthy, especially when searching for lists of items such as entities or categories. These single strings are hard to read and debug, as demonstrated below: 

'aql': 'language:(en) AND entities:({{id:Q95 AND overall_prominence:>=0.65}} OR {{id:Q312 AND overall_prominence:>=0.65}} OR {{id:Q2283 AND overall_prominence:>=0.65}} OR {{id:Q355 AND overall_prominence:>=0.65}}) AND categories:({{taxonomy:aylien AND id:ay.impact.joint}} OR {{taxonomy:aylien AND id:ay.biz.manda}} OR {{taxonomy:aylien AND id:ay.impact.ops}} OR {{taxonomy:aylien AND id:ay.biz.regulat}}) AND source.name.keyword:("Techcrunch" OR "FinExtra")' 

That’s why we’ve created a more user-friendly way of composing queries, using flat parameters to break them up into snippets, improving legibility, debugging, and ease of writing, while providing the power of AQL’s searchability.  Here’s the same query from above written in the flat parameter (key-value pair) format: 

'language':'en', 

'entities': '{{id:Q95 AND overall_prominence:>0.65}} OR {{id:Q312 AND overall_prominence:>0.65}} OR {{id:Q2238 AND overall_prominence:>0.65}} OR {{id:Q355 AND overall_prominence:>0.65}} ', 

‘categories’:’{{taxonomy:aylien AND id:ay.impact.joint}} OR {{taxonomy:aylien AND id:ay.biz.manda}} OR {{taxonomy:aylien AND id:ay.impact.ops}} OR {{taxonomy:aylien AND id:ay.biz.regulat}}’ 

'source.name' : '("Techcrunch" OR "FinExtra")' 

 

4. Improved entity and source sorting with Autocomplete v2 

The final upgrade in this release is an entirely new version of the Autocomplete endpoint. Autocomplete v2 is a helper endpoint to search for entities and sources in the Quantexa News API database. The previous version of Autocomplete needed updating due to limitations with its sorting algorithm. V2 significantly improves sorting results, so that the top result is most likely the entity or source that you are looking for. For further accuracy, v2 enables you to input an entity type (e.g. organization, person etc), and the output includes additional metadata (description and entity type) for further disambiguation. The improvement of this endpoint is especially helpful when bulk matching entities and sources. Below is an example response: 

 



"items":[ 
{ 
"id":"Q312", 

"text":"Apple Inc.", 

"description":"Apple Inc.", 

"Types":[ 

{ 

"id":"Q43229", 

"names":"organization" 

}, 

{ 

"id":"Q4830453", 

"Names":"business" 

}, 

{ 

"id":"Q783794", 

"Names":"company" 

} 

], 

"Weight":17087, 

"href":"https://api.aylien.com/v1/entity-manager/entities/Q312" 

}, 

 

5. Enhanced security through bearer authentication 

At Quantexa we take security extremely seriously. That’s why Quantexa News API has upgraded its user authentication method, adhering to API standards, including OAuth. The previous method consisted of passing your app ID and API key, like in the example below: 

headers = { 

    'X-Application-ID': 'xxxxxxx', 

    'X-Application-Key': 'xxxxxxxxxxxx'} 

  response = requests.request("GET", url, headers=headers, data = payload) 

The new method requires a username and password combination to generate a bearer token, providing greater security for user accounts and API keys. See the example below for how it works: 

#Provide your username and password to authenticate request 

Username = "username" 

Password = "password" 

  

#Call the oauth endpoint to generate a bearer token 

token = requests.post("https://api.aylien.com/v1/oauth 

/token",auth=(username,password),data={"grant_type”:"password"}).json()["access_token"] 

  

#Pass the token and app id as headers to the request 

Headers = {f"Authorization":"Bearer {}".format( 

token),"AppId":"APP-ID"} 

For further information on how to utilize all of these new aspects of this release, please refer to the Quantexa News API technical documentation.  

Sign up for a free 14 day trial of Quantexa News API now and see for yourself why it is the world leader in AI-powered news intelligence platforms.  

Stay Informed

From time to time, we would like to contact you about our products and services via email.