Search code examples
ibm-cloudibm-watsonalchemyapi

I can get Alchemy Data News results with entities or keywords, but not both


I'm trying to search and retrieve news articles on Alchemy Data News. I can get results using entities:

https://access.alchemyapi.com/calls/data/GetNews?apikey=[redacted]&outputMode=json&start=now-60d&end=now-0d&maxResults=10&return=enriched.url.title,enriched.url.url,enriched.url.entities,enriched.url.concepts&q.enriched.url.entities.entity=|text=Neil%20Tyson,type=Person|

and I can get results using keywords:

https://access.alchemyapi.com/calls/data/GetNews?apikey=[redacted]&outputMode=json&start=now-60d&end=now-0d&maxResults=10&return=enriched.url.title,enriched.url.url,enriched.url.entities,enriched.url.concepts&q.enriched.url.enrichedTitle.keywords.keyword.text=solar%20System

but if I combine the two I just get results that say "OK":

https://access.alchemyapi.com/calls/data/GetNews?apikey=[redacted]&outputMode=json&start=now-60d&end=now-0d&maxResults=10&return=enriched.url.title,enriched.url.url,enriched.url.entities,enriched.url.concepts&q.enriched.url.enrichedTitle.keywords.keyword.text=solar%20System&q.enriched.url.entities.entity=|text=Neil%20Tyson,type=Person|

{
"status": "OK",
"usage": "By accessing AlchemyAPI or using information generated by AlchemyAPI, you are agreeing to be bound by the AlchemyAPI Terms of Use: http://www.alchemyapi.com/company/terms.html",
"totalTransactions": "4320",
"result": {
    "status": "OK"
}

with no docs. Is this supposed to work, or am I barking up the wrong tree?


Solution

  • The problem is you've created a query with 0 results. If you remove the &return portion of the query the response will include only a count. You can also add &timeSlice to see results by time bucket (more on counts and time slice here). Running your combined query with a monthly time slice (&timeSlice=1M) returns:

    "status": "OK",
    "totalTransactions": "4322",
    "result": {
        "count": 0,
        "slices": [
            0,
            0
        ],
        "status": "OK"
        }
    

    An example of the combining entity and and concept with many recent/topical response (at least during Feb 2016) is replaceing Solar System with B.o.B:

    https://access.alchemyapi.com/calls/data/GetNews?outputMode=json&start=now-60d&end=now-0d&maxResults=10&return=enriched.url.title&enriched.url.url&enriched.url.entities&enriched.url.concepts&q.enriched.url.entities.entity.text=Neil+Tyson&type=Person&q.enriched.url.enrichedTitle.keywords.keyword.text=B.o.B&apikey=<YOUR API  KEY>
    

    and that's where the focus of this service is, querying and helping identify trends in recent news.