Skip to content
Gregor Leban edited this page Jun 23, 2023 · 12 revisions

Shares of articles/events on social media

In Event Registry, we also store information about how many times an individual article has been shared on social networks, such as Facebook and LinkedIn, Google Plus and others. When requesting article information, you can set the socialScore = True flag in ArticleInfoFlags and the resulting articles will contain information about the number of shares of the article.

An example where articles about Apple with the most shares on social media would be:

from eventregistry import *
er = EventRegistry(apiKey = YOUR_API_KEY)
q = QueryArticles(conceptUri = er.getConceptUri("Apple"))
q.setRequestedResult(RequestArticlesInfo(
    count = 5,
    sortBy = "socialScore",
    returnInfo = ReturnInfo(
        articleInfo = ArticleInfoFlags(socialScore = True))))
ret = er.execQuery(q)

The results in ret are partially shown below. The shares on Facebook and Twitter are shown in the shares object.

{
    "articles": {
        "results": [
            {
                "uri": "244825036",
                "title": "Introducing the Leap Motion - YouTube",
                "shares": {
                    "facebook": 72432,
                    "twitter": 1187
                },
                // remaining article properties (see Article data model)
            },
            {
                "uri": "261446268",
                "title": "Will the Second Generation Apple Watch Have This Amazing New Feature?",
                "shares": {
                    "facebook": 4,
                    "twitter": 44576
                },
                // ...
            }
        ],
    ...
    }
}

Based on the shares of the articles in social media we also compute a social score for events. A social score of an event is computed by selecting all articles assigned to the event and sorting them by decreasing social score. Maximum top 30 articles are then selected and an average social score of them is computed and used as the event's social score.

A similar example is illustrated below. Now we search for events about Apple and request to get also the socialScore property.

q = QueryEvents(conceptUri = er.getConceptUri("Apple"))
q.setRequestedResult(RequestEventsInfo(
    count = 5,
    sortBy = "socialScore",
    returnInfo = ReturnInfo(
        eventInfo = EventInfoFlags(socialScore = True))))
ret = er.execQuery(q)

Part of the result of the query can be seen below. The social score of the event is stored in the socialScore property.

{
    "events": {
        "resultCount": 58484,
        "results": [
            {
                "uri": "2381731",
                "title": {
                    "eng": "New Indiana 'Religious Liberty' Law Could Legalize Discrimination Against Gay People, Opponents Say"
                },
                "socialScore": 1835.824,
            },
            // remaining event properties (see Event data model)
        ]
    }
}

Most shared articles on a given date

Since we store information about the social scores of the articles, we are also able to provide the user with a list of top shared articles on any given day. This functionality is provided by the GetTopSharedArticles() class. An example of the use would be:

from eventregistry import *
er = EventRegistry(apiKey = YOUR_API_KEY)
q = GetTopSharedArticles(date = "2015-05-23", count = 30)
ret = er.execQuery(q)

ret would, in this case, contain a list of 30 articles that have the highest social score.

Most shared events on a given date

As for the articles, we can provide the same functionality also for events. For any given date, the user can obtain the list of events that have the highest socialScore value. This list will, therefore, contain events for which the articles were shared the most. The class that provides this functionality is called GetTopSharedEvents and can be used as follows:

from eventregistry import *
er = EventRegistry(apiKey = YOUR_API_KEY)
q = GetTopSharedEvents(date = "2015-05-23", count = 30)
ret = er.execQuery(q)