Skip to content

Get Article Information

Gregor Leban edited this page Jun 23, 2023 · 8 revisions

When you want to find details about a specific article you can use the QueryArticle class.

An example use of the QueryArticle() class to obtain details about the article with URI 247634888 would be:

from eventregistry import *
er = EventRegistry(apiKey = YOUR_API_KEY)
q = QueryArticle("247634888")
# get core article information
q.addRequestedResult(RequestArticleInfo())
res = er.execQuery(q)

The resulting JSON object contained in res will contain:

{
    "247634888": {
        "info": {
            "lang": "por",
            "body": "...",
            "title": "...",
            "url": "...",
            "uri": "...",
            "eventUri": "...",
            "time": "...",
            "date": "...",
            // other properties of the article (see Article data model)
        }
    }
}

The returned information about the article follows the Article data model.

QueryArticle

QueryArticle constructor accepts a single argument articleUriOrUriList:

QueryArticle(articleUriOrUriList)

The articleUriOrUriList can be a string representing a single article URI (newsfeed ID) or it can be a list of article URIs (at most 200).

Methods

The article URIs are provided as results of some queries, such as RequestEventArticleUris() result in the QueryEvent(). In some cases we would simply like to iterate over some larger set of articles and in this cases, a possible solution is also to use a static method queryById. Article IDs in Event Registry start at 0 and end at the current number of imported news articles (which can be seen in the statistics table on ER Homepage). To get information about the first 200 Event Registry articles, one can use the following constructor for QueryArticle():

q = QueryArticle.queryById(range(200))

Returned information

QueryArticle class provides a method addRequestedResult() that can be used to specify which details about the article you wish to obtain. The argument in the method call has to be an instance that has a base class RequestArticle. Below are the classes that can be specified in the addRequestedResult calls:

RequestArticleInfo

RequestArticleInfo(returnInfo = ReturnInfo())

RequestArticleInfo class can provide the available information about the article - the title, body, date, concepts, event membership, ...

  • returnInfo: sets the properties of various types of data that should be returned about the article (concepts, categories, news source, ...)

RequestArticleSimilarArticles

RequestArticleSimilarArticles(page = 1,
    count = 20,
    lang = ["eng"],
    limitPerLang = -1,
    returnInfo = ReturnInfo())

RequestArticleSimilarArticles returns a list of similar articles according to the CCA similarity.

  • page: which page of the similar articles to return (starting from 1).
  • count: number of similar articles to return (max 200).
  • lang: languages in which should be the returned similar articles.
  • limitPerLang: is there a maximum number of articles that we should return for each language.
  • returnInfo: sets the properties of various types of data that is returned (articles, concepts, categories, news sources, ...)

RequestArticleDuplicatedArticles

RequestArticleDuplicatedArticles(page = 1,
    count = 20,
    returnInfo = ReturnInfo(articleInfo = ArticleInfoFlags(bodyLen = -1))):

RequestArticleDuplicatedArticles returns a list of article that are duplicates of the specified article..

  • page: which page of the duplicated articles to return (starting from 1).
  • count: number of duplicated articles to return (max 200).
  • returnInfo: sets the properties of various types of data that is returned (articles, concepts, categories, news sources, ...)