twitter-openapi-python 0.1.1__py3-none-any.whl → 0.1.2__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- twitter_openapi_python/api/__init__.py +2 -0
- twitter_openapi_python/api/birdwatch_api.py +116 -0
- twitter_openapi_python/api/community_api.py +149 -0
- twitter_openapi_python/api/default_api.py +75 -0
- twitter_openapi_python/api/tweet_api.py +44 -0
- twitter_openapi_python/api/user_list_api.py +70 -0
- twitter_openapi_python/api/users_api.py +18 -0
- twitter_openapi_python/client.py +9 -1
- {twitter_openapi_python-0.1.1.dist-info → twitter_openapi_python-0.1.2.dist-info}/METADATA +2 -2
- {twitter_openapi_python-0.1.1.dist-info → twitter_openapi_python-0.1.2.dist-info}/RECORD +13 -11
- {twitter_openapi_python-0.1.1.dist-info → twitter_openapi_python-0.1.2.dist-info}/WHEEL +0 -0
- {twitter_openapi_python-0.1.1.dist-info → twitter_openapi_python-0.1.2.dist-info}/licenses/LICENSE +0 -0
- {twitter_openapi_python-0.1.1.dist-info → twitter_openapi_python-0.1.2.dist-info}/licenses/LICENSE.AGPL +0 -0
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
# flake8: noqa
|
|
4
4
|
|
|
5
|
+
from twitter_openapi_python.api.birdwatch_api import BirdwatchApiUtils
|
|
6
|
+
from twitter_openapi_python.api.community_api import CommunityApiUtils
|
|
5
7
|
from twitter_openapi_python.api.default_api import DefaultApiUtils
|
|
6
8
|
from twitter_openapi_python.api.initial_state_api import InitialStateApiUtils
|
|
7
9
|
from twitter_openapi_python.api.post_api import PostApiUtils
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
from typing import Any, Optional
|
|
2
|
+
|
|
3
|
+
import twitter_openapi_python_generated as twitter
|
|
4
|
+
import twitter_openapi_python_generated.models as models
|
|
5
|
+
from x_client_transaction import ClientTransaction
|
|
6
|
+
|
|
7
|
+
from twitter_openapi_python.models import (
|
|
8
|
+
TimelineApiUtilsResponse,
|
|
9
|
+
TweetApiUtilsData,
|
|
10
|
+
TwitterApiUtilsResponse,
|
|
11
|
+
)
|
|
12
|
+
from twitter_openapi_python.utils import (
|
|
13
|
+
data_request,
|
|
14
|
+
error_check,
|
|
15
|
+
timeline_request,
|
|
16
|
+
tweet_entries_converter,
|
|
17
|
+
)
|
|
18
|
+
|
|
19
|
+
ResponseType = TwitterApiUtilsResponse[TimelineApiUtilsResponse[TweetApiUtilsData]]
|
|
20
|
+
ParamType = dict[str, Any]
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
class BirdwatchApiUtils:
|
|
24
|
+
"""Community Notes."""
|
|
25
|
+
|
|
26
|
+
api: twitter.BirdwatchApi
|
|
27
|
+
flag: ParamType
|
|
28
|
+
|
|
29
|
+
def __init__(self, api: twitter.BirdwatchApi, flag: ParamType, ct: ClientTransaction):
|
|
30
|
+
self.api = api
|
|
31
|
+
self.flag = flag
|
|
32
|
+
self.ct = ct
|
|
33
|
+
|
|
34
|
+
def get_birdwatch_fetch_alias_self_select_status(
|
|
35
|
+
self,
|
|
36
|
+
extra_param: Optional[ParamType] = None,
|
|
37
|
+
) -> TwitterApiUtilsResponse[models.BirdwatchAliasSelfSelectStatus]:
|
|
38
|
+
param: ParamType = {}
|
|
39
|
+
if extra_param is not None:
|
|
40
|
+
param.update(extra_param)
|
|
41
|
+
return data_request(
|
|
42
|
+
self.api.get_birdwatch_fetch_alias_self_select_status_with_http_info,
|
|
43
|
+
self.flag["BirdwatchFetchAliasSelfSelectStatus"],
|
|
44
|
+
self.ct,
|
|
45
|
+
lambda e: error_check(e.data, e.errors).authenticated_user_birdwatch_alias_self_select_status,
|
|
46
|
+
param,
|
|
47
|
+
)
|
|
48
|
+
|
|
49
|
+
def get_birdwatch_fetch_authenticated_user_profile(
|
|
50
|
+
self,
|
|
51
|
+
extra_param: Optional[ParamType] = None,
|
|
52
|
+
) -> TwitterApiUtilsResponse[models.BirdwatchProfile]:
|
|
53
|
+
param: ParamType = {}
|
|
54
|
+
if extra_param is not None:
|
|
55
|
+
param.update(extra_param)
|
|
56
|
+
return data_request(
|
|
57
|
+
self.api.get_birdwatch_fetch_authenticated_user_profile_with_http_info,
|
|
58
|
+
self.flag["BirdwatchFetchAuthenticatedUserProfile"],
|
|
59
|
+
self.ct,
|
|
60
|
+
lambda e: error_check(e.data, e.errors).authenticated_user_birdwatch_profile,
|
|
61
|
+
param,
|
|
62
|
+
)
|
|
63
|
+
|
|
64
|
+
def get_birdwatch_fetch_birdwatch_profile(
|
|
65
|
+
self,
|
|
66
|
+
alias: str,
|
|
67
|
+
extra_param: Optional[ParamType] = None,
|
|
68
|
+
) -> TwitterApiUtilsResponse[models.BirdwatchProfile]:
|
|
69
|
+
param: ParamType = {"alias": alias}
|
|
70
|
+
if extra_param is not None:
|
|
71
|
+
param.update(extra_param)
|
|
72
|
+
return data_request(
|
|
73
|
+
self.api.get_birdwatch_fetch_birdwatch_profile_with_http_info,
|
|
74
|
+
self.flag["BirdwatchFetchBirdwatchProfile"],
|
|
75
|
+
self.ct,
|
|
76
|
+
lambda e: error_check(e.data, e.errors).birdwatch_profile_by_alias,
|
|
77
|
+
param,
|
|
78
|
+
)
|
|
79
|
+
|
|
80
|
+
def get_birdwatch_fetch_global_timeline(
|
|
81
|
+
self,
|
|
82
|
+
cursor: Optional[str] = None,
|
|
83
|
+
extra_param: Optional[ParamType] = None,
|
|
84
|
+
) -> ResponseType:
|
|
85
|
+
"""Posts with notes on the Community Notes home page (first tab)."""
|
|
86
|
+
param: ParamType = {}
|
|
87
|
+
if cursor is not None:
|
|
88
|
+
param["cursor"] = cursor
|
|
89
|
+
if extra_param is not None:
|
|
90
|
+
param.update(extra_param)
|
|
91
|
+
return timeline_request(
|
|
92
|
+
self.api.get_birdwatch_fetch_global_timeline_with_http_info,
|
|
93
|
+
self.flag["BirdwatchFetchGlobalTimeline"],
|
|
94
|
+
self.ct,
|
|
95
|
+
lambda e: error_check(
|
|
96
|
+
e.data.viewer.birdwatch_home_page.body.initial_timeline.timeline.timeline, e.errors
|
|
97
|
+
).instructions,
|
|
98
|
+
param,
|
|
99
|
+
tweet_entries_converter,
|
|
100
|
+
)
|
|
101
|
+
|
|
102
|
+
def get_birdwatch_fetch_public_data(
|
|
103
|
+
self,
|
|
104
|
+
extra_param: Optional[ParamType] = None,
|
|
105
|
+
) -> TwitterApiUtilsResponse[models.BirdwatchPublicDataFileBundle]:
|
|
106
|
+
"""Download urls of the latest public data files."""
|
|
107
|
+
param: ParamType = {}
|
|
108
|
+
if extra_param is not None:
|
|
109
|
+
param.update(extra_param)
|
|
110
|
+
return data_request(
|
|
111
|
+
self.api.get_birdwatch_fetch_public_data_with_http_info,
|
|
112
|
+
self.flag["BirdwatchFetchPublicData"],
|
|
113
|
+
self.ct,
|
|
114
|
+
lambda e: error_check(e.data, e.errors).birdwatch_latest_public_data_file_bundle,
|
|
115
|
+
param,
|
|
116
|
+
)
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
from typing import Any, List, Optional
|
|
2
|
+
|
|
3
|
+
import twitter_openapi_python_generated as twitter
|
|
4
|
+
import twitter_openapi_python_generated.models as models
|
|
5
|
+
from x_client_transaction import ClientTransaction
|
|
6
|
+
|
|
7
|
+
from twitter_openapi_python.models import (
|
|
8
|
+
TimelineApiUtilsResponse,
|
|
9
|
+
TweetApiUtilsData,
|
|
10
|
+
TwitterApiUtilsResponse,
|
|
11
|
+
)
|
|
12
|
+
from twitter_openapi_python.utils import (
|
|
13
|
+
data_request,
|
|
14
|
+
error_check,
|
|
15
|
+
timeline_request,
|
|
16
|
+
tweet_entries_converter,
|
|
17
|
+
)
|
|
18
|
+
|
|
19
|
+
ResponseType = TwitterApiUtilsResponse[TimelineApiUtilsResponse[TweetApiUtilsData]]
|
|
20
|
+
ParamType = dict[str, Any]
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
class CommunityApiUtils:
|
|
24
|
+
api: twitter.CommunityApi
|
|
25
|
+
flag: ParamType
|
|
26
|
+
|
|
27
|
+
def __init__(self, api: twitter.CommunityApi, flag: ParamType, ct: ClientTransaction):
|
|
28
|
+
self.api = api
|
|
29
|
+
self.flag = flag
|
|
30
|
+
self.ct = ct
|
|
31
|
+
|
|
32
|
+
def get_communities_fetch_one_query(
|
|
33
|
+
self,
|
|
34
|
+
community_id: str,
|
|
35
|
+
extra_param: Optional[ParamType] = None,
|
|
36
|
+
) -> TwitterApiUtilsResponse[models.CommunityPageCommunity]:
|
|
37
|
+
"""The community page (full members and moderators)."""
|
|
38
|
+
param: ParamType = {"communityId": community_id}
|
|
39
|
+
if extra_param is not None:
|
|
40
|
+
param.update(extra_param)
|
|
41
|
+
return data_request(
|
|
42
|
+
self.api.get_communities_fetch_one_query_with_http_info,
|
|
43
|
+
self.flag["CommunitiesFetchOneQuery"],
|
|
44
|
+
self.ct,
|
|
45
|
+
lambda e: error_check(e.data, e.errors).community_results.result,
|
|
46
|
+
param,
|
|
47
|
+
)
|
|
48
|
+
|
|
49
|
+
def get_community_query(
|
|
50
|
+
self,
|
|
51
|
+
community_id: str,
|
|
52
|
+
extra_param: Optional[ParamType] = None,
|
|
53
|
+
) -> TwitterApiUtilsResponse[models.CommunitySettingsCommunity]:
|
|
54
|
+
"""The community settings / moderation pages (partial users, trending hashtags)."""
|
|
55
|
+
param: ParamType = {"communityId": community_id}
|
|
56
|
+
if extra_param is not None:
|
|
57
|
+
param.update(extra_param)
|
|
58
|
+
return data_request(
|
|
59
|
+
self.api.get_community_query_with_http_info,
|
|
60
|
+
self.flag["CommunityQuery"],
|
|
61
|
+
self.ct,
|
|
62
|
+
lambda e: error_check(e.data, e.errors).community_results.result,
|
|
63
|
+
param,
|
|
64
|
+
)
|
|
65
|
+
|
|
66
|
+
def get_communities_search_query(
|
|
67
|
+
self,
|
|
68
|
+
query: str,
|
|
69
|
+
cursor: Optional[str] = None,
|
|
70
|
+
extra_param: Optional[ParamType] = None,
|
|
71
|
+
) -> TwitterApiUtilsResponse[models.CommunitiesSearchSlice]:
|
|
72
|
+
"""Community cards for a query; the next page is slice_info.next_cursor."""
|
|
73
|
+
param: ParamType = {"query": query}
|
|
74
|
+
if cursor is not None:
|
|
75
|
+
param["cursor"] = cursor
|
|
76
|
+
if extra_param is not None:
|
|
77
|
+
param.update(extra_param)
|
|
78
|
+
return data_request(
|
|
79
|
+
self.api.get_communities_search_query_with_http_info,
|
|
80
|
+
self.flag["CommunitiesSearchQuery"],
|
|
81
|
+
self.ct,
|
|
82
|
+
lambda e: error_check(e.data, e.errors).communities_search_slice,
|
|
83
|
+
param,
|
|
84
|
+
)
|
|
85
|
+
|
|
86
|
+
def get_topic_carousel_query(
|
|
87
|
+
self,
|
|
88
|
+
extra_param: Optional[ParamType] = None,
|
|
89
|
+
) -> TwitterApiUtilsResponse[List[models.CommunityTopic]]:
|
|
90
|
+
param: ParamType = {}
|
|
91
|
+
if extra_param is not None:
|
|
92
|
+
param.update(extra_param)
|
|
93
|
+
return data_request(
|
|
94
|
+
self.api.get_topic_carousel_query_with_http_info,
|
|
95
|
+
self.flag["TopicCarouselQuery"],
|
|
96
|
+
self.ct,
|
|
97
|
+
lambda e: error_check(e.data, e.errors).community_topic_results.community_topics,
|
|
98
|
+
param,
|
|
99
|
+
)
|
|
100
|
+
|
|
101
|
+
def get_global_communities_post_search_timeline(
|
|
102
|
+
self,
|
|
103
|
+
raw_query: str,
|
|
104
|
+
cursor: Optional[str] = None,
|
|
105
|
+
count: Optional[int] = None,
|
|
106
|
+
extra_param: Optional[ParamType] = None,
|
|
107
|
+
) -> ResponseType:
|
|
108
|
+
"""Posts across communities (Top)."""
|
|
109
|
+
param: ParamType = {"rawQuery": raw_query}
|
|
110
|
+
if cursor is not None:
|
|
111
|
+
param["cursor"] = cursor
|
|
112
|
+
if count is not None:
|
|
113
|
+
param["count"] = count
|
|
114
|
+
if extra_param is not None:
|
|
115
|
+
param.update(extra_param)
|
|
116
|
+
return timeline_request(
|
|
117
|
+
self.api.get_global_communities_post_search_timeline_with_http_info,
|
|
118
|
+
self.flag["GlobalCommunitiesPostSearchTimeline"],
|
|
119
|
+
self.ct,
|
|
120
|
+
lambda e: error_check(e.data.search_by_raw_query.communities_posts_search_page.timeline, e.errors).instructions,
|
|
121
|
+
param,
|
|
122
|
+
tweet_entries_converter,
|
|
123
|
+
)
|
|
124
|
+
|
|
125
|
+
def get_global_communities_latest_post_search_timeline(
|
|
126
|
+
self,
|
|
127
|
+
raw_query: str,
|
|
128
|
+
cursor: Optional[str] = None,
|
|
129
|
+
count: Optional[int] = None,
|
|
130
|
+
extra_param: Optional[ParamType] = None,
|
|
131
|
+
) -> ResponseType:
|
|
132
|
+
"""Posts across communities (Latest)."""
|
|
133
|
+
param: ParamType = {"rawQuery": raw_query}
|
|
134
|
+
if cursor is not None:
|
|
135
|
+
param["cursor"] = cursor
|
|
136
|
+
if count is not None:
|
|
137
|
+
param["count"] = count
|
|
138
|
+
if extra_param is not None:
|
|
139
|
+
param.update(extra_param)
|
|
140
|
+
return timeline_request(
|
|
141
|
+
self.api.get_global_communities_latest_post_search_timeline_with_http_info,
|
|
142
|
+
self.flag["GlobalCommunitiesLatestPostSearchTimeline"],
|
|
143
|
+
self.ct,
|
|
144
|
+
lambda e: error_check(
|
|
145
|
+
e.data.search_by_raw_query.communities_latest_posts_search_page.timeline, e.errors
|
|
146
|
+
).instructions,
|
|
147
|
+
param,
|
|
148
|
+
tweet_entries_converter,
|
|
149
|
+
)
|
|
@@ -78,3 +78,78 @@ class DefaultApiUtils:
|
|
|
78
78
|
if response.data is None:
|
|
79
79
|
raise Exception("No tweet")
|
|
80
80
|
return response # type: ignore
|
|
81
|
+
|
|
82
|
+
def get_authenticate_periscope(
|
|
83
|
+
self,
|
|
84
|
+
extra_param: Optional[ParamType] = None,
|
|
85
|
+
) -> TwitterApiUtilsResponse[str]:
|
|
86
|
+
"""A Periscope (live video) token for the account."""
|
|
87
|
+
param: ParamType = {}
|
|
88
|
+
if extra_param is not None:
|
|
89
|
+
param.update(extra_param)
|
|
90
|
+
return self.request(
|
|
91
|
+
apiFn=self.api.get_authenticate_periscope_with_http_info,
|
|
92
|
+
convertFn=lambda x: error_check(x.data, x.errors).authenticate_periscope,
|
|
93
|
+
key="AuthenticatePeriscope",
|
|
94
|
+
param=param,
|
|
95
|
+
)
|
|
96
|
+
|
|
97
|
+
def get_creator_studio_tab_bar_item_query(
|
|
98
|
+
self,
|
|
99
|
+
extra_param: Optional[ParamType] = None,
|
|
100
|
+
) -> TwitterApiUtilsResponse[models.CreatorStudioTabBarItemQueryResponseData]:
|
|
101
|
+
param: ParamType = {}
|
|
102
|
+
if extra_param is not None:
|
|
103
|
+
param.update(extra_param)
|
|
104
|
+
return self.request(
|
|
105
|
+
apiFn=self.api.get_creator_studio_tab_bar_item_query_with_http_info,
|
|
106
|
+
convertFn=lambda x: error_check(x.data, x.errors),
|
|
107
|
+
key="CreatorStudioTabBarItemQuery",
|
|
108
|
+
param=param,
|
|
109
|
+
)
|
|
110
|
+
|
|
111
|
+
def get_data_saver_mode(
|
|
112
|
+
self,
|
|
113
|
+
device_id: Optional[str] = None,
|
|
114
|
+
extra_param: Optional[ParamType] = None,
|
|
115
|
+
) -> TwitterApiUtilsResponse[models.DataSaverModeResponseData]:
|
|
116
|
+
param: ParamType = {}
|
|
117
|
+
if device_id is not None:
|
|
118
|
+
param["device_id"] = device_id
|
|
119
|
+
if extra_param is not None:
|
|
120
|
+
param.update(extra_param)
|
|
121
|
+
return self.request(
|
|
122
|
+
apiFn=self.api.get_data_saver_mode_with_http_info,
|
|
123
|
+
convertFn=lambda x: error_check(x.data, x.errors),
|
|
124
|
+
key="DataSaverMode",
|
|
125
|
+
param=param,
|
|
126
|
+
)
|
|
127
|
+
|
|
128
|
+
def get_grok_home(
|
|
129
|
+
self,
|
|
130
|
+
extra_param: Optional[ParamType] = None,
|
|
131
|
+
) -> TwitterApiUtilsResponse[models.GrokHome]:
|
|
132
|
+
"""Grok model options, prompts and eligibility."""
|
|
133
|
+
param: ParamType = {}
|
|
134
|
+
if extra_param is not None:
|
|
135
|
+
param.update(extra_param)
|
|
136
|
+
return self.request(
|
|
137
|
+
apiFn=self.api.get_grok_home_with_http_info,
|
|
138
|
+
convertFn=lambda x: error_check(x.data, x.errors).grok_home,
|
|
139
|
+
key="GrokHome",
|
|
140
|
+
param=param,
|
|
141
|
+
)
|
|
142
|
+
|
|
143
|
+
def get_pinned_timelines(
|
|
144
|
+
self,
|
|
145
|
+
extra_param: Optional[ParamType] = None,
|
|
146
|
+
) -> TwitterApiUtilsResponse[models.PinnedTimelines]:
|
|
147
|
+
param: ParamType = {}
|
|
148
|
+
if extra_param is not None:
|
|
149
|
+
param.update(extra_param)
|
|
150
|
+
return self.request(
|
|
151
|
+
apiFn=self.api.get_pinned_timelines_with_http_info,
|
|
152
|
+
convertFn=lambda x: error_check(x.data, x.errors).pinned_timelines,
|
|
153
|
+
key="PinnedTimelines",
|
|
154
|
+
param=param,
|
|
155
|
+
)
|
|
@@ -636,3 +636,47 @@ class TweetApiUtils:
|
|
|
636
636
|
param,
|
|
637
637
|
lambda entry: user_result_converter(user_entries_converter(entry)),
|
|
638
638
|
)
|
|
639
|
+
|
|
640
|
+
def get_bookmark_search_timeline(
|
|
641
|
+
self,
|
|
642
|
+
raw_query: str,
|
|
643
|
+
cursor: Optional[str] = None,
|
|
644
|
+
count: Optional[int] = None,
|
|
645
|
+
extra_param: Optional[ParamType] = None,
|
|
646
|
+
) -> ResponseType:
|
|
647
|
+
"""Search the account's bookmarks."""
|
|
648
|
+
param: ParamType = {"rawQuery": raw_query}
|
|
649
|
+
if cursor is not None:
|
|
650
|
+
param["cursor"] = cursor
|
|
651
|
+
if count is not None:
|
|
652
|
+
param["count"] = count
|
|
653
|
+
if extra_param is not None:
|
|
654
|
+
param.update(extra_param)
|
|
655
|
+
|
|
656
|
+
response = self.request(
|
|
657
|
+
apiFn=self.api.get_bookmark_search_timeline_with_http_info,
|
|
658
|
+
convertFn=lambda e: error_check(
|
|
659
|
+
e.data.search_by_raw_query.bookmarks_search_timeline.timeline, e.errors
|
|
660
|
+
).instructions,
|
|
661
|
+
key="BookmarkSearchTimeline",
|
|
662
|
+
param=param,
|
|
663
|
+
)
|
|
664
|
+
return response
|
|
665
|
+
|
|
666
|
+
def get_explore_sidebar(
|
|
667
|
+
self,
|
|
668
|
+
extra_param: Optional[ParamType] = None,
|
|
669
|
+
) -> TrendResponseType:
|
|
670
|
+
"""Trends of the explore sidebar."""
|
|
671
|
+
param: ParamType = {}
|
|
672
|
+
if extra_param is not None:
|
|
673
|
+
param.update(extra_param)
|
|
674
|
+
|
|
675
|
+
return timeline_request(
|
|
676
|
+
self.api.get_explore_sidebar_with_http_info,
|
|
677
|
+
self.flag["ExploreSidebar"],
|
|
678
|
+
self.ct,
|
|
679
|
+
lambda e: error_check(e.data.explore_sidebar.timeline, e.errors).instructions,
|
|
680
|
+
param,
|
|
681
|
+
trend_entries_converter,
|
|
682
|
+
)
|
|
@@ -302,3 +302,73 @@ class UserListApiUtils:
|
|
|
302
302
|
lambda e: error_check(e.data, e.errors).list,
|
|
303
303
|
param,
|
|
304
304
|
)
|
|
305
|
+
|
|
306
|
+
def get_list_search_timeline(
|
|
307
|
+
self,
|
|
308
|
+
raw_query: str,
|
|
309
|
+
cursor: Optional[str] = None,
|
|
310
|
+
count: Optional[int] = None,
|
|
311
|
+
extra_param: Optional[ParamType] = None,
|
|
312
|
+
) -> ListResponseType:
|
|
313
|
+
param: ParamType = {"rawQuery": raw_query}
|
|
314
|
+
if cursor is not None:
|
|
315
|
+
param["cursor"] = cursor
|
|
316
|
+
if count is not None:
|
|
317
|
+
param["count"] = count
|
|
318
|
+
if extra_param is not None:
|
|
319
|
+
param.update(extra_param)
|
|
320
|
+
return timeline_request(
|
|
321
|
+
self.api.get_list_search_timeline_with_http_info,
|
|
322
|
+
self.flag["ListSearchTimeline"],
|
|
323
|
+
self.ct,
|
|
324
|
+
lambda e: error_check(e.data.search_by_raw_query.list_search_timeline.timeline, e.errors).instructions,
|
|
325
|
+
param,
|
|
326
|
+
list_entries_converter,
|
|
327
|
+
)
|
|
328
|
+
|
|
329
|
+
def get_combined_lists(
|
|
330
|
+
self,
|
|
331
|
+
user_id: str,
|
|
332
|
+
cursor: Optional[str] = None,
|
|
333
|
+
count: Optional[int] = None,
|
|
334
|
+
extra_param: Optional[ParamType] = None,
|
|
335
|
+
) -> ListResponseType:
|
|
336
|
+
"""Lists a user owns or follows."""
|
|
337
|
+
param: ParamType = {"userId": user_id}
|
|
338
|
+
if cursor is not None:
|
|
339
|
+
param["cursor"] = cursor
|
|
340
|
+
if count is not None:
|
|
341
|
+
param["count"] = count
|
|
342
|
+
if extra_param is not None:
|
|
343
|
+
param.update(extra_param)
|
|
344
|
+
return timeline_request(
|
|
345
|
+
self.api.get_combined_lists_with_http_info,
|
|
346
|
+
self.flag["CombinedLists"],
|
|
347
|
+
self.ct,
|
|
348
|
+
lambda e: error_check(error_check(e.data.user, e.errors).result.timeline.timeline, e.errors).instructions,
|
|
349
|
+
param,
|
|
350
|
+
list_entries_converter,
|
|
351
|
+
)
|
|
352
|
+
|
|
353
|
+
def get_lists_management_page_timeline(
|
|
354
|
+
self,
|
|
355
|
+
cursor: Optional[str] = None,
|
|
356
|
+
count: Optional[int] = None,
|
|
357
|
+
extra_param: Optional[ParamType] = None,
|
|
358
|
+
) -> ListResponseType:
|
|
359
|
+
"""The account's lists management page."""
|
|
360
|
+
param: ParamType = {}
|
|
361
|
+
if cursor is not None:
|
|
362
|
+
param["cursor"] = cursor
|
|
363
|
+
if count is not None:
|
|
364
|
+
param["count"] = count
|
|
365
|
+
if extra_param is not None:
|
|
366
|
+
param.update(extra_param)
|
|
367
|
+
return timeline_request(
|
|
368
|
+
self.api.get_lists_management_page_timeline_with_http_info,
|
|
369
|
+
self.flag["ListsManagementPageTimeline"],
|
|
370
|
+
self.ct,
|
|
371
|
+
lambda e: error_check(e.data.viewer.list_management_timeline.timeline, e.errors).instructions,
|
|
372
|
+
param,
|
|
373
|
+
list_entries_converter,
|
|
374
|
+
)
|
|
@@ -7,6 +7,7 @@ from x_client_transaction import ClientTransaction
|
|
|
7
7
|
from twitter_openapi_python.models import TwitterApiUtilsResponse, UserApiUtilsData
|
|
8
8
|
from twitter_openapi_python.utils import (
|
|
9
9
|
build_response,
|
|
10
|
+
data_request,
|
|
10
11
|
error_check,
|
|
11
12
|
get_kwargs,
|
|
12
13
|
user_result_converter,
|
|
@@ -54,3 +55,20 @@ class UsersApiUtils:
|
|
|
54
55
|
key="UsersByRestIds",
|
|
55
56
|
param=param,
|
|
56
57
|
)
|
|
58
|
+
|
|
59
|
+
def get_users_verified_avatars(
|
|
60
|
+
self,
|
|
61
|
+
user_ids: list[str],
|
|
62
|
+
extra_param: Optional[ParamType] = None,
|
|
63
|
+
) -> TwitterApiUtilsResponse[list[models.VerifiedAvatarUser]]:
|
|
64
|
+
"""Partial users (avatar shape, verification) for the given ids."""
|
|
65
|
+
param: ParamType = {"userIds": user_ids}
|
|
66
|
+
if extra_param is not None:
|
|
67
|
+
param.update(extra_param)
|
|
68
|
+
return data_request(
|
|
69
|
+
self.api.get_users_verified_avatars_with_http_info,
|
|
70
|
+
self.flag["UsersVerifiedAvatars"],
|
|
71
|
+
self.ct,
|
|
72
|
+
lambda e: [x.result for x in error_check(e.data, e.errors).users_results],
|
|
73
|
+
param,
|
|
74
|
+
)
|
twitter_openapi_python/client.py
CHANGED
|
@@ -8,6 +8,8 @@ import urllib3
|
|
|
8
8
|
from x_client_transaction import ClientTransaction
|
|
9
9
|
|
|
10
10
|
from twitter_openapi_python.api import (
|
|
11
|
+
BirdwatchApiUtils,
|
|
12
|
+
CommunityApiUtils,
|
|
11
13
|
DefaultApiUtils,
|
|
12
14
|
InitialStateApiUtils,
|
|
13
15
|
PostApiUtils,
|
|
@@ -32,6 +34,12 @@ class TwitterOpenapiPythonClient:
|
|
|
32
34
|
self.placeholder = placeholder
|
|
33
35
|
self.ct = ct
|
|
34
36
|
|
|
37
|
+
def get_birdwatch_api(self) -> BirdwatchApiUtils:
|
|
38
|
+
return BirdwatchApiUtils(twitter.BirdwatchApi(self.api), self.placeholder, self.ct)
|
|
39
|
+
|
|
40
|
+
def get_community_api(self) -> CommunityApiUtils:
|
|
41
|
+
return CommunityApiUtils(twitter.CommunityApi(self.api), self.placeholder, self.ct)
|
|
42
|
+
|
|
35
43
|
def get_default_api(self) -> DefaultApiUtils:
|
|
36
44
|
return DefaultApiUtils(twitter.DefaultApi(self.api), self.placeholder, self.ct)
|
|
37
45
|
|
|
@@ -61,7 +69,7 @@ class TwitterOpenapiPythonClient:
|
|
|
61
69
|
|
|
62
70
|
|
|
63
71
|
class TwitterOpenapiPython:
|
|
64
|
-
hash: str = "
|
|
72
|
+
hash: str = "127fa210d7f9b0252276c86a1860a7db816d9d69"
|
|
65
73
|
placeholder_url = "https://raw.githubusercontent.com/fa0311/twitter-openapi/{hash}/src/config/placeholder.json"
|
|
66
74
|
header = "https://raw.githubusercontent.com/fa0311/latest-user-agent/refs/heads/main/header.json"
|
|
67
75
|
access_token: str = (
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: twitter_openapi_python
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.2
|
|
4
4
|
Summary: Twitter OpenAPI
|
|
5
5
|
Keywords: twitter,api,python,scraper
|
|
6
6
|
Author: fa0311
|
|
@@ -8,7 +8,7 @@ Author-email: fa0311 <yuki@yuki0311.com>
|
|
|
8
8
|
License-Expression: LicenseRef-Custom OR AGPL-3.0-or-later
|
|
9
9
|
License-File: LICENSE
|
|
10
10
|
License-File: LICENSE.AGPL
|
|
11
|
-
Requires-Dist: twitter-openapi-python-generated==0.1.
|
|
11
|
+
Requires-Dist: twitter-openapi-python-generated==0.1.2
|
|
12
12
|
Requires-Dist: pydantic>=2.6
|
|
13
13
|
Requires-Dist: requests>=2.31.0,<3.0.0
|
|
14
14
|
Requires-Dist: urllib3>=2.1.0,<3.0.0
|
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
twitter_openapi_python/__init__.py,sha256=IyCanHNVJtKPGaYEMBqF37VXfMtZNUJlPhSOZMvO5jg,324
|
|
2
|
-
twitter_openapi_python/api/__init__.py,sha256=
|
|
3
|
-
twitter_openapi_python/api/
|
|
2
|
+
twitter_openapi_python/api/__init__.py,sha256=1YPsr8wnqlrBFAViXCwYwDdk2kNwA6PMC8DAnsWC62U,772
|
|
3
|
+
twitter_openapi_python/api/birdwatch_api.py,sha256=_SpT0-RU3GhEvYa9Sqf7JpC62kxnE-u0CbUnCHNTrBM,4121
|
|
4
|
+
twitter_openapi_python/api/community_api.py,sha256=hht31A83v3BfqcYa1-H9LyNIKd7UJMUWM9kzMUEJCus,5379
|
|
5
|
+
twitter_openapi_python/api/default_api.py,sha256=iuzWVgQsjZtsa5E6fVXESOJzXVx0u7iVnfGPwjo96hs,5334
|
|
4
6
|
twitter_openapi_python/api/initial_state_api.py,sha256=nAkb25-btWdMoSyyncxS_VrBQ9uKDgzmG7jBubfETYo,2269
|
|
5
7
|
twitter_openapi_python/api/post_api.py,sha256=YSiGjV95AxxxSukZZESVRJ34D8hde6YRjd0Q6ElQ8fE,13166
|
|
6
|
-
twitter_openapi_python/api/tweet_api.py,sha256=
|
|
8
|
+
twitter_openapi_python/api/tweet_api.py,sha256=gBa0-7Pwvfau56SpTuY30t7-7wZ-2txRefW8vTnLZoE,23476
|
|
7
9
|
twitter_openapi_python/api/user_api.py,sha256=CF9ST6jNI54H_ShBZLT-O1uu1h-xkaKKJmcQ0Au0H7g,4477
|
|
8
|
-
twitter_openapi_python/api/user_list_api.py,sha256=
|
|
9
|
-
twitter_openapi_python/api/users_api.py,sha256=
|
|
10
|
+
twitter_openapi_python/api/user_list_api.py,sha256=VNMbvGxwV5t-77-H5x6vs55bcnbnVW5rRk9AjwKk2mw,13061
|
|
11
|
+
twitter_openapi_python/api/users_api.py,sha256=u7jauEpXJ-beXcOl054Vpz8WZOIh2ubma0bPnU5JECY,2440
|
|
10
12
|
twitter_openapi_python/api/v11_get_api.py,sha256=UXe34f6IBYExqWCJ8HCld_8d_ChQb92je0G5VtLxmyM,1978
|
|
11
13
|
twitter_openapi_python/api/v11_post_api.py,sha256=eErGBOo-y4E1AAMIHgeWnc0rAFmc5KgIoipJI-8V0Y8,1781
|
|
12
|
-
twitter_openapi_python/client.py,sha256=
|
|
14
|
+
twitter_openapi_python/client.py,sha256=jeh0TGhNcBjyghnwaSV9Uz6YrmKf_3S1VFAbcgwMv8c,7126
|
|
13
15
|
twitter_openapi_python/models/__init__.py,sha256=pHISZJrEPBlXS25kMydl1SxXuCct-CUpnPDfL7kEEBo,588
|
|
14
16
|
twitter_openapi_python/models/base.py,sha256=3sw6wdQn9i8FoujFxhEFVWIB26-qjI6JTDuXKuebM0Y,189
|
|
15
17
|
twitter_openapi_python/models/header.py,sha256=EKujtBRZOJmeh2SD1QOCsLWaE9gdGY4wsNUgwCnbTCU,644
|
|
@@ -20,8 +22,8 @@ twitter_openapi_python/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSu
|
|
|
20
22
|
twitter_openapi_python/tid.py,sha256=xjqJMyPOp62nw2MQjMGHaB4L6G6OZHuWkMR-WKJo7aU,1120
|
|
21
23
|
twitter_openapi_python/utils/__init__.py,sha256=lIEPoDqtgCvUk0A8cWqdTlTWMhkEp_NbVxL7sJ0uiu8,612
|
|
22
24
|
twitter_openapi_python/utils/api.py,sha256=ytdYSv08LYGCe8gof4DptzhjCkgIBV1uJmJXC9htQnU,12623
|
|
23
|
-
twitter_openapi_python-0.1.
|
|
24
|
-
twitter_openapi_python-0.1.
|
|
25
|
-
twitter_openapi_python-0.1.
|
|
26
|
-
twitter_openapi_python-0.1.
|
|
27
|
-
twitter_openapi_python-0.1.
|
|
25
|
+
twitter_openapi_python-0.1.2.dist-info/licenses/LICENSE,sha256=sLv8EMhrPCMG_LeweYvYKS_B-cDMBwBSKZel7LSMGAs,1493
|
|
26
|
+
twitter_openapi_python-0.1.2.dist-info/licenses/LICENSE.AGPL,sha256=TfPDBt3ar0uv_f9cqCDMZ5rIzW3CY8anRRd4PkL6ejs,34522
|
|
27
|
+
twitter_openapi_python-0.1.2.dist-info/WHEEL,sha256=9IUYslYuG_asT4WlWvfk_K76nveuLvSTKDoLeL0cV-Q,80
|
|
28
|
+
twitter_openapi_python-0.1.2.dist-info/METADATA,sha256=Cm2f6SkQGROikAKlvltINUo-9xUaMtW4i50SOyt5kYY,3232
|
|
29
|
+
twitter_openapi_python-0.1.2.dist-info/RECORD,,
|
|
File without changes
|
{twitter_openapi_python-0.1.1.dist-info → twitter_openapi_python-0.1.2.dist-info}/licenses/LICENSE
RENAMED
|
File without changes
|
|
File without changes
|