hhmx.de

Leon Cowle

Leon Cowle (@leoncowle@hachyderm.io)

Föderation EN Do 25.01.2024 17:05:46

@kellogh @andypiper I've used this one before in some of my playing.

>>> import requests
>>> apikey=ā€˜<redacted -- get one on instances.social>ā€™
>>> r = requests.get("instances.social/api/1.0/insta", headers={'Authorization':f'Bearer {apikey}'}).json()
>>> len(r['instances'])
17422
>>> r['instances'][250]['name']
's.ovalerio.net'
>>> r['instances'][250]['up']
True
>>> r['instances'][250]['dead']
False

(Full path that is possibly truncated above [by Mastodon] is: /api/1.0/instances/list?count=0]

Tim Kellogg

Tim Kellogg (@kellogh@hachyderm.io)

Föderation EN Do 25.01.2024 17:08:38

@leoncowle @andypiper good idea! iā€™m on a relatively big instance too

Leon Cowle

Leon Cowle (@leoncowle@hachyderm.io)

Föderation EN Do 25.01.2024 17:11:32

@kellogh @andypiper No, that doesn't work on your instance -- you have to use instances.social. I'm not sure, but I think instances.social is a specific service, not a Mastodon instance.

Andy Piper

Andy Piper (@andypiper@macaw.social)

Föderation EN Do 25.01.2024 17:12:06

@leoncowle @kellogh yeah I was going to suggest instances.social, and I also believe it is a specific thing.

Tim Kellogg

Tim Kellogg (@kellogh@hachyderm.io)

Föderation EN Do 25.01.2024 17:35:40

@andypiper @leoncowle omg i should've just let CoPilot guide me through it. This is all AI generated code...

def list_instances(search_term: str | None = None) -> list[dict[str, str]]:
    """
    List instances from the instances.social API.

    :param search_term: A search term to filter instances by.
    :return: A list of instances.
    """
    url = "https://instances.social/api/1.0/instances/list"
    params = {}
    if search_term:
        params["search"] = search_term

(Medien: 1)