A Python snippet to fetch all communities

in #hive2 years ago

For a project, I needed to fetch all communities' data to create a map between the weird tag names (hive-XXXXXX) and the human-readable community titles.

This Python snippet creates exactly this data structure:

from lighthive.client import Client

def get_all_communities(last=None, limit=100, community_list=None):
    if not community_list:
        community_list = []

    c = Client()
    communities = c('bridge').list_communities({"limit": limit, "last": last})
    community_list += communities

    if communities:
        return get_all_communities(

    return community_list

if __name__ == '__main__':

    all_communities = get_all_communities()
    print(len(all_communities), "communities found")

    tag_name_map = {c["name"]: c["title"] for c in all_communities}

P.S: Looks like we have 1497 valid communities created so far. 😲


Türkçe diliyle programlama dili kursu veriyor musun?

Coin Marketplace

STEEM 0.22
TRX 0.07
JST 0.030
BTC 21040.78
ETH 1204.81
USDT 1.00
SBD 3.18