@@ -11,50 +11,132 @@ def __init__(self, client: APIClient):
11
11
self .client = client
12
12
13
13
# Fetch tweet detail | 获取推文详情
14
- async def fetch_tweet_detail (self , focalTweetId : str ):
14
+ async def fetch_tweet_detail (self , tweet_id : str ):
15
15
endpoint = "/api/v1/twitter/web/fetch_tweet_detail"
16
- data = await self .client .fetch_get_json (f"{ endpoint } ?focalTweetId= { focalTweetId } " )
16
+ data = await self .client .fetch_get_json (f"{ endpoint } ?tweet_id= { tweet_id } " )
17
17
return data
18
18
19
19
# Fetch user profile | 获取用户资料
20
- async def fetch_user_profile (self , screen_name : str ):
20
+ async def fetch_user_profile (self , screen_name : str = None , rest_id : int = None ):
21
21
endpoint = "/api/v1/twitter/web/fetch_user_profile"
22
- data = await self .client .fetch_get_json (f"{ endpoint } ?screen_name={ screen_name } " )
22
+ params = []
23
+ if screen_name :
24
+ params .append (f"screen_name={ screen_name } " )
25
+ if rest_id :
26
+ params .append (f"rest_id={ rest_id } " )
27
+ query = "&" .join (params )
28
+ data = await self .client .fetch_get_json (f"{ endpoint } ?{ query } " )
23
29
return data
24
30
25
31
# Fetch user post tweet | 获取用户发帖
26
- async def fetch_user_post_tweet (self , userId : str , count : int = 20 , cursor : str = None ):
32
+ async def fetch_user_post_tweet (self , screen_name : str = None , rest_id : int = None , cursor : str = None ):
27
33
endpoint = "/api/v1/twitter/web/fetch_user_post_tweet"
28
- data = await self .client .fetch_get_json (f"{ endpoint } ?userId={ userId } &count={ count } &cursor={ cursor } " )
34
+ params = []
35
+ if screen_name :
36
+ params .append (f"screen_name={ screen_name } " )
37
+ if rest_id :
38
+ params .append (f"rest_id={ rest_id } " )
39
+ if cursor :
40
+ params .append (f"cursor={ cursor } " )
41
+ query = "&" .join (params )
42
+ data = await self .client .fetch_get_json (f"{ endpoint } ?{ query } " )
29
43
return data
30
44
31
- # SearchTimeline | 搜索时间线
32
- async def fetch_search_timeline (self , rawQuery : str , count : int = 20 , product : str = ' Top' , cursor : str = None ):
45
+ # Fetch search timeline | 搜索
46
+ async def fetch_search_timeline (self , keyword : str , search_type : str = " Top" , cursor : str = None ):
33
47
endpoint = "/api/v1/twitter/web/fetch_search_timeline"
34
- data = await self .client .fetch_get_json (f"{ endpoint } ?rawQuery={ rawQuery } &count={ count } &product={ product } &cursor={ cursor } " )
48
+ params = [f"keyword={ keyword } " , f"search_type={ search_type } " ]
49
+ if cursor :
50
+ params .append (f"cursor={ cursor } " )
51
+ query = "&" .join (params )
52
+ data = await self .client .fetch_get_json (f"{ endpoint } ?{ query } " )
35
53
return data
36
54
37
- # Post Comments | 获取评论
38
- async def fetch_post_comments (self , tweetId : str , rankingModel : str = 'Relevance' , cursor : str = None ):
55
+ # Fetch post comments | 获取评论
56
+ async def fetch_post_comments (self , tweet_id : str , cursor : str = None ):
39
57
endpoint = "/api/v1/twitter/web/fetch_post_comments"
40
- data = await self .client .fetch_get_json (f"{ endpoint } ?tweetId={ tweetId } &rankingModel={ rankingModel } &cursor={ cursor } " )
58
+ params = [f"tweet_id={ tweet_id } " ]
59
+ if cursor :
60
+ params .append (f"cursor={ cursor } " )
61
+ query = "&" .join (params )
62
+ data = await self .client .fetch_get_json (f"{ endpoint } ?{ query } " )
63
+ return data
64
+
65
+ # Fetch latest post comments | 获取最新的推文评论
66
+ async def fetch_latest_post_comments (self , tweet_id : str , cursor : str = None ):
67
+ endpoint = "/api/v1/twitter/web/fetch_latest_post_comments"
68
+ params = [f"tweet_id={ tweet_id } " ]
69
+ if cursor :
70
+ params .append (f"cursor={ cursor } " )
71
+ query = "&" .join (params )
72
+ data = await self .client .fetch_get_json (f"{ endpoint } ?{ query } " )
41
73
return data
42
74
43
75
# Fetch user tweet replies | 获取用户推文回复
44
- async def fetch_user_tweet_replies (self , userId : str , count : int = 20 , cursor : str = None ):
76
+ async def fetch_user_tweet_replies (self , screen_name : str , cursor : str = None ):
45
77
endpoint = "/api/v1/twitter/web/fetch_user_tweet_replies"
46
- data = await self .client .fetch_get_json (f"{ endpoint } ?userId={ userId } &count={ count } &cursor={ cursor } " )
78
+ params = [f"screen_name={ screen_name } " ]
79
+ if cursor :
80
+ params .append (f"cursor={ cursor } " )
81
+ query = "&" .join (params )
82
+ data = await self .client .fetch_get_json (f"{ endpoint } ?{ query } " )
47
83
return data
48
84
49
- # UserHighlightsTweets | 获取用户高光推文
50
- async def fetch_user_highlights_tweets (self , userId : str , count : int = 20 , cursor : str = None ):
85
+ # Fetch user highlights tweets | 获取用户高光推文
86
+ async def fetch_user_highlights_tweets (self , user_id : str , count : int = 20 , cursor : str = None ):
51
87
endpoint = "/api/v1/twitter/web/fetch_user_highlights_tweets"
52
- data = await self .client .fetch_get_json (f"{ endpoint } ?userId={ userId } &count={ count } &cursor={ cursor } " )
88
+ params = [f"userId={ user_id } " , f"count={ count } " ]
89
+ if cursor :
90
+ params .append (f"cursor={ cursor } " )
91
+ query = "&" .join (params )
92
+ data = await self .client .fetch_get_json (f"{ endpoint } ?{ query } " )
53
93
return data
54
94
55
- # UserMedia | 获取用户媒体
56
- async def fetch_user_media (self , userId : str , count : int = 20 , cursor : str = None ):
95
+ # Fetch user media | 获取用户媒体
96
+ async def fetch_user_media (self , screen_name : str = None , rest_id : int = None ):
57
97
endpoint = "/api/v1/twitter/web/fetch_user_media"
58
- data = await self .client .fetch_get_json (f"{ endpoint } ?userId={ userId } &count={ count } &cursor={ cursor } " )
98
+ params = []
99
+ if screen_name :
100
+ params .append (f"screen_name={ screen_name } " )
101
+ if rest_id :
102
+ params .append (f"rest_id={ rest_id } " )
103
+ query = "&" .join (params )
104
+ data = await self .client .fetch_get_json (f"{ endpoint } ?{ query } " )
105
+ return data
106
+
107
+ # Fetch retweet user list | 转推用户列表
108
+ async def fetch_retweet_user_list (self , tweet_id : str , cursor : str = None ):
109
+ endpoint = "/api/v1/twitter/web/fetch_retweet_user_list"
110
+ params = [f"tweet_id={ tweet_id } " ]
111
+ if cursor :
112
+ params .append (f"cursor={ cursor } " )
113
+ query = "&" .join (params )
114
+ data = await self .client .fetch_get_json (f"{ endpoint } ?{ query } " )
115
+ return data
116
+
117
+ # Fetch trending | 趋势
118
+ async def fetch_trending (self , country : str = "UnitedStates" ):
119
+ endpoint = "/api/v1/twitter/web/fetch_trending"
120
+ data = await self .client .fetch_get_json (f"{ endpoint } ?country={ country } " )
121
+ return data
122
+
123
+ # Fetch user followings | 用户关注
124
+ async def fetch_user_followings (self , screen_name : str , cursor : str = None ):
125
+ endpoint = "/api/v1/twitter/web/fetch_user_followings"
126
+ params = [f"screen_name={ screen_name } " ]
127
+ if cursor :
128
+ params .append (f"cursor={ cursor } " )
129
+ query = "&" .join (params )
130
+ data = await self .client .fetch_get_json (f"{ endpoint } ?{ query } " )
131
+ return data
132
+
133
+ # Fetch user followers | 用户粉丝
134
+ async def fetch_user_followers (self , screen_name : str , cursor : str = None ):
135
+ endpoint = "/api/v1/twitter/web/fetch_user_followers"
136
+ params = [f"screen_name={ screen_name } " ]
137
+ if cursor :
138
+ params .append (f"cursor={ cursor } " )
139
+ query = "&" .join (params )
140
+ data = await self .client .fetch_get_json (f"{ endpoint } ?{ query } " )
59
141
return data
60
142
0 commit comments