From 975381a93677f464cf78d864c3b85b034c131fdf Mon Sep 17 00:00:00 2001 From: Harmon Date: Sun, 11 Apr 2021 14:10:49 -0500 Subject: [PATCH] Update and improve documentation for API.trends_place Automatically use docstring for documentation Improve method and documentation order Add API documentation header to match API reference index --- docs/api.rst | 32 +++++--------------------------- tweepy/api.py | 46 ++++++++++++++++++++++++++++++++++++---------- 2 files changed, 41 insertions(+), 37 deletions(-) diff --git a/docs/api.rst b/docs/api.rst index 2db695a..082887f 100644 --- a/docs/api.rst +++ b/docs/api.rst @@ -235,6 +235,11 @@ Get locations with trending topics .. automethod:: API.trends_closest +Get trends near a location +^^^^^^^^^^^^^^^^^^^^^^^^^^ + +.. automethod:: API.trends_place + Account Methods --------------- @@ -348,33 +353,6 @@ Search Methods provided by the API, and should not be modified. -Trends Methods --------------- - -.. method:: API.trends_place(id, [exclude]) - - Returns the top 50 trending topics for a specific WOEID, - if trending information is available for it. - - The response is an array of “trend” objects that encode the name of the - trending topic, the query parameter that can be used to search for the topic - on Twitter Search, and the Twitter Search URL. - - This information is cached for 5 minutes. Requesting more frequently than - that will not return any more data, and will count against your rate limit - usage. - - The tweet_volume for the last 24 hours is also returned for many trends if - this is available. - - :param id: The Yahoo! Where On Earth ID of the location to return trending - information for. Global information is available by using 1 as - the WOEID. - :param exclude: Setting this equal to hashtags will remove all hashtags - from the trends list. - :rtype: :class:`JSON` object - - Geo Methods ----------- diff --git a/tweepy/api.py b/tweepy/api.py index 12ee6d8..ce446ce 100644 --- a/tweepy/api.py +++ b/tweepy/api.py @@ -2624,19 +2624,35 @@ class API: ), lat=lat, long=long, **kwargs ) - @payload('json') - def rate_limit_status(self, **kwargs): - """ :reference: https://developer.twitter.com/en/docs/twitter-api/v1/developer-utilities/rate-limit-status/api-reference/get-application-rate_limit_status - """ - return self.request( - 'GET', 'application/rate_limit_status', endpoint_parameters=( - 'resources', - ), use_cache=False, **kwargs - ) + # Get trends near a location @payload('json') def trends_place(self, id, **kwargs): - """ :reference: https://developer.twitter.com/en/docs/twitter-api/v1/trends/trends-for-location/api-reference/get-trends-place + """trends_place(id *, exclude) + + Returns the top 50 trending topics for a specific WOEID, if trending + information is available for it. + + The response is an array of “trend” objects that encode the name of the + trending topic, the query parameter that can be used to search for the + topic on Twitter Search, and the Twitter Search URL. + + This information is cached for 5 minutes. Requesting more frequently + than that will not return any more data, and will count against your + rate limit usage. + + The tweet_volume for the last 24 hours is also returned for many trends + if this is available. + + :param id: The Yahoo! Where On Earth ID of the location to return + trending information for. Global information is available by using + 1 as the WOEID. + :param exclude: Setting this equal to hashtags will remove all hashtags + from the trends list. + + :rtype: :class:`JSON` object + + :reference: https://developer.twitter.com/en/docs/twitter-api/v1/trends/trends-for-location/api-reference/get-trends-place """ return self.request( 'GET', 'trends/place', endpoint_parameters=( @@ -2644,6 +2660,16 @@ class API: ), id=id, **kwargs ) + @payload('json') + def rate_limit_status(self, **kwargs): + """ :reference: https://developer.twitter.com/en/docs/twitter-api/v1/developer-utilities/rate-limit-status/api-reference/get-application-rate_limit_status + """ + return self.request( + 'GET', 'application/rate_limit_status', endpoint_parameters=( + 'resources', + ), use_cache=False, **kwargs + ) + @pagination(mode='next') @payload('status', list=True) def search_30_day(self, label, query, **kwargs): -- 2.25.1