Search code examples
ibm-watsonalchemyapi

Alchemy News Excerpts


We are formatting and presenting Alchemy Data News query results for our users. I think I see other demos that do this (e.g. Watson News Explorer) and they display a small excerpt from each article. I don't see any excerpts returned by Alchemy Data News API. Are we missing something in our query? How can we display an excerpt of the news story for our users?


Solution

  • You can retrieve a text sample using return=enriched.url.text

    See a full list of parameters here

    https://docs.google.com/spreadsheets/d/1wN0e_fhYCO7GBAneN9xjrNo57OtS_0Tr8FI9xCMfmzM/edit#gid=0

    for example

    https://gateway-a.watsonplatform.net/calls/data/GetNews?apikey=****
      &outputMode=json&start=now-1d&end=now&count=100
      &q.enriched.url.enrichedTitle.relations.relation
      =|action.verb.text=acquire,object.entities.entity.type=Company|
      &return=enriched.url.text
    

    will return

    {
        "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": "148",
        "result": {
            "docs": [
                {
                    "id": "NzI0MTkzMTM0N3wxNDY0OTYzMzY2",
                    "source": {
                        "enriched": {
                            "url": {
                                "text": "We've heard all year that fighting
                                 the opioid crisis is the most important issue facing the New Hampshire
                                 Legislature. Executive Councilor Colin Van Ostern is required by law to
                                 file a report on his gubernatorial campaign's receipts and expenditures by
                                 June 22. ..."
                            }
                        }
                    },
                    "timestamp": 1464963366
                },(...)
    

    ps. I am using Alchemy API for Bluemix