Connectors

Most of the popular social media services have APIs (application programming interfaces). Using them, one could collect a lot of interesting research data. But there are some difficulties. Every API has its own request endpoints, syntax, response format, rate limits, etc. If you are dealing with more than one social media source - you constantly have to switch between these API-languages. Moreover, if you want to compare multiple networks, first you have to "similarify" your data from different sources.

The main purpose of connectors - is to build a high-level meta-API wrapper, and to bring to network data required similarity. There is no need to care about how alike concepts are called in different networks (i.e. "tweet" in Twitter, "status" in Facebook, or "post" in Livejournal), and what exactly endpoints you should use. Also connectors keep track of rate limits and handle errors and exceptions.

Connectors output standardized pieces of data, that could be used "as is", or processed to more complex models, or saved in suitable form using exporters.

Aviable connectors and time rates for base data pieces

Every connector is a class, that inherits from smapy.connectors.base.BaseConnector(). This is done for maximal similarity. The only pieces, implemented individually in every conncetor concern low-level API interactions.

class propierty .profiles() .statuses() .comments()
smapy.connectors.Facebook() 50 750 2500
smapy.connectors.Twitter() 1000 1000 1000
smapy.connectors.GooglePlus() 100 1000 2000
smapy.connectors.YouTube() 50 400 700
smapy.connectors.Instagram() 100 500 2000
smapy.connectors.LiveJournal() 30 10 40
smapy.connectors.VKontakte() 50 3000 5000
smapy.connectors.Odnoklassniki() - - -

* Time costs evaluated in average number of collected instances per 1 minute.

smapy.Connection(net) class

Every connector could be imported from smapy.connectors package. I.e.:

>>> from smapy.connectors import LiveJournal
>>> lj_stat = LiveJournal()
>>> lj_stat.accounts = 'drugoi'
>>> lj_stat.profiles()
{'drugoi': {'followers': 78984,
            'id': 'drugoi',
            'link': 'http://users.livejournal.com/drugoi/',
            'name': u'Журнал Другого',
            'nickname': 'drugoi',
            'statuses': u'14519',
            'type': 'person'}}

But when you often switch between multiple connectors - it's easier to use universal Connection(net) class. This class returns initialised connector to social media channel, specified using net parameter. net - is a two-letter abbreviation, unique for every registered in smapy.CONNECTORS connector. The above example with the same result, using Connection(net) class:

>>> from smapy import Connection
>>> lj_stat = Connection('lj')
>>> lj_stat.accounts = 'drugoi'
>>> lj_stat.profiles()
{'drugoi': {'followers': 78984,
            'id': 'drugoi',
            'link': 'http://users.livejournal.com/drugoi/',
            'name': u'Журнал Другого',
            'nickname': 'drugoi',
            'statuses': u'14519',
            'type': 'person'}}

List of avaliable connectors (already registered) with two-letter abbreviation (.Connector().network property):

Network .Connector().network .Connector().name
Twitter tw Twitter
Facebook fb Facebook
GooglePlus gp Google+
Instagram ig Instagram
LiveJournal lj LiveJournal
VKontakte vk ВКонтакте
YouTube yt YouTube
Odnoklassniki ok Одноклассники

Documentation

Every connector is to be unified with others. So there are quite a few differences between them, and that differences concern optional parameters. So here abstract connector will be described. IRL substitute smapy.connectors.Connector() with appropriate connector (i.e., smapy.connectors.Twitter(), smapy.connectors.Facebook()) or smapy.Connection(net) object.

Public properties

Public methods

Other

Some of described functions has specific optional parameters. Most of them concern concrete media platforms. Find out more about connectors you are interested in:

Besides this, every connector has a bunch of "hidden" properties and functions. Find out more about them on writing your own connector page.