From a955f3000c57c134f51d55b42c0e98ff56e17311 Mon Sep 17 00:00:00 2001 From: Harmon Date: Fri, 21 Apr 2023 00:08:33 -0500 Subject: [PATCH] Remove support for deprecated Premium v1.1 Search APIs https://twittercommunity.com/t/deprecating-the-premium-v1-1-api/191092 --- README.md | 1 - docs/api.rst | 15 ----- tweepy/api.py | 175 ++------------------------------------------------ 3 files changed, 6 insertions(+), 185 deletions(-) diff --git a/README.md b/README.md index 381dcd1a1..54fa5473d 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,6 @@ Tweepy: Twitter for Python! [![DOI](https://zenodo.org/badge/244025.svg)](https://zenodo.org/badge/latestdoi/244025) [![Twitter API v1.1](https://img.shields.io/endpoint?url=https%3A%2F%2Ftwbadges.glitch.me%2Fbadges%2Fstandard)](https://developer.twitter.com/en/docs/twitter-api/v1) -[![Twitter API Premium v1.1](https://img.shields.io/endpoint?url=https%3A%2F%2Ftwbadges.glitch.me%2Fbadges%2Fpremium)](https://developer.twitter.com/en/docs/twitter-api/premium) [![Twitter API v2](https://img.shields.io/endpoint?url=https%3A%2F%2Ftwbadges.glitch.me%2Fbadges%2Fv2)](https://developer.twitter.com/en/docs/twitter-api) [![Documentation Status](https://readthedocs.org/projects/tweepy/badge/?version=latest)](https://tweepy.readthedocs.io/en/latest/) diff --git a/docs/api.rst b/docs/api.rst index 1124f8ade..e05c94d0e 100644 --- a/docs/api.rst +++ b/docs/api.rst @@ -16,12 +16,6 @@ +------------------------------------------+--------------------------------------------+ | Twitter API v1.1 Endpoint | :class:`API` Method | +==========================================+============================================+ - | .. centered:: :ref:`Premium Search APIs` | - +------------------------------------------+--------------------------------------------+ - | `GET search/30day/:label`_ | :meth:`API.search_30_day` | - +------------------------------------------+--------------------------------------------+ - | `GET search/fullarchive/:label`_ | :meth:`API.search_full_archive` | - +------------------------------------------+--------------------------------------------+ | .. centered:: :ref:`Tweets` | +---------------------------------------------------------------------------------------+ | .. centered:: |Get Tweet timelines|_ | @@ -259,8 +253,6 @@ | `GET application/rate_limit_status`_ | :meth:`API.rate_limit_status` | +------------------------------------------+--------------------------------------------+ -.. _GET search/30day/:label: https://developer.twitter.com/en/docs/twitter-api/premium/search-api/api-reference/premium-search -.. _GET search/fullarchive/:label: https://developer.twitter.com/en/docs/twitter-api/premium/search-api/api-reference/premium-search .. |Get Tweet timelines| replace:: *Get Tweet timelines* .. _GET statuses/home_timeline: https://developer.twitter.com/en/docs/twitter-api/v1/tweets/timelines/api-reference/get-statuses-home_timeline .. _GET statuses/mentions_timeline: https://developer.twitter.com/en/docs/twitter-api/v1/tweets/timelines/api-reference/get-statuses-mentions_timeline @@ -371,13 +363,6 @@ .. |Get app rate limit status| replace:: *Get app rate limit status* .. _GET application/rate_limit_status: https://developer.twitter.com/en/docs/twitter-api/v1/developer-utilities/rate-limit-status/api-reference/get-application-rate_limit_status -Premium Search APIs -=================== - -.. automethod:: API.search_30_day - -.. automethod:: API.search_full_archive - Tweets ====== diff --git a/tweepy/api.py b/tweepy/api.py index 3d755c8e6..549fe690e 100644 --- a/tweepy/api.py +++ b/tweepy/api.py @@ -57,6 +57,10 @@ class API: Added support for ``include_ext_edit_control`` endpoint/method parameter + .. versionchanged:: 4.14 + Removed ``search_30_day`` and ``search_full_archive`` methods, as + `the Premium v1.1 API has been deprecated`_ + Parameters ---------- auth @@ -91,6 +95,8 @@ class API: References ---------- https://developer.twitter.com/en/docs/api-reference-index + + .. _the Premium v1.1 API has been deprecated: https://twittercommunity.com/t/deprecating-the-premium-v1-1-api/191092 """ def __init__( @@ -287,175 +293,6 @@ def request( finally: self.session.close() - # Premium Search APIs - - @pagination(mode='next') - @payload('status', list=True) - def search_30_day(self, label, query, **kwargs): - """search_30_day(label, query, *, tag, fromDate, toDate, maxResults, \ - next) - - Premium search that provides Tweets posted within the last 30 days. - - Parameters - ---------- - label - The (case-sensitive) label associated with your search developer - environment, as displayed at - https://developer.twitter.com/en/account/environments. - query - The equivalent of one premium rule/filter, with up to 1,024 - characters (256 with Sandbox dev environments). - - This parameter should include ALL portions of the rule/filter, - including all operators, and portions of the rule should not be - separated into other parameters of the query. - tag - Tags can be used to segregate rules and their matching data into - different logical groups. If a rule tag is provided, the rule tag - is included in the 'matching_rules' attribute. - - It is recommended to assign rule-specific UUIDs to rule tags and - maintain desired mappings on the client side. - fromDate - The oldest UTC timestamp (from most recent 30 days) from which the - Tweets will be provided. Timestamp is in minute granularity and is - inclusive (i.e. 12:00 includes the 00 minute). - - Specified: Using only the fromDate with no toDate parameter will - deliver results for the query going back in time from now( ) until - the fromDate. - - Not Specified: If a fromDate is not specified, the API will deliver - all of the results for 30 days prior to now( ) or the toDate (if - specified). - - If neither the fromDate or toDate parameter is used, the API will - deliver all results for the most recent 30 days, starting at the - time of the request, going backwards. - toDate - The latest, most recent UTC timestamp to which the Tweets will be - provided. Timestamp is in minute granularity and is not inclusive - (i.e. 11:59 does not include the 59th minute of the hour). - - Specified: Using only the toDate with no fromDate parameter will - deliver the most recent 30 days of data prior to the toDate. - - Not Specified: If a toDate is not specified, the API will deliver - all of the results from now( ) for the query going back in time to - the fromDate. - - If neither the fromDate or toDate parameter is used, the API will - deliver all results for the entire 30-day index, starting at the - time of the request, going backwards. - maxResults - The maximum number of search results to be returned by a request. A - number between 10 and the system limit (currently 500, 100 for - Sandbox environments). By default, a request response will return - 100 results. - next - This parameter is used to get the next 'page' of results. The value - used with the parameter is pulled directly from the response - provided by the API, and should not be modified. - - Returns - ------- - :py:class:`List`\[:class:`~tweepy.models.Status`] - - References - ---------- - https://developer.twitter.com/en/docs/twitter-api/premium/search-api/api-reference/premium-search - """ - return self.request( - 'GET', f'tweets/search/30day/{label}', endpoint_parameters=( - 'query', 'tag', 'fromDate', 'toDate', 'maxResults', 'next' - ), query=query, **kwargs - ) - - @pagination(mode='next') - @payload('status', list=True) - def search_full_archive(self, label, query, **kwargs): - """search_full_archive(label, query, *, tag, fromDate, toDate, \ - maxResults, next) - - Premium search that provides Tweets from as early as 2006, starting - with the first Tweet posted in March 2006. - - Parameters - ---------- - label - The (case-sensitive) label associated with your search developer - environment, as displayed at - https://developer.twitter.com/en/account/environments. - query - The equivalent of one premium rule/filter, with up to 1,024 - characters (256 with Sandbox dev environments). - - This parameter should include ALL portions of the rule/filter, - including all operators, and portions of the rule should not be - separated into other parameters of the query. - tag - Tags can be used to segregate rules and their matching data into - different logical groups. If a rule tag is provided, the rule tag - is included in the 'matching_rules' attribute. - - It is recommended to assign rule-specific UUIDs to rule tags and - maintain desired mappings on the client side. - fromDate - The oldest UTC timestamp (from most recent 30 days) from which the - Tweets will be provided. Timestamp is in minute granularity and is - inclusive (i.e. 12:00 includes the 00 minute). - - Specified: Using only the fromDate with no toDate parameter will - deliver results for the query going back in time from now( ) until - the fromDate. - - Not Specified: If a fromDate is not specified, the API will deliver - all of the results for 30 days prior to now( ) or the toDate (if - specified). - - If neither the fromDate or toDate parameter is used, the API will - deliver all results for the most recent 30 days, starting at the - time of the request, going backwards. - toDate - The latest, most recent UTC timestamp to which the Tweets will be - provided. Timestamp is in minute granularity and is not inclusive - (i.e. 11:59 does not include the 59th minute of the hour). - - Specified: Using only the toDate with no fromDate parameter will - deliver the most recent 30 days of data prior to the toDate. - - Not Specified: If a toDate is not specified, the API will deliver - all of the results from now( ) for the query going back in time to - the fromDate. - - If neither the fromDate or toDate parameter is used, the API will - deliver all results for the entire 30-day index, starting at the - time of the request, going backwards. - maxResults - The maximum number of search results to be returned by a request. A - number between 10 and the system limit (currently 500, 100 for - Sandbox environments). By default, a request response will return - 100 results. - next - This parameter is used to get the next 'page' of results. The value - used with the parameter is pulled directly from the response - provided by the API, and should not be modified. - - Returns - ------- - :py:class:`List`\[:class:`~tweepy.models.Status`] - - References - ---------- - https://developer.twitter.com/en/docs/twitter-api/premium/search-api/api-reference/premium-search - """ - return self.request( - 'GET', f'tweets/search/fullarchive/{label}', endpoint_parameters=( - 'query', 'tag', 'fromDate', 'toDate', 'maxResults', 'next' - ), query=query, **kwargs - ) - # Get Tweet timelines @pagination(mode='id')