aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLorenz Diener <[email protected]>2019-10-12 20:51:29 +0200
committerLorenz Diener <[email protected]>2019-10-12 20:51:29 +0200
commit2e5095f301c62c73f6b839bbbffeda14ab8cd797 (patch)
tree4eceb70b7cbdd3ebd24ab724b1e61cf5f168deee /mastodon/Mastodon.py
parente60a3f1892bb685fcbe6ebbc9ed10602c9549028 (diff)
downloadmastodon.py-2e5095f301c62c73f6b839bbbffeda14ab8cd797.tar.gz
Add, document and test nodeinfo api (fixes #199)
Diffstat (limited to 'mastodon/Mastodon.py')
-rw-r--r--mastodon/Mastodon.py30
1 files changed, 29 insertions, 1 deletions
diff --git a/mastodon/Mastodon.py b/mastodon/Mastodon.py
index f0063e5..1561fa1 100644
--- a/mastodon/Mastodon.py
+++ b/mastodon/Mastodon.py
@@ -660,7 +660,35 @@ class Mastodon:
660 Basic health check. Returns True if healthy, False if not. 660 Basic health check. Returns True if healthy, False if not.
661 """ 661 """
662 return self.__api_request('GET', '/health', parse=False).decode("utf-8") == "success" 662 return self.__api_request('GET', '/health', parse=False).decode("utf-8") == "success"
663 663
664 @api_version("3.0.0", "3.0.0", "3.0.0")
665 def instance_nodeinfo(self, schema = "http://nodeinfo.diaspora.software/ns/schema/2.0"):
666 """
667 Retrieves the instances nodeinfo information.
668
669 For information on what the nodeinfo can contain, see the nodeinfo
670 specification: https://github.com/jhass/nodeinfo . By default,
671 Mastodon.py will try to retrieve the version 2.0 schema nodeinfo.
672
673 To override the schema, specify the desired schema with the `schema`
674 parameter.
675 """
676 links = self.__api_request('GET', '/.well-known/nodeinfo')["links"]
677
678 schema_url = None
679 for available_schema in links:
680 if available_schema.rel == schema:
681 schema_url = available_schema.href
682
683 if schema_url is None:
684 raise MastodonIllegalArgumentError("Requested nodeinfo schema is not available.")
685
686 try:
687 return self.__api_request('GET', schema_url, base_url_override="")
688 except MastodonNotFoundError:
689 parse = urlparse(schema_url)
690 return self.__api_request('GET', parse.path + parse.params + parse.query + parse.fragment)
691
664 ### 692 ###
665 # Reading data: Timelines 693 # Reading data: Timelines
666 ## 694 ##
Powered by cgit v1.2.3 (git 2.41.0)