Last active
October 2, 2018 18:33
-
-
Save ekollof/47e3f3f54f2aee5ab1b512d6222bf292 to your computer and use it in GitHub Desktop.
Example getting stats from mastodon
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3.7 | |
import sys | |
from mastodon import Mastodon | |
from pprint import pprint | |
from urllib.parse import urlparse | |
def main(): | |
host = urlparse(sys.argv[1]) | |
Mastodon.create_app( | |
'maststats', | |
api_base_url = sys.argv[1], | |
to_file = f"{host.netloc}.secret" | |
) | |
mastodon = Mastodon( | |
client_id = f'{host.netloc}.secret', | |
api_base_url = sys.argv[1] | |
) | |
instance = mastodon.instance() | |
pprint(instance) | |
activity = mastodon.instance_activity()[0] | |
pprint(activity) | |
if __name__ == "__main__": | |
main() |
Against a bigger instance ;)
./getstats.py https://mastodon.social
{'contact_account': {'acct': 'Gargron',
'avatar': 'https://files.mastodon.social/accounts/avatars/000/000/001/original/ba7cb4a53cf22d9a.png',
'avatar_static': 'https://files.mastodon.social/accounts/avatars/000/000/001/original/ba7cb4a53cf22d9a.png',
'bot': False,
'created_at': datetime.datetime(2016, 3, 16, 14, 34, 26, 392000, tzinfo=tzutc()),
'display_name': 'Eugenio',
'emojis': [],
'fields': [{'name': 'Patreon',
'value': '<a '
'href="https://www.patreon.com/mastodon" '
'rel="me nofollow noopener" '
'target="_blank"><span '
'class="invisible">https://www.</span><span '
'class="">patreon.com/mastodon</span><span '
'class="invisible"></span></a>',
'verified_at': None},
{'name': 'E-mail',
'value': '[email protected]'},
{'name': 'Avatar by',
'value': '<span class="h-card"><a '
'href="https://mastodon.art/@DearMsDear" '
'class="u-url '
'mention">@<span>DearMsDear</span></a></span>'}],
'followers_count': 154387,
'following_count': 497,
'header': 'https://files.mastodon.social/accounts/headers/000/000/001/original/998815725e9554b0.jpg',
'header_static': 'https://files.mastodon.social/accounts/headers/000/000/001/original/998815725e9554b0.jpg',
'id': 1,
'locked': False,
'note': '<p>Developer of Mastodon. 25</p>',
'statuses_count': 44211,
'url': 'https://mastodon.social/@Gargron',
'username': 'Gargron'},
'description': 'This page describes the mastodon.social <em>instance</em> - '
'wondering what Mastodon is? Check out <a '
'href="https://joinmastodon.org">joinmastodon.org</a> instead! '
'In essence, Mastodon is a decentralized, open source social '
'network. This is just one part of the network, run by the '
'main developers of the project <img draggable="false" alt="" '
'class="emojione" '
'src="https://mastodon.social/emoji/1f418.svg" /> It is not '
'focused on any particular niche interest - everyone is '
'welcome as long as you follow our code of conduct!</p><p>Hero '
'image by <a href="https://mastodon.social/@b_cavello" '
'class="u-url mention">@<span>b_cavello</span></a>',
'email': '[email protected]',
'languages': ['en'],
'stats': {'domain_count': 6612, 'status_count': 8575351, 'user_count': 242543},
'thumbnail': 'https://files.mastodon.social/site_uploads/files/000/000/001/original/DN5wMUeVQAENPwp.jpg_large.jpeg',
'title': 'Mastodon',
'uri': 'mastodon.social',
'urls': {'streaming_api': 'wss://mastodon.social'},
'version': '2.5.0'}
{'logins': 11668,
'registrations': 2051,
'statuses': 48038,
'week': datetime.datetime(2018, 9, 30, 22, 0, tzinfo=<UTC>)}
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
From my own instance: