diff options
Diffstat (limited to 'mastodon/trends.py')
-rw-r--r-- | mastodon/trends.py | 72 |
1 files changed, 72 insertions, 0 deletions
diff --git a/mastodon/trends.py b/mastodon/trends.py new file mode 100644 index 0000000..09a0ae5 --- /dev/null +++ b/mastodon/trends.py | |||
@@ -0,0 +1,72 @@ | |||
1 | # trends.py - trend-related endpoints | ||
2 | |||
3 | from .versions import _DICT_VERSION_HASHTAG, _DICT_VERSION_STATUS, _DICT_VERSION_CARD | ||
4 | from .utility import api_version | ||
5 | |||
6 | from .internals import Mastodon as Internals | ||
7 | |||
8 | class Mastodon(Internals): | ||
9 | ### | ||
10 | # Reading data: Trends | ||
11 | ### | ||
12 | @api_version("2.4.3", "3.5.0", _DICT_VERSION_HASHTAG) | ||
13 | def trends(self, limit=None): | ||
14 | """ | ||
15 | Alias for :ref:`trending_tags() <trending_tags()>` | ||
16 | """ | ||
17 | return self.trending_tags(limit=limit) | ||
18 | |||
19 | @api_version("3.5.0", "3.5.0", _DICT_VERSION_HASHTAG) | ||
20 | def trending_tags(self, limit=None, lang=None): | ||
21 | """ | ||
22 | Fetch trending-hashtag information, if the instance provides such information. | ||
23 | |||
24 | Specify `limit` to limit how many results are returned (the maximum number | ||
25 | of results is 10, the endpoint is not paginated). | ||
26 | |||
27 | Does not require authentication unless locked down by the administrator. | ||
28 | |||
29 | Important versioning note: This endpoint does not exist for Mastodon versions | ||
30 | between 2.8.0 (inclusive) and 3.0.0 (exclusive). | ||
31 | |||
32 | Pass `lang` to override the global locale parameter, which may affect trend ordering. | ||
33 | |||
34 | Returns a list of :ref:`hashtag dicts <hashtag dicts>`, sorted by the instance's trending algorithm, | ||
35 | descending. | ||
36 | """ | ||
37 | params = self.__generate_params(locals()) | ||
38 | if self.verify_minimum_version("3.5.0", cached=True): | ||
39 | # Starting 3.5.0, old version is deprecated | ||
40 | return self.__api_request('GET', '/api/v1/trends/tags', params) | ||
41 | else: | ||
42 | return self.__api_request('GET', '/api/v1/trends', params) | ||
43 | |||
44 | @api_version("3.5.0", "3.5.0", _DICT_VERSION_STATUS) | ||
45 | def trending_statuses(self): | ||
46 | """ | ||
47 | Fetch trending-status information, if the instance provides such information. | ||
48 | |||
49 | Specify `limit` to limit how many results are returned (the maximum number | ||
50 | of results is 10, the endpoint is not paginated). | ||
51 | |||
52 | Pass `lang` to override the global locale parameter, which may affect trend ordering. | ||
53 | |||
54 | Returns a list of :ref:`status dicts <status dicts>`, sorted by the instances's trending algorithm, | ||
55 | descending. | ||
56 | """ | ||
57 | params = self.__generate_params(locals()) | ||
58 | return self.__api_request('GET', '/api/v1/trends/statuses', params) | ||
59 | |||
60 | @api_version("3.5.0", "3.5.0", _DICT_VERSION_CARD) | ||
61 | def trending_links(self): | ||
62 | """ | ||
63 | Fetch trending-link information, if the instance provides such information. | ||
64 | |||
65 | Specify `limit` to limit how many results are returned (the maximum number | ||
66 | of results is 10, the endpoint is not paginated). | ||
67 | |||
68 | Returns a list of :ref:`card dicts <card dicts>`, sorted by the instances's trending algorithm, | ||
69 | descending. | ||
70 | """ | ||
71 | params = self.__generate_params(locals()) | ||
72 | return self.__api_request('GET', '/api/v1/trends/links', params) | ||