2022-11-30 23:39:08 +00:00
|
|
|
# trends.py - trend-related endpoints
|
|
|
|
|
|
|
|
from .versions import _DICT_VERSION_HASHTAG, _DICT_VERSION_STATUS, _DICT_VERSION_CARD
|
|
|
|
from .utility import api_version
|
|
|
|
|
|
|
|
from .internals import Mastodon as Internals
|
|
|
|
|
2023-01-02 13:39:16 +00:00
|
|
|
|
2022-11-30 23:39:08 +00:00
|
|
|
class Mastodon(Internals):
|
|
|
|
###
|
|
|
|
# Reading data: Trends
|
|
|
|
###
|
|
|
|
@api_version("2.4.3", "3.5.0", _DICT_VERSION_HASHTAG)
|
|
|
|
def trends(self, limit=None):
|
|
|
|
"""
|
2023-04-23 16:41:57 +00:00
|
|
|
Old alias for :ref:`trending_tags() <trending_tags()>`
|
|
|
|
|
|
|
|
Deprecated. Please use :ref:`trending_tags() <trending_tags()>` instead.
|
2022-11-30 23:39:08 +00:00
|
|
|
"""
|
2023-01-02 13:39:16 +00:00
|
|
|
return self.trending_tags(limit=limit)
|
2022-11-30 23:39:08 +00:00
|
|
|
|
|
|
|
@api_version("3.5.0", "3.5.0", _DICT_VERSION_HASHTAG)
|
|
|
|
def trending_tags(self, limit=None, lang=None):
|
|
|
|
"""
|
|
|
|
Fetch trending-hashtag information, if the instance provides such information.
|
|
|
|
|
|
|
|
Specify `limit` to limit how many results are returned (the maximum number
|
|
|
|
of results is 10, the endpoint is not paginated).
|
|
|
|
|
|
|
|
Does not require authentication unless locked down by the administrator.
|
|
|
|
|
|
|
|
Important versioning note: This endpoint does not exist for Mastodon versions
|
2023-01-02 13:39:16 +00:00
|
|
|
between 2.8.0 (inclusive) and 3.0.0 (exclusive).
|
2022-11-30 23:39:08 +00:00
|
|
|
|
|
|
|
Pass `lang` to override the global locale parameter, which may affect trend ordering.
|
|
|
|
|
|
|
|
Returns a list of :ref:`hashtag dicts <hashtag dicts>`, sorted by the instance's trending algorithm,
|
|
|
|
descending.
|
|
|
|
"""
|
|
|
|
params = self.__generate_params(locals())
|
2023-04-23 16:41:57 +00:00
|
|
|
if "lang" in params:
|
|
|
|
del params["lang"]
|
2022-11-30 23:39:08 +00:00
|
|
|
if self.verify_minimum_version("3.5.0", cached=True):
|
|
|
|
# Starting 3.5.0, old version is deprecated
|
2023-04-23 16:41:57 +00:00
|
|
|
return self.__api_request('GET', '/api/v1/trends/tags', params, lang_override=lang)
|
2022-11-30 23:39:08 +00:00
|
|
|
else:
|
2023-04-23 16:41:57 +00:00
|
|
|
return self.__api_request('GET', '/api/v1/trends', params, lang_override=lang)
|
2022-11-30 23:39:08 +00:00
|
|
|
|
|
|
|
@api_version("3.5.0", "3.5.0", _DICT_VERSION_STATUS)
|
2023-04-23 16:41:57 +00:00
|
|
|
def trending_statuses(self, limit=None, lang=None):
|
2022-11-30 23:39:08 +00:00
|
|
|
"""
|
|
|
|
Fetch trending-status information, if the instance provides such information.
|
|
|
|
|
|
|
|
Specify `limit` to limit how many results are returned (the maximum number
|
|
|
|
of results is 10, the endpoint is not paginated).
|
|
|
|
|
|
|
|
Pass `lang` to override the global locale parameter, which may affect trend ordering.
|
|
|
|
|
|
|
|
Returns a list of :ref:`status dicts <status dicts>`, sorted by the instances's trending algorithm,
|
|
|
|
descending.
|
|
|
|
"""
|
|
|
|
params = self.__generate_params(locals())
|
2023-04-23 16:41:57 +00:00
|
|
|
if "lang" in params:
|
|
|
|
del params["lang"]
|
|
|
|
return self.__api_request('GET', '/api/v1/trends/statuses', params, lang_override=lang)
|
2022-11-30 23:39:08 +00:00
|
|
|
|
|
|
|
@api_version("3.5.0", "3.5.0", _DICT_VERSION_CARD)
|
2023-04-23 16:41:57 +00:00
|
|
|
def trending_links(self, limit=None, lang=None):
|
2022-11-30 23:39:08 +00:00
|
|
|
"""
|
|
|
|
Fetch trending-link information, if the instance provides such information.
|
|
|
|
|
|
|
|
Specify `limit` to limit how many results are returned (the maximum number
|
|
|
|
of results is 10, the endpoint is not paginated).
|
|
|
|
|
|
|
|
Returns a list of :ref:`card dicts <card dicts>`, sorted by the instances's trending algorithm,
|
|
|
|
descending.
|
|
|
|
"""
|
|
|
|
params = self.__generate_params(locals())
|
2023-04-23 16:41:57 +00:00
|
|
|
if "lang" in params:
|
|
|
|
del params["lang"]
|
|
|
|
return self.__api_request('GET', '/api/v1/trends/links', params, lang_override=lang)
|