From 8c30384e2f272098b6a942c04150aa945abfcc0d Mon Sep 17 00:00:00 2001 From: ikaroskun Date: Tue, 4 Nov 2025 15:14:56 +0800 Subject: [PATCH] feat(domain): :sparkles: migrate domain to x.com --- README.rst | 6 ++-- docs/docs/authorization.md | 6 ++-- docs/docs/authorization_oauth2.md | 4 +-- docs/docs/index.md | 2 +- .../docs/usage/compliance/batch_compliance.md | 2 +- .../direct-messages/direct-messages-lookup.md | 2 +- .../direct-messages/manage-direct-messages.md | 2 +- docs/docs/usage/lists/list-follows.md | 6 ++-- docs/docs/usage/lists/list-lookup.md | 4 +-- docs/docs/usage/lists/list-members.md | 6 ++-- docs/docs/usage/lists/list-tweets-lookup.md | 4 +-- docs/docs/usage/lists/manage-lists.md | 2 +- docs/docs/usage/lists/pinned-lists.md | 6 ++-- .../docs/usage/media-upload/chunked-upload.md | 2 +- docs/docs/usage/media-upload/simple-upload.md | 2 +- docs/docs/usage/spaces/search.md | 2 +- docs/docs/usage/spaces/spaces-lookup.md | 2 +- docs/docs/usage/trends/trends.md | 2 +- docs/docs/usage/tweets/bookmarks.md | 2 +- docs/docs/usage/tweets/likes.md | 2 +- docs/docs/usage/tweets/qutoe_tweets.md | 2 +- docs/docs/usage/tweets/retweet.md | 2 +- docs/docs/usage/tweets/tweet-manage.md | 2 +- docs/docs/usage/usage/tweets.md | 2 +- docs/docs/usage/users/blocks.md | 2 +- docs/docs/usage/users/follows.md | 2 +- docs/docs/usage/users/mutes.md | 2 +- docs/docs/usage/users/search.md | 2 +- docs/docs/usage/users/user-lookup.md | 2 +- docs/mkdocs.yml | 2 +- pytwitter/api.py | 22 ++++++------ pytwitter/models/compliance.py | 2 +- pytwitter/models/dm_event.py | 2 +- pytwitter/models/ext.py | 4 +-- pytwitter/models/list.py | 2 +- pytwitter/models/media.py | 2 +- pytwitter/models/media_upload.py | 2 +- pytwitter/models/place.py | 2 +- pytwitter/models/poll.py | 2 +- pytwitter/models/space.py | 2 +- pytwitter/models/trend.py | 2 +- pytwitter/models/tweet.py | 6 ++-- pytwitter/models/usage.py | 2 +- pytwitter/models/user.py | 4 +-- pytwitter/rate_limit.py | 4 +-- pytwitter/streaming.py | 8 ++--- tests/apis/test_auth.py | 18 +++++----- tests/apis/test_compliance_job.py | 6 ++-- tests/apis/test_dm_events.py | 12 +++---- tests/apis/test_follows.py | 8 ++--- tests/apis/test_hidden_reply.py | 4 +-- tests/apis/test_lists.py | 34 +++++++++--------- tests/apis/test_media_upload.py | 12 +++---- tests/apis/test_media_upload_v2.py | 12 +++---- tests/apis/test_search.py | 4 +-- tests/apis/test_space.py | 12 +++---- tests/apis/test_timelines.py | 6 ++-- tests/apis/test_trends.py | 2 +- tests/apis/test_tweets.py | 36 +++++++++---------- tests/apis/test_usage.py | 2 +- tests/apis/test_users.py | 30 ++++++++-------- tests/streams/test_auth.py | 6 ++-- tests/streams/test_rules.py | 10 +++--- tests/streams/test_stream.py | 4 +-- tests/test_rate_limit.py | 10 +++--- tests/test_response.py | 14 ++++---- 66 files changed, 196 insertions(+), 200 deletions(-) diff --git a/README.rst b/README.rst index 4b7516b1..b68c79ad 100644 --- a/README.rst +++ b/README.rst @@ -3,7 +3,7 @@ python-twitter A simple Python wrapper for Twitter API v2 :sparkles: :cake: :sparkles:. .. image:: https://img.shields.io/endpoint?url=https%3A%2F%2Ftwbadges.glitch.me%2Fbadges%2Fv2 - :target: https://developer.twitter.com/en/docs/twitter-api + :target: https://developer.x.com/en/docs/twitter-api :alt: v2 .. image:: https://github.com/sns-sdks/python-twitter/workflows/Test/badge.svg @@ -24,7 +24,7 @@ A simple Python wrapper for Twitter API v2 :sparkles: :cake: :sparkles:. Introduction ============ -Twitter has published new version `Twitter API V2 `_ for developer at Aug 13, 2020. +Twitter has published new version `Twitter API V2 `_ for developer at Aug 13, 2020. This library provides a service to easily use this new version Twitter API. @@ -32,7 +32,7 @@ This library provides a service to easily use this new version Twitter API. Documentation ============= -You can get all API descriptions `Twitter API v2 Documentation `_. +You can get all API descriptions `Twitter API v2 Documentation `_. Docs for this library on `here `_ diff --git a/docs/docs/authorization.md b/docs/docs/authorization.md index 9f46d503..116b0dde 100644 --- a/docs/docs/authorization.md +++ b/docs/docs/authorization.md @@ -7,7 +7,7 @@ So, This will show you how to obtain user access tokens through the 3-legged OAu At the beginning, You need a Twitter app, and enable the `3-legged OAuth`. -You can get more information at the [official Documentation](https://developer.twitter.com/en/docs/authentication/oauth-1-0a/obtaining-user-access-tokens). +You can get more information at the [official Documentation](https://developer.x.com/en/docs/authentication/oauth-1-0a/obtaining-user-access-tokens). If you're ready, now let's get started do a simple example with this library. @@ -30,7 +30,7 @@ Now you can get the url for user to do authenticate, ```python api.get_authorize_url() -# https://api.twitter.com/oauth/authorize?oauth_token=NPcudxy0yU5T3tBzho7iCotZ3cnetKwcTIRlX0iwRl0 +# https://api.x.com/oauth/authorize?oauth_token=NPcudxy0yU5T3tBzho7iCotZ3cnetKwcTIRlX0iwRl0 ``` Upon successful authentication, your callback_url would receive a request containing the oauth_token and oauth_verifier parameters. @@ -51,5 +51,5 @@ Now the api instance will have the user authorization. You can use this to manag !!! tip "Note" - If you have any confusion, you need to read the [Get user access token](https://developer.twitter.com/en/docs/authentication/oauth-1-0a/obtaining-user-access-tokens) first. + If you have any confusion, you need to read the [Get user access token](https://developer.x.com/en/docs/authentication/oauth-1-0a/obtaining-user-access-tokens) first. \ No newline at end of file diff --git a/docs/docs/authorization_oauth2.md b/docs/docs/authorization_oauth2.md index edc39b29..a426dd55 100644 --- a/docs/docs/authorization_oauth2.md +++ b/docs/docs/authorization_oauth2.md @@ -2,7 +2,7 @@ Once you have got the request access for `OAuth2.0`, your app will have the `Client ID` to do `authorization` for `OAuth2.0`. -You can get more information at the [documentation](https://developer.twitter.com/en/docs/twitter-api/oauth2) and the [community content](https://twittercommunity.com/t/announcing-oauth-2-0-general-availability/163555). +You can get more information at the [documentation](https://developer.x.com/en/docs/twitter-api/oauth2) and the [community content](https://twittercommunity.com/t/announcing-oauth-2-0-general-availability/163555). If you're ready, now let's get started do a simple example with this library. @@ -32,7 +32,7 @@ You need save the `code_verifier` for generate access token. ```python authorization_url, code_verifier, state = api.get_oauth2_authorize_url() -#('https://twitter.com/i/oauth2/authorize?response_type=code&client_id=client_id&redirect_uri=https%3A%2F%2Flocalhost%2F&scope=users.read+tweet.read&state=HVLpccax4G57jMJu1yddJtP55HYMQA&code_challenge=jntz4xjHJ0XHzWA7_Wa6rrA8zHwu4qPZt2MQsv6&code_challenge_method=S256', +#('https://x.com/i/oauth2/authorize?response_type=code&client_id=client_id&redirect_uri=https%3A%2F%2Flocalhost%2F&scope=users.read+tweet.read&state=HVLpccax4G57jMJu1yddJtP55HYMQA&code_challenge=jntz4xjHJ0XHzWA7_Wa6rrA8zHwu4qPZt2MQsv6&code_challenge_method=S256', # '01wNLFIFeh310NpRLt837gcrvK1JqFrFvoYFU0DnH', # 'HVLpccax4G57jMJu1yddJtP55HYMQA') ``` diff --git a/docs/docs/index.md b/docs/docs/index.md index ac4cb1f9..a7d191df 100644 --- a/docs/docs/index.md +++ b/docs/docs/index.md @@ -5,7 +5,7 @@ A Python wrapper around for Twitter API V2 :sparkles: :cake: :sparkles:. ## Introduction -Twitter has published new version [Twitter API V2](https://twitter.com/TwitterDev/status/1293593516040269825) for developer at Aug 13, 2020. +Twitter has published new version [Twitter API V2](https://x.com/TwitterDev/status/1293593516040269825) for developer at Aug 13, 2020. So this library provides a Python interface for this version API. Library work on Python 3.6+. diff --git a/docs/docs/usage/compliance/batch_compliance.md b/docs/docs/usage/compliance/batch_compliance.md index cc08fe51..e3e3689f 100644 --- a/docs/docs/usage/compliance/batch_compliance.md +++ b/docs/docs/usage/compliance/batch_compliance.md @@ -1,6 +1,6 @@ These batch compliance endpoints allow you to upload large datasets of Tweet or user IDs to retrieve their compliance status in order to determine what data requires action in order to bring your datasets into compliance. Please note, use of the batch compliance endpoints is restricted to aforementioned use cases, and any other purpose is prohibited and may result in enforcement action. -You can get more information at [batch compliance docs](https://developer.twitter.com/en/docs/twitter-api/compliance/batch-compliance/introduction). +You can get more information at [batch compliance docs](https://developer.x.com/en/docs/twitter-api/compliance/batch-compliance/introduction). Typically, there are 4 steps involved in working with this endpoint: diff --git a/docs/docs/usage/direct-messages/direct-messages-lookup.md b/docs/docs/usage/direct-messages/direct-messages-lookup.md index 7543cf64..b062afbc 100644 --- a/docs/docs/usage/direct-messages/direct-messages-lookup.md +++ b/docs/docs/usage/direct-messages/direct-messages-lookup.md @@ -2,7 +2,7 @@ Direct Messages enable private conversations on Twitter. Direct Messages are one of the most popular features of Twitter, with a wide variety of use cases. These use cases range from group chats among friends to powering customer support for brands around the world. New v2 versions of Direct Messages endpoints will be introduced in stages, and this first stage includes fundamental endpoints for creating Direct Messages and listing Direct Message conversation events. For the first time, the Twitter API v2 supports group conversations. -You can get more information for this at [docs](https://developer.twitter.com/en/docs/twitter-api/direct-messages/lookup/introduction) +You can get more information for this at [docs](https://developer.x.com/en/docs/twitter-api/direct-messages/lookup/introduction) ### Get all messages in a 1-1 conversation diff --git a/docs/docs/usage/direct-messages/manage-direct-messages.md b/docs/docs/usage/direct-messages/manage-direct-messages.md index e519dca3..de13bef8 100644 --- a/docs/docs/usage/direct-messages/manage-direct-messages.md +++ b/docs/docs/usage/direct-messages/manage-direct-messages.md @@ -2,7 +2,7 @@ Direct Messages enable private conversations on Twitter. Direct Messages are one of the most popular features of Twitter, with a wide variety of use cases. These use cases range from group chats among friends, to powering customer support for brands around the world. New v2 versions of Direct Messages endpoints will be introduced in stages, and this first stage includes fundamental endpoints for creating Direct Messages and listing Direct Message conversation events. For the first time, the Twitter API v2 supports group conversations. -You can get more information for this at [docs](https://developer.twitter.com/en/docs/twitter-api/direct-messages/manage/introduction) +You can get more information for this at [docs](https://developer.x.com/en/docs/twitter-api/direct-messages/manage/introduction) ### Create a message in a 1-1 conversation with the participant diff --git a/docs/docs/usage/lists/list-follows.md b/docs/docs/usage/lists/list-follows.md index 6479cea2..fd5ff33c 100644 --- a/docs/docs/usage/lists/list-follows.md +++ b/docs/docs/usage/lists/list-follows.md @@ -2,9 +2,9 @@ List follows lookup group has two available endpoints. You are able to retrieve details on followers of a specified List and get data on which Lists a user follows. These endpoints can be used to enable people to curate and organize Tweets based on what type of Lists other users are following. -You can use either [OAuth 1.0a User Context](https://developer.twitter.com/en/docs/authentication/oauth-1-0a) or [OAuth 2.0 Bearer Token](https://developer.twitter.com/en/docs/authentication/oauth-2-0) to authenticate to these endpoints. +You can use either [OAuth 1.0a User Context](https://developer.x.com/en/docs/authentication/oauth-1-0a) or [OAuth 2.0 Bearer Token](https://developer.x.com/en/docs/authentication/oauth-2-0) to authenticate to these endpoints. -You can get more information for this at [docs](https://developer.twitter.com/en/docs/twitter-api/lists/list-follows/introduction) +You can get more information for this at [docs](https://developer.x.com/en/docs/twitter-api/lists/list-follows/introduction) ### Get list's followers @@ -30,7 +30,7 @@ The manage List follows endpoints allow you to follow and unfollow a List on beh For these endpoints, there are two methods available: POST and DELETE. The POST method allows you to follow a List, and the DELETE method allows you to delete a List. -You can get more information for this at [docs](https://developer.twitter.com/en/docs/twitter-api/lists/list-follows/introduction) +You can get more information for this at [docs](https://developer.x.com/en/docs/twitter-api/lists/list-follows/introduction) ### Follow a list diff --git a/docs/docs/usage/lists/list-lookup.md b/docs/docs/usage/lists/list-lookup.md index 0da05610..b4881327 100644 --- a/docs/docs/usage/lists/list-lookup.md +++ b/docs/docs/usage/lists/list-lookup.md @@ -1,8 +1,8 @@ ~~This List lookup group has two available endpoints. You are able to retrieve a specified List by ID and get details on user-owned Lists. With the Lists endpoints, you can build solutions that enable people to curate and organize Tweets based on preferences, interests, groups, or topics. -You can use either [OAuth 1.0a User Context](https://developer.twitter.com/en/docs/authentication/oauth-1-0a) or [OAuth 2.0 Bearer Token](https://developer.twitter.com/en/docs/authentication/oauth-2-0) to authenticate to these endpoints. If you choose to use [OAuth 1.0a User Context](https://developer-staging.twitter.com/en/docs/authentication/oauth-1-0a), use the Access Tokens associated with a user that has authorized your App. You can generate Access Tokens using the [3-legged OAuth flow](https://developer-staging.twitter.com/en/docs/authentication/oauth-1-0a/obtaining-user-access-tokens). +You can use either [OAuth 1.0a User Context](https://developer.x.com/en/docs/authentication/oauth-1-0a) or [OAuth 2.0 Bearer Token](https://developer.x.com/en/docs/authentication/oauth-2-0) to authenticate to these endpoints. If you choose to use [OAuth 1.0a User Context](https://developer-staging.x.com/en/docs/authentication/oauth-1-0a), use the Access Tokens associated with a user that has authorized your App. You can generate Access Tokens using the [3-legged OAuth flow](https://developer-staging.x.com/en/docs/authentication/oauth-1-0a/obtaining-user-access-tokens). -You can get more information for this at [docs](https://developer.twitter.com/en/docs/twitter-api/lists/list-lookup/introduction) +You can get more information for this at [docs](https://developer.x.com/en/docs/twitter-api/lists/list-lookup/introduction) ## Lookup a specific list by ID diff --git a/docs/docs/usage/lists/list-members.md b/docs/docs/usage/lists/list-members.md index 989c955c..3c14bc95 100644 --- a/docs/docs/usage/lists/list-members.md +++ b/docs/docs/usage/lists/list-members.md @@ -1,9 +1,9 @@ ## List members lookup Members lookup group has two available endpoints. You are able to retrieve details on members of a specified List and see which Lists a user is a member of. These endpoints can be used to enable people to curate and organize new Lists based on the membership information. -You can use either [OAuth 1.0a User Context](https://developer.twitter.com/en/docs/authentication/oauth-1-0a) or [OAuth 2.0 Bearer Token](https://developer.twitter.com/en/docs/authentication/oauth-2-0) to authenticate to these endpoints. +You can use either [OAuth 1.0a User Context](https://developer.x.com/en/docs/authentication/oauth-1-0a) or [OAuth 2.0 Bearer Token](https://developer.x.com/en/docs/authentication/oauth-2-0) to authenticate to these endpoints. -You can get more information for this at [docs](https://developer.twitter.com/en/docs/twitter-api/lists/list-members/introduction) +You can get more information for this at [docs](https://developer.x.com/en/docs/twitter-api/lists/list-members/introduction) ### Get list's members @@ -30,7 +30,7 @@ The manage List members endpoints allow you to add and remove members to a List For these endpoints, there are two methods available: POST and DELETE. The POST method allows you to add a member to a List, and the DELETE method allows you to remove a member from a List. -You can get more information for this at [docs](https://developer.twitter.com/en/docs/twitter-api/lists/list-members/introduction) +You can get more information for this at [docs](https://developer.x.com/en/docs/twitter-api/lists/list-members/introduction) ### Add member to a list diff --git a/docs/docs/usage/lists/list-tweets-lookup.md b/docs/docs/usage/lists/list-tweets-lookup.md index 02b3549c..9a96818a 100644 --- a/docs/docs/usage/lists/list-tweets-lookup.md +++ b/docs/docs/usage/lists/list-tweets-lookup.md @@ -1,8 +1,8 @@ List Tweets lookup has one available endpoint to retrieve Tweets from a specified List. With this endpoint, you can build solutions that enable users to customize, organize and prioritize the Tweets they see in their timeline. -You can use either [OAuth 1.0a User Context](https://developer.twitter.com/en/docs/authentication/oauth-1-0a) or [OAuth 2.0 Bearer Token](https://developer.twitter.com/en/docs/authentication/oauth-2-0) to authenticate to these endpoints. If you choose to use [OAuth 1.0a User Context](https://developer-staging.twitter.com/en/docs/authentication/oauth-1-0a), use the Access Tokens associated with a user that has authorized your App. You can generate Access Tokens using the [3-legged OAuth flow](https://developer-staging.twitter.com/en/docs/authentication/oauth-1-0a/obtaining-user-access-tokens). +You can use either [OAuth 1.0a User Context](https://developer.x.com/en/docs/authentication/oauth-1-0a) or [OAuth 2.0 Bearer Token](https://developer.x.com/en/docs/authentication/oauth-2-0) to authenticate to these endpoints. If you choose to use [OAuth 1.0a User Context](https://developer-staging.x.com/en/docs/authentication/oauth-1-0a), use the Access Tokens associated with a user that has authorized your App. You can generate Access Tokens using the [3-legged OAuth flow](https://developer-staging.x.com/en/docs/authentication/oauth-1-0a/obtaining-user-access-tokens). -You can get more information for this at [docs](https://developer.twitter.com/en/docs/twitter-api/lists/list-tweets/introduction) +You can get more information for this at [docs](https://developer.x.com/en/docs/twitter-api/lists/list-tweets/introduction) ## Lookup Tweets from a specified List diff --git a/docs/docs/usage/lists/manage-lists.md b/docs/docs/usage/lists/manage-lists.md index 94f46f39..8f961552 100644 --- a/docs/docs/usage/lists/manage-lists.md +++ b/docs/docs/usage/lists/manage-lists.md @@ -4,7 +4,7 @@ For these endpoints, there are three methods available: POST, DELETE and PUT. Th There is a user rate limit of 300 requests per 15 minutes for all three endpoints. -You can get more information for this at [docs](https://developer.twitter.com/en/docs/twitter-api/lists/manage-lists/introduction) +You can get more information for this at [docs](https://developer.x.com/en/docs/twitter-api/lists/manage-lists/introduction) Note that you can create up to 1000 Lists per account. diff --git a/docs/docs/usage/lists/pinned-lists.md b/docs/docs/usage/lists/pinned-lists.md index d1f08a47..1d05561a 100644 --- a/docs/docs/usage/lists/pinned-lists.md +++ b/docs/docs/usage/lists/pinned-lists.md @@ -6,7 +6,7 @@ For these endpoints, there are two methods available: POST and DELETE. The POST There is a user rate limit of 50 requests per 15 minutes for both endpoints. -You can get more information for this at [docs](https://developer.twitter.com/en/docs/twitter-api/lists/pinned-lists/introduction) +You can get more information for this at [docs](https://developer.x.com/en/docs/twitter-api/lists/pinned-lists/introduction) ### Pin a list @@ -30,9 +30,9 @@ my_api.unpin_list(user_id=my_api.auth_user_id, list_id="ID for list to unpin") Pinned List lookup has one available endpoint that allows you to retrieve an authenticated user's pinned Lists. There is a rate limit of 15 requests per 15 minutes for this endpoint. -Since you are making requests on behalf of a user with all pinned List endpoints, you must authenticate with [OAuth 1.0a User Context](https://developer-staging.twitter.com/en/docs/authentication/oauth-1-0a) and use the Access Tokens associated with a user that has authorized your App. You can generate Access Tokens using the [3-legged OAuth flow](https://developer-staging.twitter.com/en/docs/authentication/oauth-1-0a/obtaining-user-access-tokens). +Since you are making requests on behalf of a user with all pinned List endpoints, you must authenticate with [OAuth 1.0a User Context](https://developer-staging.x.com/en/docs/authentication/oauth-1-0a) and use the Access Tokens associated with a user that has authorized your App. You can generate Access Tokens using the [3-legged OAuth flow](https://developer-staging.x.com/en/docs/authentication/oauth-1-0a/obtaining-user-access-tokens). -You can get more information for this at [docs](https://developer.twitter.com/en/docs/twitter-api/lists/pinned-lists/introduction) +You can get more information for this at [docs](https://developer.x.com/en/docs/twitter-api/lists/pinned-lists/introduction) ### Get user pinned lists diff --git a/docs/docs/usage/media-upload/chunked-upload.md b/docs/docs/usage/media-upload/chunked-upload.md index 129f49d8..ffbdf826 100644 --- a/docs/docs/usage/media-upload/chunked-upload.md +++ b/docs/docs/usage/media-upload/chunked-upload.md @@ -1,6 +1,6 @@ Chunked upload is the recommended method for uploading media files. It allows you to upload media files up to 512MB. The chunked upload endpoint can be used to upload both images and videos. -You can get more information for this at [docs](https://developer.twitter.com/en/docs/twitter-api/v1/media/upload-media/api-reference/post-media-upload-init). +You can get more information for this at [docs](https://developer.x.com/en/docs/twitter-api/v1/media/upload-media/api-reference/post-media-upload-init). follow the steps below to upload a video by chunked upload: diff --git a/docs/docs/usage/media-upload/simple-upload.md b/docs/docs/usage/media-upload/simple-upload.md index b58a2f27..f012c87a 100644 --- a/docs/docs/usage/media-upload/simple-upload.md +++ b/docs/docs/usage/media-upload/simple-upload.md @@ -1,6 +1,6 @@ The simple upload endpoint can only be used to upload images(gifs). -You can get more information for this at [docs](https://developer.twitter.com/en/docs/twitter-api/v1/media/upload-media/api-reference/post-media-upload) +You can get more information for this at [docs](https://developer.x.com/en/docs/twitter-api/v1/media/upload-media/api-reference/post-media-upload) follow the steps below to upload an image: diff --git a/docs/docs/usage/spaces/search.md b/docs/docs/usage/spaces/search.md index 99247273..fec514a1 100644 --- a/docs/docs/usage/spaces/search.md +++ b/docs/docs/usage/spaces/search.md @@ -2,7 +2,7 @@ This endpoint allows you to search Spaces by their title, and to filter results The endpoint accepts one or more keywords as a query. Its results can be filtered by the status of a Space (live or scheduled). By default, a request will return both live and scheduled Spaces that match the specified query. -You can get more information at [search docs](https://developer.twitter.com/en/docs/twitter-api/spaces/search/introduction). +You can get more information at [search docs](https://developer.x.com/en/docs/twitter-api/spaces/search/introduction). ## Search spaces diff --git a/docs/docs/usage/spaces/spaces-lookup.md b/docs/docs/usage/spaces/spaces-lookup.md index bcb4b78f..5c9cad71 100644 --- a/docs/docs/usage/spaces/spaces-lookup.md +++ b/docs/docs/usage/spaces/spaces-lookup.md @@ -1,5 +1,5 @@ The Spaces lookup endpoints help you lookup live or scheduled Spaces, and enable you to build discovery experiences to give your users ways to find Spaces they may be interested in. -You can get more information at [Lookup docs](https://developer.twitter.com/en/docs/twitter-api/spaces/lookup/introduction). +You can get more information at [Lookup docs](https://developer.x.com/en/docs/twitter-api/spaces/lookup/introduction). There have multiple methods for get spaces data by api. diff --git a/docs/docs/usage/trends/trends.md b/docs/docs/usage/trends/trends.md index fbd425e3..facb8e91 100644 --- a/docs/docs/usage/trends/trends.md +++ b/docs/docs/usage/trends/trends.md @@ -1,7 +1,7 @@ The Trends lookup endpoint allow developers to get the Trends for a location, specified using the where-on-earth id (WOEID). **Note:** WOEID is a legacy identifier created by Yahoo and has been deprecated. X API uses the numeric value to identify town and country trend locations. -Reference our legacy [blog post](https://blog.twitter.com/engineering/en_us/a/2010/woeids-in-twitters-trends.html), or [archived data](https://archive.org/details/geoplanet_data_7.10.0.zip0.) +Reference our legacy [blog post](https://blog.x.com/engineering/en_us/a/2010/woeids-in-twitters-trends.html), or [archived data](https://archive.org/details/geoplanet_data_7.10.0.zip0.) ### Get trends diff --git a/docs/docs/usage/tweets/bookmarks.md b/docs/docs/usage/tweets/bookmarks.md index 4bccf8a4..60a969bd 100644 --- a/docs/docs/usage/tweets/bookmarks.md +++ b/docs/docs/usage/tweets/bookmarks.md @@ -1,6 +1,6 @@ Bookmarks are a core feature of the Twitter app that allows you to “save” Tweets and easily access them later. With these endpoints, you can retrieve, create, delete or build solutions to manage your Bookmarks via the API. -You can get more information for this at [docs](https://developer.twitter.com/en/docs/twitter-api/tweets/bookmarks/introduction) +You can get more information for this at [docs](https://developer.x.com/en/docs/twitter-api/tweets/bookmarks/introduction) ## Manage Bookmarks diff --git a/docs/docs/usage/tweets/likes.md b/docs/docs/usage/tweets/likes.md index 1187c2ca..f93c4dec 100644 --- a/docs/docs/usage/tweets/likes.md +++ b/docs/docs/usage/tweets/likes.md @@ -2,7 +2,7 @@ The manage Likes endpoints enable you to like or unlike a specified Tweet on beh For this endpoint group, there are two methods available POST and DELETE. The POST method allows you to like a Tweet, and the DELETE method will enable you to unlike a Tweet. -You can get more information for this at [docs](https://developer.twitter.com/en/docs/twitter-api/tweets/likes/introduction) +You can get more information for this at [docs](https://developer.x.com/en/docs/twitter-api/tweets/likes/introduction) ## likes diff --git a/docs/docs/usage/tweets/qutoe_tweets.md b/docs/docs/usage/tweets/qutoe_tweets.md index b7dbc760..725010fd 100644 --- a/docs/docs/usage/tweets/qutoe_tweets.md +++ b/docs/docs/usage/tweets/qutoe_tweets.md @@ -2,7 +2,7 @@ The Quote Tweets lookup endpoint gives the Quote Tweets for a given Tweet ID. T Tweets are delivered in reverse-chronological order, starting with the most recent. Results are paginated up to 100 Tweets per page (10 Tweets by default). Pagination tokens are provided for paging through large sets of Tweets. -You can get more information for this at [docs](https://developer.twitter.com/en/docs/twitter-api/tweets/quote-tweets/introduction) +You can get more information for this at [docs](https://developer.x.com/en/docs/twitter-api/tweets/quote-tweets/introduction) ## Quote Tweets diff --git a/docs/docs/usage/tweets/retweet.md b/docs/docs/usage/tweets/retweet.md index 9f3017c5..b13e5176 100644 --- a/docs/docs/usage/tweets/retweet.md +++ b/docs/docs/usage/tweets/retweet.md @@ -2,7 +2,7 @@ The manage Retweets endpoints enable you to Retweet or undo a Retweet of a speci For this endpoint group, there are two methods available POST and DELETE. The POST method allows you to Retweet a Tweet, and the DELETE method will enable you to undo a Retweet of a given Tweet. -You can get more information for this at [docs](https://developer.twitter.com/en/docs/twitter-api/tweets/retweets/introduction) +You can get more information for this at [docs](https://developer.x.com/en/docs/twitter-api/tweets/retweets/introduction) ## Retweets diff --git a/docs/docs/usage/tweets/tweet-manage.md b/docs/docs/usage/tweets/tweet-manage.md index 448a397e..48073c59 100644 --- a/docs/docs/usage/tweets/tweet-manage.md +++ b/docs/docs/usage/tweets/tweet-manage.md @@ -4,7 +4,7 @@ We have two available methods for manage Tweets, POST and DELETE. The POST metho There is a user rate limit of 200 requests per 15 minutes for the POST method. The DELETE method has a rate limit of 50 requests per 15 minutes. Additionally, there is a limit of 300 requests per 3 hours, including Tweets created with either manage Tweets or manage Retweets. -You can get more information for this at [docs](https://developer.twitter.com/en/docs/twitter-api/tweets/manage-tweets/introduction) +You can get more information for this at [docs](https://developer.x.com/en/docs/twitter-api/tweets/manage-tweets/introduction) ## Post a Tweet diff --git a/docs/docs/usage/usage/tweets.md b/docs/docs/usage/usage/tweets.md index 7b74bb10..eef209d7 100644 --- a/docs/docs/usage/usage/tweets.md +++ b/docs/docs/usage/usage/tweets.md @@ -1,6 +1,6 @@ The Usage API in the Twitter API v2 allows developers to programmatically retrieve their project usage. Using thie endpoint, developers can keep a track and monitor of the number of Tweets they have pulled for a given billing cycle. -You can learn more about the Usage API in the [docs](https://developer.twitter.com/en/docs/twitter-api/usage/tweets/introduction). +You can learn more about the Usage API in the [docs](https://developer.x.com/en/docs/twitter-api/usage/tweets/introduction). !!! tip "Note" diff --git a/docs/docs/usage/users/blocks.md b/docs/docs/usage/users/blocks.md index 66d9bb7f..247f51dc 100644 --- a/docs/docs/usage/users/blocks.md +++ b/docs/docs/usage/users/blocks.md @@ -2,7 +2,7 @@ The manage blocks endpoints enable you to block or unblock a specified user on b For this endpoint group, there are two methods available POST and DELETE. The POST method allows you to block a user, and the DELETE method will enable you to unblock. -You can get more information for this at [docs](https://developer.twitter.com/en/docs/twitter-api/users/blocks/introduction) +You can get more information for this at [docs](https://developer.x.com/en/docs/twitter-api/users/blocks/introduction) ## Blocks diff --git a/docs/docs/usage/users/follows.md b/docs/docs/usage/users/follows.md index 13800273..9334303a 100644 --- a/docs/docs/usage/users/follows.md +++ b/docs/docs/usage/users/follows.md @@ -2,7 +2,7 @@ Following users is one of the most foundational actions on Twitter. Twitter offer two sets of endpoint groups to help you lookup, create, and delete follow relationships: follows lookup and manage follows. -You can get more information for this at [docs](https://developer.twitter.com/en/docs/twitter-api/users/follows/introduction) +You can get more information for this at [docs](https://developer.x.com/en/docs/twitter-api/users/follows/introduction) ## Follows lookup diff --git a/docs/docs/usage/users/mutes.md b/docs/docs/usage/users/mutes.md index 63fc89fa..f13aaa7a 100644 --- a/docs/docs/usage/users/mutes.md +++ b/docs/docs/usage/users/mutes.md @@ -2,7 +2,7 @@ The manage mute endpoints enable you to mute or unmute a specified account on be For these endpoints, there are two methods available: POST and DELETE. The POST method allows you to mute an account, and the DELETE method allows you to unmute an account. There is a user rate limit of 50 requests per 15 minutes for both the POST and DELETE endpoints. -You can get more information for this at [docs](https://developer.twitter.com/en/docs/twitter-api/users/mutes/introduction) +You can get more information for this at [docs](https://developer.x.com/en/docs/twitter-api/users/mutes/introduction) ## Manage Mutes diff --git a/docs/docs/usage/users/search.md b/docs/docs/usage/users/search.md index 06398fac..931b57a7 100644 --- a/docs/docs/usage/users/search.md +++ b/docs/docs/usage/users/search.md @@ -1,6 +1,6 @@ The Users Search endpoint provides a simple, relevance-based search interface to public user accounts on X. Try querying by topical interest, full name, company name, location, or other criteria. -You can get more information for this at [docs](https://developer.twitter.com/en/docs/twitter-api/users/search/introduction) +You can get more information for this at [docs](https://developer.x.com/en/docs/twitter-api/users/search/introduction) ## Search Users diff --git a/docs/docs/usage/users/user-lookup.md b/docs/docs/usage/users/user-lookup.md index b8ad72b6..662c53c5 100644 --- a/docs/docs/usage/users/user-lookup.md +++ b/docs/docs/usage/users/user-lookup.md @@ -1,5 +1,5 @@ -Twitter allow app to lookup users. You can get more information at [Lookup docs](https://developer.twitter.com/en/docs/twitter-api/users/lookup/introduction). +Twitter allow app to lookup users. You can get more information at [Lookup docs](https://developer.x.com/en/docs/twitter-api/users/lookup/introduction). If you have the username or ID for user(s) which you want to get data. You can use follows methods: diff --git a/docs/mkdocs.yml b/docs/mkdocs.yml index 21cbc3f4..3701f0be 100644 --- a/docs/mkdocs.yml +++ b/docs/mkdocs.yml @@ -83,7 +83,7 @@ nav: extra: social: - icon: fontawesome/brands/twitter - link: https://twitter.com/realllkk520 + link: https://x.com/realllkk520 - icon: fontawesome/brands/github link: https://github.com/sns-sdks/python-twitter diff --git a/pytwitter/api.py b/pytwitter/api.py index a0585fb5..1d9f253a 100644 --- a/pytwitter/api.py +++ b/pytwitter/api.py @@ -27,14 +27,14 @@ class Api: - BASE_URL_V2 = "https://api.twitter.com/2" - BASE_REQUEST_TOKEN_URL = "https://api.twitter.com/oauth/request_token" - BASE_AUTHORIZE_URL = "https://api.twitter.com/oauth/authorize" - BASE_ACCESS_TOKEN_URL = "https://api.twitter.com/oauth/access_token" + BASE_URL_V2 = "https://api.x.com/2" + BASE_REQUEST_TOKEN_URL = "https://api.x.com/oauth/request_token" + BASE_AUTHORIZE_URL = "https://api.x.com/oauth/authorize" + BASE_ACCESS_TOKEN_URL = "https://api.x.com/oauth/access_token" DEFAULT_CALLBACK_URI = "https://localhost/" - BASE_OAUTH2_AUTHORIZE_URL = "https://twitter.com/i/oauth2/authorize" - BASE_OAUTH2_ACCESS_TOKEN_URL = "https://api.twitter.com/2/oauth2/token" - BASE_UPLOAD_URL = "https://upload.twitter.com/1.1" + BASE_OAUTH2_AUTHORIZE_URL = "https://x.com/i/oauth2/authorize" + BASE_OAUTH2_ACCESS_TOKEN_URL = "https://api.x.com/2/oauth2/token" + BASE_UPLOAD_URL = "https://upload.x.com/1.1" DEFAULT_SCOPES = ["users.read", "tweet.read"] def __init__( @@ -264,7 +264,7 @@ def invalidate_access_token(self) -> dict: raise PyTwitterError("Can only revoke oauth1 token") resp = requests.post( - url="https://api.twitter.com/1.1/oauth/invalidate_token", + url="https://api.x.com/1.1/oauth/invalidate_token", ) data = self._parse_response(resp=resp) return data @@ -281,7 +281,7 @@ def generate_bearer_token(self, consumer_key: str, consumer_secret: str) -> dict "Content-Type": "application/x-www-form-urlencoded;charset=UTF-8", } resp = requests.post( - url="https://api.twitter.com/oauth2/token", + url="https://api.x.com/oauth2/token", data={"grant_type": "client_credentials"}, headers=headers, ) @@ -305,7 +305,7 @@ def invalidate_bearer_token( "Content-Type": "application/x-www-form-urlencoded", } resp = requests.post( - url="https://api.twitter.com/oauth2/invalidate_token", + url="https://api.x.com/oauth2/invalidate_token", data={"access_token": access_token}, headers=headers, ) @@ -2014,7 +2014,7 @@ def search_users( ), } return self._get( - url="https://api.twitter.com/2/users/search", + url=f"{self.BASE_URL_V2}/users/search", params=args, cls=md.User, multi=True, diff --git a/pytwitter/models/compliance.py b/pytwitter/models/compliance.py index c292e831..86cee13e 100644 --- a/pytwitter/models/compliance.py +++ b/pytwitter/models/compliance.py @@ -13,7 +13,7 @@ class ComplianceJob(BaseModel): """ A class representing the job for compliance. - Refer: https://developer.twitter.com/en/docs/twitter-api/compliance/batch-compliance/api-reference/get-compliance-jobs-id + Refer: https://developer.x.com/en/docs/twitter-api/compliance/batch-compliance/api-reference/get-compliance-jobs-id """ id: Optional[str] = field(default=None) diff --git a/pytwitter/models/dm_event.py b/pytwitter/models/dm_event.py index 3958be02..a1c8a843 100644 --- a/pytwitter/models/dm_event.py +++ b/pytwitter/models/dm_event.py @@ -1,7 +1,7 @@ """ Direct Message events - Refer: https://developer.twitter.com/en/docs/twitter-api/data-dictionary/object-model/dm-events + Refer: https://developer.x.com/en/docs/twitter-api/data-dictionary/object-model/dm-events """ from dataclasses import dataclass, field diff --git a/pytwitter/models/ext.py b/pytwitter/models/ext.py index 2f6f92d1..423eec13 100644 --- a/pytwitter/models/ext.py +++ b/pytwitter/models/ext.py @@ -1,7 +1,7 @@ """ extends objects - Refer: https://developer.twitter.com/en/docs/twitter-api/expansions + Refer: https://developer.x.com/en/docs/twitter-api/expansions """ from dataclasses import dataclass, field @@ -89,7 +89,7 @@ class Includes(BaseModel): class TweetCount(BaseModel): """ A class representing the counts for tweets match a search query. - Refer: https://developer.twitter.com/en/docs/twitter-api/tweets/counts/api-reference/get-tweets-counts-recent + Refer: https://developer.x.com/en/docs/twitter-api/tweets/counts/api-reference/get-tweets-counts-recent """ start: Optional[str] = field(default=None) diff --git a/pytwitter/models/list.py b/pytwitter/models/list.py index 5d846a85..fe45967c 100644 --- a/pytwitter/models/list.py +++ b/pytwitter/models/list.py @@ -1,7 +1,7 @@ """ Model for list. - Refer: https://developer.twitter.com/en/docs/twitter-api/lists/manage-lists/api-reference/post-lists + Refer: https://developer.x.com/en/docs/twitter-api/lists/manage-lists/api-reference/post-lists """ from dataclasses import dataclass, field diff --git a/pytwitter/models/media.py b/pytwitter/models/media.py index da60fc51..6ce4636e 100644 --- a/pytwitter/models/media.py +++ b/pytwitter/models/media.py @@ -1,7 +1,7 @@ """ Media object - Refer: https://developer.twitter.com/en/docs/twitter-api/data-dictionary/object-model/media + Refer: https://developer.x.com/en/docs/twitter-api/data-dictionary/object-model/media """ from dataclasses import dataclass, field diff --git a/pytwitter/models/media_upload.py b/pytwitter/models/media_upload.py index b73e4c3d..c25c50dd 100644 --- a/pytwitter/models/media_upload.py +++ b/pytwitter/models/media_upload.py @@ -1,7 +1,7 @@ """ Media upload response object: - Refer: https://developer.twitter.com/en/docs/twitter-api/v1/media/upload-media/api-reference/post-media-upload + Refer: https://developer.x.com/en/docs/twitter-api/v1/media/upload-media/api-reference/post-media-upload """ from dataclasses import dataclass, field diff --git a/pytwitter/models/place.py b/pytwitter/models/place.py index 9d500100..8720f011 100644 --- a/pytwitter/models/place.py +++ b/pytwitter/models/place.py @@ -1,7 +1,7 @@ """ Place object - Refer: https://developer.twitter.com/en/docs/twitter-api/data-dictionary/object-model/place + Refer: https://developer.x.com/en/docs/twitter-api/data-dictionary/object-model/place """ from dataclasses import dataclass, field, make_dataclass diff --git a/pytwitter/models/poll.py b/pytwitter/models/poll.py index eca990ea..415e82db 100644 --- a/pytwitter/models/poll.py +++ b/pytwitter/models/poll.py @@ -1,7 +1,7 @@ """ Poll object - Refer: https://developer.twitter.com/en/docs/twitter-api/data-dictionary/object-model/poll + Refer: https://developer.x.com/en/docs/twitter-api/data-dictionary/object-model/poll """ from dataclasses import dataclass, field diff --git a/pytwitter/models/space.py b/pytwitter/models/space.py index bfcdcdd7..9d2b9046 100644 --- a/pytwitter/models/space.py +++ b/pytwitter/models/space.py @@ -1,7 +1,7 @@ """ Space object. - Refer: https://developer.twitter.com/en/docs/twitter-api/data-dictionary/object-model/space + Refer: https://developer.x.com/en/docs/twitter-api/data-dictionary/object-model/space """ from dataclasses import dataclass, field diff --git a/pytwitter/models/trend.py b/pytwitter/models/trend.py index 06127b5e..704f8975 100644 --- a/pytwitter/models/trend.py +++ b/pytwitter/models/trend.py @@ -1,6 +1,6 @@ """ Trend Object - Refer: https://developer.twitter.com/en/docs/twitter-api/trends/api-reference/get-trends-by-woeid + Refer: https://developer.x.com/en/docs/twitter-api/trends/api-reference/get-trends-by-woeid """ from dataclasses import dataclass, field diff --git a/pytwitter/models/tweet.py b/pytwitter/models/tweet.py index b03350c5..524a7186 100644 --- a/pytwitter/models/tweet.py +++ b/pytwitter/models/tweet.py @@ -1,7 +1,7 @@ """ tweet object - Refer: https://developer.twitter.com/en/docs/twitter-api/data-dictionary/object-model/tweet + Refer: https://developer.x.com/en/docs/twitter-api/data-dictionary/object-model/tweet """ import textwrap @@ -44,7 +44,7 @@ class TweetEditControls(BaseModel): @dataclass class TweetContextAnnotation(BaseModel): """ - Refer https://developer.twitter.com/en/docs/twitter-api/annotations + Refer https://developer.x.com/en/docs/twitter-api/annotations """ domain: Optional[TweetContextAnnotationDomain] = field( @@ -151,7 +151,7 @@ class TweetPublicMetrics(BaseModel): @dataclass class TweetWithheld(BaseModel): """ - refer: https://help.twitter.com/en/rules-and-policies/tweet-withheld-by-country + refer: https://help.x.com/en/rules-and-policies/tweet-withheld-by-country """ copyright: Optional[bool] = field(default=None, repr=False) diff --git a/pytwitter/models/usage.py b/pytwitter/models/usage.py index 33dad138..f29d2124 100644 --- a/pytwitter/models/usage.py +++ b/pytwitter/models/usage.py @@ -1,6 +1,6 @@ """ Usage object - Refer:https://developer.twitter.com/en/docs/twitter-api/usage/tweets/api-reference/get-usage-tweets + Refer:https://developer.x.com/en/docs/twitter-api/usage/tweets/api-reference/get-usage-tweets """ from dataclasses import dataclass, field diff --git a/pytwitter/models/user.py b/pytwitter/models/user.py index 940c9f53..46f34c0f 100644 --- a/pytwitter/models/user.py +++ b/pytwitter/models/user.py @@ -1,7 +1,7 @@ """ user object - Refer: https://developer.twitter.com/en/docs/twitter-api/data-dictionary/object-model/user + Refer: https://developer.x.com/en/docs/twitter-api/data-dictionary/object-model/user """ from dataclasses import dataclass, field @@ -61,7 +61,7 @@ class PublicMetrics(BaseModel): @dataclass class UserWithheld(BaseModel): """ - refer: https://help.twitter.com/en/rules-and-policies/tweet-withheld-by-country + refer: https://help.x.com/en/rules-and-policies/tweet-withheld-by-country """ scope: Optional[str] = field(default=None) diff --git a/pytwitter/rate_limit.py b/pytwitter/rate_limit.py index a1ce91e7..b9e2f07e 100644 --- a/pytwitter/rate_limit.py +++ b/pytwitter/rate_limit.py @@ -1,7 +1,7 @@ """ Twitter API Rate Limit. - Refer: https://developer.twitter.com/en/docs/twitter-api/rate-limits + Refer: https://developer.x.com/en/docs/twitter-api/rate-limits """ import logging @@ -453,7 +453,7 @@ def get_limit(self, auth_type, method="GET"): class RateLimit: """ API rate limit. - Refer: https://developer.twitter.com/en/docs/twitter-api/rate-limits + Refer: https://developer.x.com/en/docs/twitter-api/rate-limits """ def __init__(self, auth_type="app"): diff --git a/pytwitter/streaming.py b/pytwitter/streaming.py index c8f26396..c1c1b1cb 100644 --- a/pytwitter/streaming.py +++ b/pytwitter/streaming.py @@ -19,7 +19,7 @@ class StreamApi: - BASE_URL = "https://api.twitter.com/2" + BASE_URL = "https://api.x.com/2" def __init__( self, @@ -78,7 +78,7 @@ def generate_bearer_token(consumer_key: str, consumer_secret: str) -> dict: "Content-Type": "application/x-www-form-urlencoded;charset=UTF-8", } resp = requests.post( - url="https://api.twitter.com/oauth2/token", + url="https://api.x.com/oauth2/token", data={"grant_type": "client_credentials"}, headers=headers, ) @@ -163,7 +163,7 @@ def on_tweet(self, tweet): def on_keep_alive(self): """ - Refer: https://developer.twitter.com/en/docs/twitter-api/tweets/sampled-stream/integrate/handling-disconnections + Refer: https://developer.x.com/en/docs/twitter-api/tweets/sampled-stream/integrate/handling-disconnections :return: """ logger.debug("Received keep alive signal") @@ -354,7 +354,7 @@ def manage_rules( Add or delete rules to your stream. :param rules: Json body for your rules. - See more detail: https://developer.twitter.com/en/docs/twitter-api/tweets/filtered-stream/api-reference/post-tweets-search-stream-rules + See more detail: https://developer.x.com/en/docs/twitter-api/tweets/filtered-stream/api-reference/post-tweets-search-stream-rules :param dry_run: Set to true can test the syntax of your rules without submitting it. :param return_json: Type for returned data. If you set True JSON data will be returned. :return: Response object or json data diff --git a/tests/apis/test_auth.py b/tests/apis/test_auth.py index 1a08b28f..65703582 100644 --- a/tests/apis/test_auth.py +++ b/tests/apis/test_auth.py @@ -12,9 +12,7 @@ def test_generate_bearer_token(api, helpers): token_data = helpers.load_json_data("testdata/apis/authflow/bearer_token.json") - responses.add( - responses.POST, url="https://api.twitter.com/oauth2/token", json=token_data - ) + responses.add(responses.POST, url="https://api.x.com/oauth2/token", json=token_data) # test initial by app Api( @@ -41,7 +39,7 @@ def test_invalidate_bearer_token(api, helpers): responses.add( responses.POST, - url="https://api.twitter.com/oauth2/invalidate_token", + url="https://api.x.com/oauth2/invalidate_token", json=token_data, ) @@ -76,7 +74,7 @@ def test_user_auth(): def test_oauth_flow(): responses.add( responses.POST, - url="https://api.twitter.com/oauth/request_token", + url="https://api.x.com/oauth/request_token", json={ "oauth_token": "uid-token", "oauth_token_secret": "oauth token secret", @@ -96,7 +94,7 @@ def test_oauth_flow(): responses.add( responses.POST, - url="https://api.twitter.com/oauth/access_token", + url="https://api.x.com/oauth/access_token", json={ "oauth_token": "uid-token", "oauth_token_secret": "oauth token secret", @@ -121,7 +119,7 @@ def test_oauth_flow(): def test_oauth_uid(): responses.add( responses.POST, - url="https://api.twitter.com/oauth/request_token", + url="https://api.x.com/oauth/request_token", json={ "oauth_token": "uid-token", "oauth_token_secret": "oauth token secret", @@ -137,7 +135,7 @@ def test_oauth_uid(): responses.add( responses.POST, - url="https://api.twitter.com/oauth/access_token", + url="https://api.x.com/oauth/access_token", json={ "oauth_token": "uid-token", "oauth_token_secret": "oauth token secret", @@ -165,7 +163,7 @@ def test_invalidate_access_token(): ) responses.add( responses.POST, - url="https://api.twitter.com/1.1/oauth/invalidate_token", + url="https://api.x.com/1.1/oauth/invalidate_token", json={"access_token": "ACCESS_TOKEN"}, ) @@ -191,7 +189,7 @@ def test_oauth2_flow(): responses.add( responses.POST, - url="https://api.twitter.com/2/oauth2/token", + url="https://api.x.com/2/oauth2/token", json={ "token_type": "bearer", "expires_in": 7200, diff --git a/tests/apis/test_compliance_job.py b/tests/apis/test_compliance_job.py index 0de32f58..6af5dc8e 100644 --- a/tests/apis/test_compliance_job.py +++ b/tests/apis/test_compliance_job.py @@ -12,7 +12,7 @@ def test_get_compliance_job(api, helpers): responses.add( responses.GET, - url=f"https://api.twitter.com/2/compliance/jobs/{job_id}", + url=f"https://api.x.com/2/compliance/jobs/{job_id}", json=helpers.load_json_data("testdata/apis/compliance_jobs/job_resp.json"), ) @@ -24,7 +24,7 @@ def test_get_compliance_job(api, helpers): def test_get_compliance_jobs(api, helpers): responses.add( responses.GET, - url=f"https://api.twitter.com/2/compliance/jobs", + url=f"https://api.x.com/2/compliance/jobs", json=helpers.load_json_data("testdata/apis/compliance_jobs/jobs_resp.json"), ) @@ -37,7 +37,7 @@ def test_get_compliance_jobs(api, helpers): def test_create_compliance_job(api, helpers): responses.add( responses.POST, - url=f"https://api.twitter.com/2/compliance/jobs", + url=f"https://api.x.com/2/compliance/jobs", json=helpers.load_json_data( "testdata/apis/compliance_jobs/create_job_resp.json" ), diff --git a/tests/apis/test_dm_events.py b/tests/apis/test_dm_events.py index 4467095c..44f714ea 100644 --- a/tests/apis/test_dm_events.py +++ b/tests/apis/test_dm_events.py @@ -14,7 +14,7 @@ def test_get_dm_events_by_participant(api_with_user, helpers): responses.add( responses.GET, - url=f"https://api.twitter.com/2/dm_conversations/with/{participant_id}/dm_events", + url=f"https://api.x.com/2/dm_conversations/with/{participant_id}/dm_events", json=events_data, ) @@ -34,7 +34,7 @@ def test_get_dm_events_by_conversation(api_with_user, helpers): responses.add( responses.GET, - url=f"https://api.twitter.com/2/dm_conversations/{dm_conversation_id}/dm_events", + url=f"https://api.x.com/2/dm_conversations/{dm_conversation_id}/dm_events", json=events_data, ) @@ -51,7 +51,7 @@ def test_get_dm_events(api_with_user, helpers): responses.add( responses.GET, - url=f"https://api.twitter.com/2/dm_events", + url=f"https://api.x.com/2/dm_events", json=events_data, ) @@ -68,7 +68,7 @@ def test_create_message_to_participant(api_with_user, helpers): responses.add( responses.POST, - url=f"https://api.twitter.com/2/dm_conversations/with/{participant_id}/messages", + url=f"https://api.x.com/2/dm_conversations/with/{participant_id}/messages", json=data, ) resp = api_with_user.create_message_to_participant( @@ -86,7 +86,7 @@ def test_create_message_to_conversation(api_with_user, helpers): responses.add( responses.POST, - url=f"https://api.twitter.com/2/dm_conversations/{dm_conversation_id}/messages", + url=f"https://api.x.com/2/dm_conversations/{dm_conversation_id}/messages", json=data, ) resp = api_with_user.create_message_to_conversation( @@ -102,7 +102,7 @@ def test_create_conversation(api_with_user, helpers): data = helpers.load_json_data("testdata/apis/dm_events/events_create.json") responses.add( responses.POST, - url=f"https://api.twitter.com/2/dm_conversations", + url=f"https://api.x.com/2/dm_conversations", json=data, ) resp = api_with_user.create_conversation( diff --git a/tests/apis/test_follows.py b/tests/apis/test_follows.py index 25601e45..bfec40ee 100644 --- a/tests/apis/test_follows.py +++ b/tests/apis/test_follows.py @@ -12,7 +12,7 @@ def test_get_followings(api, helpers): responses.add( responses.GET, - url=f"https://api.twitter.com/2/users/{user_id}/following", + url=f"https://api.x.com/2/users/{user_id}/following", json=following_data, ) @@ -34,7 +34,7 @@ def test_get_followers(api, helpers): responses.add( responses.GET, - url=f"https://api.twitter.com/2/users/{user_id}/followers", + url=f"https://api.x.com/2/users/{user_id}/followers", json=followers_data, ) @@ -56,7 +56,7 @@ def test_follow_user(api_with_user): responses.add( responses.POST, - url=f"https://api.twitter.com/2/users/{user_id}/following", + url=f"https://api.x.com/2/users/{user_id}/following", json={"data": {"following": True, "pending_follow": False}}, ) @@ -71,7 +71,7 @@ def test_unfollow_user(api_with_user): responses.add( responses.DELETE, - url=f"https://api.twitter.com/2/users/{user_id}/following/{target_user_id}", + url=f"https://api.x.com/2/users/{user_id}/following/{target_user_id}", json={"data": {"following": False}}, ) diff --git a/tests/apis/test_hidden_reply.py b/tests/apis/test_hidden_reply.py index dfb7b673..1f0e83b9 100644 --- a/tests/apis/test_hidden_reply.py +++ b/tests/apis/test_hidden_reply.py @@ -11,7 +11,7 @@ def test_hidden_reply(api_with_user): responses.add( responses.PUT, - url=f"https://api.twitter.com/2/tweets/{tweet_id}/hidden", + url=f"https://api.x.com/2/tweets/{tweet_id}/hidden", json={"data": {"hidden": True}}, ) @@ -25,7 +25,7 @@ def test_unhide_reply(api_with_user): responses.add( responses.PUT, - url=f"https://api.twitter.com/2/tweets/{tweet_id}/hidden", + url=f"https://api.x.com/2/tweets/{tweet_id}/hidden", json={"data": {"hidden": False}}, ) hide_resp = api_with_user.hidden_reply(tweet_id=tweet_id, hidden=False) diff --git a/tests/apis/test_lists.py b/tests/apis/test_lists.py index 43352e83..48054ef3 100644 --- a/tests/apis/test_lists.py +++ b/tests/apis/test_lists.py @@ -10,7 +10,7 @@ def test_get_list(api, helpers): list_id = "84839422" responses.add( responses.GET, - url=f"https://api.twitter.com/2/lists/{list_id}", + url=f"https://api.x.com/2/lists/{list_id}", json=helpers.load_json_data("testdata/apis/lists/list_resp.json"), ) @@ -24,7 +24,7 @@ def test_get_user_owned_lists(api, helpers): responses.add( responses.GET, - url=f"https://api.twitter.com/2/users/{user_id}/owned_lists", + url=f"https://api.x.com/2/users/{user_id}/owned_lists", json=helpers.load_json_data("testdata/apis/lists/user_lists_resp.json"), ) @@ -42,7 +42,7 @@ def test_get_user_owned_lists(api, helpers): def test_create_list(api_with_user, helpers): responses.add( responses.POST, - url="https://api.twitter.com/2/lists", + url="https://api.x.com/2/lists", json={"data": {"id": "1441162269824405510", "name": "test v2 create list"}}, ) @@ -62,7 +62,7 @@ def test_update_list(api_with_user, helpers): list_id = "1441162269824405510" responses.add( responses.PUT, - url=f"https://api.twitter.com/2/lists/{list_id}", + url=f"https://api.x.com/2/lists/{list_id}", json={"data": {"updated": True}}, ) @@ -80,7 +80,7 @@ def test_delete_list(api_with_user, helpers): list_id = "1441162269824405510" responses.add( responses.DELETE, - url=f"https://api.twitter.com/2/lists/{list_id}", + url=f"https://api.x.com/2/lists/{list_id}", json={"data": {"deleted": True}}, ) @@ -93,7 +93,7 @@ def test_get_list_tweets(api, helpers): list_id = "84839422" responses.add( responses.GET, - url=f"https://api.twitter.com/2/lists/{list_id}/tweets", + url=f"https://api.x.com/2/lists/{list_id}/tweets", json=helpers.load_json_data("testdata/apis/lists/list_tweets_resp.json"), ) @@ -109,7 +109,7 @@ def test_get_list_members(api, helpers): list_id = "84839422" responses.add( responses.GET, - url=f"https://api.twitter.com/2/lists/{list_id}/members", + url=f"https://api.x.com/2/lists/{list_id}/members", json=helpers.load_json_data("testdata/apis/lists/list_members_resp.json"), ) @@ -128,7 +128,7 @@ def test_get_user_memberships_lists(api, helpers): user_id = "84839422" responses.add( responses.GET, - url=f"https://api.twitter.com/2/users/{user_id}/list_memberships", + url=f"https://api.x.com/2/users/{user_id}/list_memberships", json=helpers.load_json_data( "testdata/apis/lists/user_memberships_lists_resp.json" ), @@ -150,7 +150,7 @@ def test_add_member_to_list(api_with_user, helpers): user_id = "2244994945" responses.add( responses.POST, - url=f"https://api.twitter.com/2/lists/{list_id}/members", + url=f"https://api.x.com/2/lists/{list_id}/members", json={"data": {"is_member": True}}, ) @@ -164,7 +164,7 @@ def test_remove_member_to_list(api_with_user, helpers): user_id = "2244994945" responses.add( responses.DELETE, - url=f"https://api.twitter.com/2/lists/{list_id}/members/{user_id}", + url=f"https://api.x.com/2/lists/{list_id}/members/{user_id}", json={"data": {"is_member": False}}, ) @@ -177,7 +177,7 @@ def test_get_list_followers(api, helpers): list_id = "84839422" responses.add( responses.GET, - url=f"https://api.twitter.com/2/lists/{list_id}/followers", + url=f"https://api.x.com/2/lists/{list_id}/followers", json=helpers.load_json_data("testdata/apis/lists/list_followers_resp.json"), ) @@ -196,7 +196,7 @@ def test_get_user_followed_lists(api, helpers): user_id = "2244994945" responses.add( responses.GET, - url=f"https://api.twitter.com/2/users/{user_id}/followed_lists", + url=f"https://api.x.com/2/users/{user_id}/followed_lists", json=helpers.load_json_data( "testdata/apis/lists/user_followed_lists_resp.json" ), @@ -218,7 +218,7 @@ def test_follow_list(api_with_user, helpers): user_id = "2244994945" responses.add( responses.POST, - url=f"https://api.twitter.com/2/users/{user_id}/followed_lists", + url=f"https://api.x.com/2/users/{user_id}/followed_lists", json={"data": {"following": True}}, ) @@ -232,7 +232,7 @@ def test_unfollow_list(api_with_user, helpers): user_id = "2244994945" responses.add( responses.DELETE, - url=f"https://api.twitter.com/2/users/{user_id}/followed_lists/{list_id}", + url=f"https://api.x.com/2/users/{user_id}/followed_lists/{list_id}", json={"data": {"following": False}}, ) @@ -245,7 +245,7 @@ def test_get_user_pinned_lists(api, helpers): user_id = "2244994945" responses.add( responses.GET, - url=f"https://api.twitter.com/2/users/{user_id}/pinned_lists", + url=f"https://api.x.com/2/users/{user_id}/pinned_lists", json=helpers.load_json_data("testdata/apis/lists/user_pinned_lists_resp.json"), ) @@ -265,7 +265,7 @@ def test_pin_list(api_with_user, helpers): user_id = "2244994945" responses.add( responses.POST, - url=f"https://api.twitter.com/2/users/{user_id}/pinned_lists", + url=f"https://api.x.com/2/users/{user_id}/pinned_lists", json={"data": {"pinned": True}}, ) @@ -279,7 +279,7 @@ def test_unpin_list(api_with_user, helpers): user_id = "2244994945" responses.add( responses.DELETE, - url=f"https://api.twitter.com/2/users/{user_id}/pinned_lists/{list_id}", + url=f"https://api.x.com/2/users/{user_id}/pinned_lists/{list_id}", json={"data": {"pinned": False}}, ) diff --git a/tests/apis/test_media_upload.py b/tests/apis/test_media_upload.py index 90637be7..b1d2165c 100644 --- a/tests/apis/test_media_upload.py +++ b/tests/apis/test_media_upload.py @@ -17,7 +17,7 @@ def test_media_upload_simple(api_with_user, helpers): responses.add( responses.POST, - url="https://upload.twitter.com/1.1/media/upload.json", + url="https://upload.x.com/1.1/media/upload.json", json=helpers.load_json_data( "testdata/apis/media_upload/upload_simple_resp.json" ), @@ -44,7 +44,7 @@ def test_media_upload_simple(api_with_user, helpers): def test_upload_media_chunked_init(api_with_user, helpers): responses.add( responses.POST, - url="https://upload.twitter.com/1.1/media/upload.json", + url="https://upload.x.com/1.1/media/upload.json", json=helpers.load_json_data( "testdata/apis/media_upload/upload_chunk_init_resp.json" ), @@ -75,7 +75,7 @@ def test_upload_media_chunked_append(api_with_user, helpers): responses.add( responses.POST, - url="https://upload.twitter.com/1.1/media/upload.json", + url="https://upload.x.com/1.1/media/upload.json", ) with open("testdata/apis/media_upload/xaa", "rb") as media: @@ -97,7 +97,7 @@ def test_upload_media_chunked_append(api_with_user, helpers): responses.add( responses.POST, - url="https://upload.twitter.com/1.1/media/upload.json", + url="https://upload.x.com/1.1/media/upload.json", status=401, json={"errors": [{"code": 32, "message": "Could not authenticate you."}]}, ) @@ -115,7 +115,7 @@ def test_upload_media_chunked_finalize(api_with_user, helpers): responses.add( responses.POST, - url="https://upload.twitter.com/1.1/media/upload.json", + url="https://upload.x.com/1.1/media/upload.json", json=helpers.load_json_data( "testdata/apis/media_upload/upload_chunk_finalize_resp.json" ), @@ -139,7 +139,7 @@ def test_upload_media_chunked_status(api_with_user, helpers): responses.add( responses.GET, - url="https://upload.twitter.com/1.1/media/upload.json", + url="https://upload.x.com/1.1/media/upload.json", json=helpers.load_json_data( "testdata/apis/media_upload/upload_chunk_status_resp.json" ), diff --git a/tests/apis/test_media_upload_v2.py b/tests/apis/test_media_upload_v2.py index 29386005..c0b1abac 100644 --- a/tests/apis/test_media_upload_v2.py +++ b/tests/apis/test_media_upload_v2.py @@ -15,7 +15,7 @@ def test_media_upload_simple_v2(api_with_user, helpers): responses.add( responses.POST, - url="https://api.twitter.com/2/media/upload", + url="https://api.x.com/2/media/upload", json=helpers.load_json_data( "testdata/apis/media_upload_v2/upload_simple_resp.json" ), @@ -40,7 +40,7 @@ def test_media_upload_simple_v2(api_with_user, helpers): def test_upload_media_chunked_init_v2(api_with_user, helpers): responses.add( responses.POST, - url="https://api.twitter.com/2/media/upload/initialize", + url="https://api.x.com/2/media/upload/initialize", json=helpers.load_json_data( "testdata/apis/media_upload_v2/upload_chunk_init_resp.json" ), @@ -68,7 +68,7 @@ def test_upload_media_chunked_append_v2(api_with_user, helpers): responses.add( responses.POST, - url=f"https://api.twitter.com/2/media/upload/{media_id}/append", + url=f"https://api.x.com/2/media/upload/{media_id}/append", ) with open("testdata/apis/media_upload/x-logo.png", "rb") as media: @@ -88,7 +88,7 @@ def test_upload_media_chunked_append_v2(api_with_user, helpers): responses.add( responses.POST, - url=f"https://api.twitter.com/2/media/upload/{media_id}/append", + url=f"https://api.x.com/2/media/upload/{media_id}/append", status=401, json={"errors": [{"code": 32, "message": "Could not authenticate you."}]}, ) @@ -106,7 +106,7 @@ def test_upload_media_chunked_finalize_v2(api_with_user, helpers): responses.add( responses.POST, - url=f"https://api.twitter.com/2/media/upload/{media_id}/finalize", + url=f"https://api.x.com/2/media/upload/{media_id}/finalize", json=helpers.load_json_data( "testdata/apis/media_upload_v2/upload_chunk_finalize_resp.json" ), @@ -130,7 +130,7 @@ def test_upload_media_chunked_status_v2(api_with_user, helpers): responses.add( responses.GET, - url="https://api.twitter.com/2/media/upload", + url="https://api.x.com/2/media/upload", json=helpers.load_json_data( "testdata/apis/media_upload_v2/upload_chunk_status_resp.json" ), diff --git a/tests/apis/test_search.py b/tests/apis/test_search.py index 643f54b3..fe848e53 100644 --- a/tests/apis/test_search.py +++ b/tests/apis/test_search.py @@ -18,7 +18,7 @@ def test_search_tweets(api, helpers): ) responses.add( responses.GET, - url="https://api.twitter.com/2/tweets/search/recent", + url="https://api.x.com/2/tweets/search/recent", json=tweets_data, ) resp = api.search_tweets( @@ -34,7 +34,7 @@ def test_search_tweets(api, helpers): ) responses.add( responses.GET, - url="https://api.twitter.com/2/tweets/search/all", + url="https://api.x.com/2/tweets/search/all", json=tweets_data, ) resp = api.search_tweets( diff --git a/tests/apis/test_space.py b/tests/apis/test_space.py index 0e607f27..01327fd1 100644 --- a/tests/apis/test_space.py +++ b/tests/apis/test_space.py @@ -11,7 +11,7 @@ def test_get_space(api, helpers): responses.add( responses.GET, - url=f"https://api.twitter.com/2/spaces/{space_id}", + url=f"https://api.x.com/2/spaces/{space_id}", json=helpers.load_json_data("testdata/apis/space/space_resp.json"), ) @@ -25,7 +25,7 @@ def test_get_spaces(api, helpers): responses.add( responses.GET, - url=f"https://api.twitter.com/2/spaces", + url=f"https://api.x.com/2/spaces", json=helpers.load_json_data("testdata/apis/space/spaces_resp.json"), ) @@ -40,7 +40,7 @@ def test_get_spaces_by_creators(api, helpers): responses.add( responses.GET, - url=f"https://api.twitter.com/2/spaces/by/creator_ids", + url=f"https://api.x.com/2/spaces/by/creator_ids", json=helpers.load_json_data("testdata/apis/space/spaces_by_creators.json"), ) @@ -54,7 +54,7 @@ def test_get_spaces_by_creators(api, helpers): def test_search_spaces(api, helpers): responses.add( responses.GET, - url=f"https://api.twitter.com/2/spaces/search", + url=f"https://api.x.com/2/spaces/search", json=helpers.load_json_data("testdata/apis/space/spaces_search_resp.json"), ) @@ -73,7 +73,7 @@ def test_get_buyers_by_space(api, helpers): space_id = "1DXxyRYNejbKM" responses.add( responses.GET, - url=f"https://api.twitter.com/2/spaces/{space_id}/buyers", + url=f"https://api.x.com/2/spaces/{space_id}/buyers", json=helpers.load_json_data("testdata/apis/space/buyers_by_space.json"), ) @@ -92,7 +92,7 @@ def test_get_tweets_by_space(api, helpers): space_id = "1DXxyRYNejbKM" responses.add( responses.GET, - url=f"https://api.twitter.com/2/spaces/{space_id}/tweets", + url=f"https://api.x.com/2/spaces/{space_id}/tweets", json=helpers.load_json_data("testdata/apis/space/tweets_by_space.json"), ) diff --git a/tests/apis/test_timelines.py b/tests/apis/test_timelines.py index 27f828c6..7fbd0bd4 100644 --- a/tests/apis/test_timelines.py +++ b/tests/apis/test_timelines.py @@ -14,7 +14,7 @@ def test_get_timelines(api, helpers): responses.add( responses.GET, - url=f"https://api.twitter.com/2/users/{user_id}/tweets", + url=f"https://api.x.com/2/users/{user_id}/tweets", json=timelines_data, ) @@ -39,7 +39,7 @@ def test_get_timelines_reverse_chronological(api_with_user, helpers): responses.add( responses.GET, - url=f"https://api.twitter.com/2/users/{user_id}/timelines/reverse_chronological", + url=f"https://api.x.com/2/users/{user_id}/timelines/reverse_chronological", json=timelines_data, ) @@ -65,7 +65,7 @@ def test_get_mentions(api, helpers): responses.add( responses.GET, - url=f"https://api.twitter.com/2/users/{user_id}/mentions", + url=f"https://api.x.com/2/users/{user_id}/mentions", json=mentions_data, ) diff --git a/tests/apis/test_trends.py b/tests/apis/test_trends.py index 94c826e8..b757ffa4 100644 --- a/tests/apis/test_trends.py +++ b/tests/apis/test_trends.py @@ -9,7 +9,7 @@ def test_get_trends_by_woeid(api, helpers): responses.add( responses.GET, - url="https://api.twitter.com/2/trends/by/woeid/1", + url="https://api.x.com/2/trends/by/woeid/1", json=helpers.load_json_data("testdata/apis/trends/trends_resp.json"), ) diff --git a/tests/apis/test_tweets.py b/tests/apis/test_tweets.py index 9d799474..896d60c5 100644 --- a/tests/apis/test_tweets.py +++ b/tests/apis/test_tweets.py @@ -14,7 +14,7 @@ def test_get_tweet(api, helpers): responses.add( responses.GET, - url=f"https://api.twitter.com/2/tweets/{tweet_id}", + url=f"https://api.x.com/2/tweets/{tweet_id}", json=tweet_data, ) @@ -45,7 +45,7 @@ def test_get_tweets(api, helpers): responses.add( responses.GET, - url=f"https://api.twitter.com/2/tweets", + url=f"https://api.x.com/2/tweets", json=tweets_data, ) @@ -76,7 +76,7 @@ def test_like_and_unlike_tweet(api_with_user): responses.add( responses.POST, - url=f"https://api.twitter.com/2/users/{user_id}/likes", + url=f"https://api.x.com/2/users/{user_id}/likes", json={"data": {"liked": True}}, ) @@ -85,7 +85,7 @@ def test_like_and_unlike_tweet(api_with_user): responses.add( responses.DELETE, - url=f"https://api.twitter.com/2/users/{user_id}/likes/{tweet_id}", + url=f"https://api.x.com/2/users/{user_id}/likes/{tweet_id}", json={"data": {"liked": False}}, ) @@ -101,7 +101,7 @@ def test_tweet_liking_users(api, helpers): tweet_id = "1395447825366847488" responses.add( responses.GET, - url=f"https://api.twitter.com/2/tweets/{tweet_id}/liking_users", + url=f"https://api.x.com/2/tweets/{tweet_id}/liking_users", json=tweets_data, ) @@ -134,7 +134,7 @@ def test_get_user_bookmarks(api_with_user, helpers): ) responses.add( responses.GET, - url=f"https://api.twitter.com/2/users/{user_id}/bookmarks", + url=f"https://api.x.com/2/users/{user_id}/bookmarks", json=tweets_data, ) @@ -154,7 +154,7 @@ def test_user_bookmark_tweet_or_remove_tweet(api_with_user): responses.add( responses.POST, - url=f"https://api.twitter.com/2/users/{user_id}/bookmarks", + url=f"https://api.x.com/2/users/{user_id}/bookmarks", json={"data": {"bookmarked": True}}, ) @@ -163,7 +163,7 @@ def test_user_bookmark_tweet_or_remove_tweet(api_with_user): responses.add( responses.DELETE, - url=f"https://api.twitter.com/2/users/{user_id}/bookmarks/{tweet_id}", + url=f"https://api.x.com/2/users/{user_id}/bookmarks/{tweet_id}", json={"data": {"bookmarked": False}}, ) @@ -179,7 +179,7 @@ def test_get_tweet_quote_tweets(api, helpers): tweet_id = "1409931481552543749" responses.add( responses.GET, - url=f"https://api.twitter.com/2/tweets/{tweet_id}/quote_tweets", + url=f"https://api.x.com/2/tweets/{tweet_id}/quote_tweets", json=tweets_data, ) @@ -209,7 +209,7 @@ def test_get_tweet_retweeted_tweets(api, helpers): tweet_id = "1720506615714213927" responses.add( responses.GET, - url=f"https://api.twitter.com/2/tweets/{tweet_id}/retweets", + url=f"https://api.x.com/2/tweets/{tweet_id}/retweets", json=tweets_data, ) @@ -249,7 +249,7 @@ def test_get_tweets_count(api, helpers): responses.add( responses.GET, - url="https://api.twitter.com/2/tweets/counts/recent", + url="https://api.x.com/2/tweets/counts/recent", json=recent_counts_data, ) resp = api.get_tweets_counts( @@ -261,7 +261,7 @@ def test_get_tweets_count(api, helpers): responses.add( responses.GET, - url="https://api.twitter.com/2/tweets/counts/all", + url="https://api.x.com/2/tweets/counts/all", json=all_counts_data, ) resp_json = api.get_tweets_counts( @@ -285,7 +285,7 @@ def test_tweet_retweeted_users(api, helpers): tweet_id = "1354143047324299264" responses.add( responses.GET, - url=f"https://api.twitter.com/2/tweets/{tweet_id}/retweeted_by", + url=f"https://api.x.com/2/tweets/{tweet_id}/retweeted_by", json=tweets_data, ) @@ -307,7 +307,7 @@ def test_retweet_remove_retweet_tweet(api_with_user, helpers): responses.add( responses.POST, - url=f"https://api.twitter.com/2/users/{uid}/retweets", + url=f"https://api.x.com/2/users/{uid}/retweets", json={"data": {"retweeted": True}}, ) @@ -316,7 +316,7 @@ def test_retweet_remove_retweet_tweet(api_with_user, helpers): responses.add( responses.DELETE, - url=f"https://api.twitter.com/2/users/{uid}/retweets/{tweet_id}", + url=f"https://api.x.com/2/users/{uid}/retweets/{tweet_id}", json={"data": {"retweeted": False}}, ) @@ -328,7 +328,7 @@ def test_retweet_remove_retweet_tweet(api_with_user, helpers): def test_create_tweet(api_with_user, helpers): responses.add( responses.POST, - url="https://api.twitter.com/2/tweets", + url="https://api.x.com/2/tweets", json=helpers.load_json_data("testdata/apis/tweet/create_tweet_resp.json"), ) @@ -336,7 +336,7 @@ def test_create_tweet(api_with_user, helpers): assert resp.id == "1445880548472328192" resp = api_with_user.create_tweet( - direct_message_deep_link="https://twitter.com/messages/compose?recipient_id=2244994945", + direct_message_deep_link="https://x.com/messages/compose?recipient_id=2244994945", for_super_followers_only=True, geo_place_id="5a110d312052166f", media_media_ids=["1455952740635586573"], @@ -358,7 +358,7 @@ def test_delete_tweet(api_with_user, helpers): responses.add( responses.DELETE, - url=f"https://api.twitter.com/2/tweets/{tweet_id}", + url=f"https://api.x.com/2/tweets/{tweet_id}", json={"data": {"deleted": True}}, ) diff --git a/tests/apis/test_usage.py b/tests/apis/test_usage.py index 7cd7289b..3efcd8d7 100644 --- a/tests/apis/test_usage.py +++ b/tests/apis/test_usage.py @@ -9,7 +9,7 @@ def test_get_usage_tweets(api, helpers): responses.add( responses.GET, - url=f"https://api.twitter.com/2/usage/tweets", + url=f"https://api.x.com/2/usage/tweets", json=helpers.load_json_data("testdata/apis/usage/usage_tweets_resp.json"), ) diff --git a/tests/apis/test_users.py b/tests/apis/test_users.py index e2b798d5..2c471c98 100644 --- a/tests/apis/test_users.py +++ b/tests/apis/test_users.py @@ -14,12 +14,12 @@ def test_get_users(api, helpers): responses.add( responses.GET, - url="https://api.twitter.com/2/users", + url="https://api.x.com/2/users", json=users_data, ) responses.add( responses.GET, - url="https://api.twitter.com/2/users/by", + url="https://api.x.com/2/users/by", json=users_data, ) @@ -69,12 +69,12 @@ def test_get_user(api, helpers): username = "TwitterDev" responses.add( responses.GET, - url=f"https://api.twitter.com/2/users/{user_id}", + url=f"https://api.x.com/2/users/{user_id}", json=users_data, ) responses.add( responses.GET, - url=f"https://api.twitter.com/2/users/by/username/{username}", + url=f"https://api.x.com/2/users/by/username/{username}", json=users_data, ) @@ -104,7 +104,7 @@ def test_get_me(api_with_user, helpers): responses.add( responses.GET, - url="https://api.twitter.com/2/users/me", + url="https://api.x.com/2/users/me", json=me_data, ) @@ -120,7 +120,7 @@ def test_get_me(api_with_user, helpers): def test_search_users(api_with_user, helpers): responses.add( responses.GET, - url="https://api.twitter.com/2/users/search", + url="https://api.x.com/2/users/search", json=helpers.load_json_data("testdata/apis/user/search_users_resp.json"), ) search_resp = api_with_user.search_users( @@ -136,7 +136,7 @@ def test_block_and_unblock_user(api_with_user): responses.add( responses.POST, - url=f"https://api.twitter.com/2/users/{user_id}/blocking", + url=f"https://api.x.com/2/users/{user_id}/blocking", json={"data": {"blocking": True}}, ) @@ -145,7 +145,7 @@ def test_block_and_unblock_user(api_with_user): responses.add( responses.DELETE, - url=f"https://api.twitter.com/2/users/{user_id}/blocking/{target_user_id}", + url=f"https://api.x.com/2/users/{user_id}/blocking/{target_user_id}", json={"data": {"blocking": False}}, ) @@ -159,7 +159,7 @@ def test_block_and_unblock_user_dm(api_with_user): responses.add( method=responses.POST, - url=f"https://api.twitter.com/2/users/{target_user_id}/dm/block", + url=f"https://api.x.com/2/users/{target_user_id}/dm/block", json={"data": {"blocked": True}}, ) resp = api_with_user.block_user_dm(target_user_id=target_user_id) @@ -167,7 +167,7 @@ def test_block_and_unblock_user_dm(api_with_user): responses.add( method=responses.POST, - url=f"https://api.twitter.com/2/users/{target_user_id}/dm/unblock", + url=f"https://api.x.com/2/users/{target_user_id}/dm/unblock", json={"data": {"blocked": False}}, ) resp = api_with_user.unblock_user_dm(target_user_id=target_user_id) @@ -183,7 +183,7 @@ def test_get_blocking_users(api_with_user, helpers): user_id = "2244994945" responses.add( responses.GET, - url=f"https://api.twitter.com/2/users/{user_id}/blocking", + url=f"https://api.x.com/2/users/{user_id}/blocking", json=users_data, ) @@ -214,7 +214,7 @@ def test_get_user_liked_tweets(api_with_user, helpers): user_id = "1301152652357595137" responses.add( responses.GET, - url=f"https://api.twitter.com/2/users/{user_id}/liked_tweets", + url=f"https://api.x.com/2/users/{user_id}/liked_tweets", json=tweets_data, ) @@ -244,7 +244,7 @@ def test_get_muting(api_with_user, helpers): user_id = "1324848235714736129" responses.add( responses.GET, - url=f"https://api.twitter.com/2/users/{user_id}/muting", + url=f"https://api.x.com/2/users/{user_id}/muting", json=muting_data, ) @@ -274,7 +274,7 @@ def test_mute_and_unmute_user(api_with_user): responses.add( responses.POST, - url=f"https://api.twitter.com/2/users/{user_id}/muting", + url=f"https://api.x.com/2/users/{user_id}/muting", json={"data": {"muting": True}}, ) @@ -283,7 +283,7 @@ def test_mute_and_unmute_user(api_with_user): responses.add( responses.DELETE, - url=f"https://api.twitter.com/2/users/{user_id}/muting/{target_user_id}", + url=f"https://api.x.com/2/users/{user_id}/muting/{target_user_id}", json={"data": {"muting": False}}, ) diff --git a/tests/streams/test_auth.py b/tests/streams/test_auth.py index a2107e07..9ce457ba 100644 --- a/tests/streams/test_auth.py +++ b/tests/streams/test_auth.py @@ -17,9 +17,7 @@ def test_initial_api(helpers): api = StreamApi(bearer_token="bearer token") token_data = helpers.load_json_data("testdata/apis/authflow/bearer_token.json") - responses.add( - responses.POST, url="https://api.twitter.com/oauth2/token", json=token_data - ) + responses.add(responses.POST, url="https://api.x.com/oauth2/token", json=token_data) api = StreamApi(consumer_key="consumer key", consumer_secret="consumer secret") @@ -28,7 +26,7 @@ def test_initial_api(helpers): def test_generate_token(): responses.add( responses.POST, - url="https://api.twitter.com/oauth2/token", + url="https://api.x.com/oauth2/token", json={ "errors": [ { diff --git a/tests/streams/test_rules.py b/tests/streams/test_rules.py index ff3c512f..cbd6cb5a 100644 --- a/tests/streams/test_rules.py +++ b/tests/streams/test_rules.py @@ -14,7 +14,7 @@ def test_get_rules(stream_api, helpers): responses.add( responses.GET, - url="https://api.twitter.com/2/tweets/search/stream/rules", + url="https://api.x.com/2/tweets/search/stream/rules", json=rules_data, ) @@ -37,25 +37,25 @@ def test_manage_rules(stream_api, helpers): # add rules responses.add( responses.POST, - url="https://api.twitter.com/2/tweets/search/stream/rules", + url="https://api.x.com/2/tweets/search/stream/rules", json=add_rules_data, status=201, ) responses.add( responses.POST, - url="https://api.twitter.com/2/tweets/search/stream/rules", + url="https://api.x.com/2/tweets/search/stream/rules", json=delete_rules_data, status=200, ) responses.add( responses.POST, - url="https://api.twitter.com/2/tweets/search/stream/rules", + url="https://api.x.com/2/tweets/search/stream/rules", json=delete_error_data, status=400, ) responses.add( responses.POST, - url="https://api.twitter.com/2/tweets/search/stream/rules", + url="https://api.x.com/2/tweets/search/stream/rules", json=None, status=200, ) diff --git a/tests/streams/test_stream.py b/tests/streams/test_stream.py index ecb458bb..69ec0dab 100644 --- a/tests/streams/test_stream.py +++ b/tests/streams/test_stream.py @@ -76,7 +76,7 @@ def callback(request): responses.add( responses.CallbackResponse( responses.GET, - url="https://api.twitter.com/2/tweets/sample/stream", + url="https://api.x.com/2/tweets/sample/stream", callback=callback, content_type="application/json", ), @@ -98,7 +98,7 @@ def test_stream_error(patched_time_sleep): responses.add( responses.Response( responses.GET, - url="https://api.twitter.com/2/tweets/search/stream", + url="https://api.x.com/2/tweets/search/stream", content_type="application/json", status=400, ), diff --git a/tests/test_rate_limit.py b/tests/test_rate_limit.py index 2a067198..533b8800 100644 --- a/tests/test_rate_limit.py +++ b/tests/test_rate_limit.py @@ -22,7 +22,7 @@ "x-rate-limit-reset": int(time.time()) + 60 * 5, } -USER_URL = "https://api.twitter.com/2/users/2244994945" +USER_URL = "https://api.x.com/2/users/2244994945" class TestRateLimit: @@ -46,12 +46,12 @@ def test_setter(self): assert d.limit == 300 assert d.remaining == 299 - following_url = "https://api.twitter.com/2/users/123456/following" + following_url = "https://api.x.com/2/users/123456/following" d = user_rate_limit.get_limit(following_url, method="POST") assert d.limit == 15 d = rate_limit.set_limit( - url="https://api.twitter.com/2/users/123456/following", + url="https://api.x.com/2/users/123456/following", headers=self.generate_headers(15, 10, 1612522029), ) assert d.remaining == 10 @@ -66,7 +66,7 @@ def test_getter(self): def test_url_to_resource(self): assert pytwitter.RateLimit.url_to_endpoint(USER_URL).resource == "/users/:id" - other_url = "https://api.twitter.com/2/tests/url" + other_url = "https://api.x.com/2/tests/url" assert pytwitter.RateLimit.url_to_endpoint(other_url).resource == "/tests/url" @patch("time.sleep") @@ -74,7 +74,7 @@ def test_url_to_resource(self): def test_api_sleep(self, patched_time_sleep, helpers): api = pytwitter.Api(bearer_token="bearer token", sleep_on_rate_limit=True) user_id = "123456" - url = f"https://api.twitter.com/2/users/{user_id}" + url = f"https://api.x.com/2/users/{user_id}" users_data = helpers.load_json_data("testdata/apis/user/user_resp.json") responses.add(responses.GET, url=url, json=users_data) diff --git a/tests/test_response.py b/tests/test_response.py index 2b045942..47b144c5 100644 --- a/tests/test_response.py +++ b/tests/test_response.py @@ -12,7 +12,7 @@ def test_parser_response_no_json(api): responses.add( responses.GET, - url="https://api.twitter.com/2/users/123", + url="https://api.x.com/2/users/123", body="", ) with pytest.raises(PyTwitterError): @@ -23,7 +23,7 @@ def test_parser_response_no_json(api): def test_parser_response_not_ok(api): responses.add( responses.GET, - url="https://api.twitter.com/2/users/123", + url="https://api.x.com/2/users/123", json={ "title": "Unauthorized", "type": "about:blank", @@ -40,7 +40,7 @@ def test_parser_response_not_ok(api): def test_parser_response_have_error(api): responses.add( responses.GET, - url="https://api.twitter.com/2/users/123", + url="https://api.x.com/2/users/123", json={ "errors": { "title": "Unauthorized", @@ -56,18 +56,18 @@ def test_parser_response_have_error(api): @responses.activate def test_parser_response_have_reason_error(api): - # Refer: https://developer.twitter.com/en/support/twitter-api/error-troubleshooting + # Refer: https://developer.x.com/en/support/twitter-api/error-troubleshooting responses.add( responses.GET, - url="https://api.twitter.com/2/users/123", + url="https://api.x.com/2/users/123", json={ "client_id": "101010101", "required_enrollment": "Standard Basic", - "registration_url": "https://developer.twitter.com/en/account", + "registration_url": "https://developer.x.com/en/account", "title": "Client Forbidden", "detail": "This request must be made using an approved developer account that is enrolled in the requested endpoint. Learn more by visiting our documentation.", "reason": "client-not-enrolled", - "type": "https://api.twitter.com/2/problems/client-forbidden", + "type": "https://api.x.com/2/problems/client-forbidden", }, ) with pytest.raises(PyTwitterError):