New to Busy?

Exploring new Hivemind Community APIs

10 comments

emrebeyler
74
last monthSteemit3 min read

Steemit Beta is running for a while, hosting the new communities UI, powered by Hivemind in the backend. There is a new set of API endpoints available.


It's possible to use these endpoints with Lightsteem in a simple way to explore the API methods. (No updates needed thanks to Lightsteem's dynamic request model)

First step, getting a Client instance


from lightsteem.client import Client

c = Client(nodes=["https://beta-api.steemit.com/"])

Get community details


c('bridge').get_community({"name": "hive-129924", "observer": "emrebeyler"})

Example Output:

{
    'id': 1352979,
    'name': 'hive-129924',
    'title': 'Python',
    'about': 'news, questions, notes, tutorials about the Python programming language',
    'lang': 'en',
    'type_id': 1,
    'is_nsfw': False,
    'subscribers': 31,
    'sum_pending': 28,
    'num_pending': 16,
    'num_authors': 9,
    'created_at': '2020-01-04 09:11:06',
    'context': {
        'role': 'admin',
        'title': '',
        'subscribed': True
    },
    'description': '',
    'flag_text': '',
    'settings': {},
    'team': [
        ['hive-129924', 'owner', ''],
        ['emrebeyler', 'admin', ''],
        ['crokkon', 'mod', 'Expert']
    ]
}

List communities


c('bridge').list_communities({"limit": 1})

List all communities and limit the results to 1. (It's possible to paginate the results with optional last argument.)

Example output:


[{
    'id': 1337319,
    'name': 'hive-100421',
    'title': 'Threespeak',
    'about': '3Speak is a video platform for deplatformed and censored content creators.',
    'lang': 'en',
    'type_id': 1,
    'is_nsfw': False,
    'subscribers': 810,
    'sum_pending': 2770,
    'num_pending': 1912,
    'num_authors': 461,
    'created_at': '2019-11-14 19:51:54',
    'context': {}
}]

List community roles


c('bridge').list_community_roles({"community": "hive-129924"})

Example output:


[
    ['hive-129924', 'owner', ''],
    ['emrebeyler', 'admin', ''],
    ['crokkon', 'mod', 'Expert']
]

List subscribers of a community


 c('bridge').list_subscribers({"community": "hive-129924"})

Example output:


[
    ['cardboard', 'guest', None, '2020-01-05 01:17:51'],
    ['anthonyadavisii', 'guest', None, '2020-01-05 01:11:03'],
    ['mytechtrail', 'guest', None, '2020-01-05 00:52:39'],
    ['louis88', 'guest', None, '2020-01-05 00:50:18'],
    ['dalz', 'guest', '', '2020-01-05 00:45:21'],
    ['emrebeyler', 'admin', '', '2020-01-04 09:11:15'],
    ...
]

List subscriptions of an account


c('bridge').list_all_subscriptions({"account": "emrebeyler"})

Example output:


[
    ['hive-129924', 'Python'],
    ['hive-174578', 'OCD'],
    ['hive-167922', 'SteemLeo'],
    ['hive-136578', 'Steem Think Tank'],
    ['hive-177976', 'DCooperation'],
    ['hive-122359', 'Community Announce'],
    ['hive-185247', 'Open Source']
]

Creating and managing communities

All these transactions are actually Custom JSON transactions. This module will give an insight. Once things go out of the beta, I'll release a helper module in Lightsteem to make things easier.

Note

These API signatures may subject the change. GIT repository is a good place to track the changes if you're interested.

Vote for my witness

If you didn't vote already, consider casting a vote for my witness on Steemconnect or on Steemit

Python community

This is originally posted on Python community in Steemit Beta. Check it out and subscribe if you're interested in Python related content.

Comments

Sort byBest