From b5f722cd3d33ecde307ae09b8450cfbbe622cfe4 Mon Sep 17 00:00:00 2001 From: Lorenz Diener Date: Mon, 30 Jul 2018 15:44:09 +0200 Subject: [PATCH] Add trendint API --- mastodon/Mastodon.py | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/mastodon/Mastodon.py b/mastodon/Mastodon.py index 7c16e5c..58380fd 100644 --- a/mastodon/Mastodon.py +++ b/mastodon/Mastodon.py @@ -160,7 +160,7 @@ class Mastodon: __DICT_VERSION_STATUS = bigger_version(bigger_version(bigger_version(bigger_version("2.1.0", __DICT_VERSION_MEDIA), __DICT_VERSION_ACCOUNT), __DICT_VERSION_APPLICATION), __DICT_VERSION_MENTION) __DICT_VERSION_INSTANCE = bigger_version("2.3.0", __DICT_VERSION_ACCOUNT) - __DICT_VERSION_HASHTAG = "1.0.0" + __DICT_VERSION_HASHTAG = "2.3.4" __DICT_VERSION_EMOJI = "2.1.0" __DICT_VERSION_RELATIONSHIP = "2.4.3" __DICT_VERSION_NOTIFICATION = bigger_version(bigger_version("1.0.0", __DICT_VERSION_ACCOUNT), __DICT_VERSION_STATUS) @@ -852,13 +852,26 @@ class Mastodon: def search_v2(self, q, resolve=False): """ Identical to `search()`, except in that it returns tags as - `tag dicts`_. + `hashtag dicts`_. Returns a `search result dict`_. """ params = self.__generate_params(locals()) return self.__api_request('GET', '/api/v2/search', params) + ### + # Reading data: Trends + ### + @api_version("2.4.3", "2.4.3", __DICT_VERSION_HASHTAG) + def trends(self): + """ + Fetch trending-hashtag information, if the instance provides such information. + + Returns a list of `hashtag dicts`_, sorted by the instances trending algorithm, + descending. + """ + return self.__api_request('GET', '/api/v1/trends') + ### # Reading data: Lists ###