mirror of
https://github.com/trevorhobenshield/twitter-api-client.git
synced 2025-12-19 18:12:11 -05:00
added recommendations endpoint
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
__title__ = "twitter-api-client"
|
||||
__description__ = "Implementation of Twitter's v1, v2, and GraphQL APIs."
|
||||
__version__ = "0.10.4"
|
||||
__version__ = "0.10.5"
|
||||
__author__ = "Trevor Hobenshield"
|
||||
__license__ = "MIT"
|
||||
@@ -4,7 +4,6 @@ import logging.config
|
||||
import math
|
||||
import mimetypes
|
||||
import platform
|
||||
import random
|
||||
from copy import deepcopy
|
||||
from datetime import datetime
|
||||
from string import ascii_letters
|
||||
@@ -42,6 +41,7 @@ class Account:
|
||||
self.debug = kwargs.get('debug', 0)
|
||||
self.gql_api = 'https://twitter.com/i/api/graphql'
|
||||
self.v1_api = 'https://api.twitter.com/1.1'
|
||||
self.v2_api = 'https://twitter.com/i/api/2'
|
||||
self.logger = self._init_logger(**kwargs)
|
||||
self.session = self._validate_session(email, username, password, session, **kwargs)
|
||||
|
||||
@@ -791,10 +791,30 @@ class Account:
|
||||
|
||||
def notifications(self, params: dict = None) -> dict:
|
||||
r = self.session.get(
|
||||
'https://twitter.com/i/api/2/notifications/all.json',
|
||||
f'{self.v2_api}/notifications/all.json',
|
||||
headers=get_headers(self.session),
|
||||
params=params or live_notification_params
|
||||
)
|
||||
if self.debug:
|
||||
log(self.logger, self.debug, r)
|
||||
return r.json()
|
||||
|
||||
def recommendations(self, params: dict = None) -> dict:
|
||||
r = self.session.get(
|
||||
f'{self.v1_api}/users/recommendations.json',
|
||||
headers=get_headers(self.session),
|
||||
params=params or recommendations_params
|
||||
)
|
||||
if self.debug:
|
||||
log(self.logger, self.debug, r)
|
||||
return r.json()
|
||||
|
||||
def fleetline(self, params: dict = None) -> dict:
|
||||
r = self.session.get(
|
||||
'https://twitter.com/i/api/fleets/v1/fleetline',
|
||||
headers=get_headers(self.session),
|
||||
params=params or {}
|
||||
)
|
||||
if self.debug:
|
||||
log(self.logger, self.debug, r)
|
||||
return r.json()
|
||||
|
||||
@@ -629,3 +629,23 @@ live_notification_params = params = {
|
||||
"skip_status": "1",
|
||||
"tweet_mode": "extended"
|
||||
}
|
||||
|
||||
recommendations_params = {
|
||||
'include_profile_interstitial_type': '1',
|
||||
'include_blocking': '1',
|
||||
'include_blocked_by': '1',
|
||||
'include_followed_by': '1',
|
||||
'include_want_retweets': '1',
|
||||
'include_mute_edge': '1',
|
||||
'include_can_dm': '1',
|
||||
'include_can_media_tag': '1',
|
||||
'include_ext_has_nft_avatar': '1',
|
||||
'include_ext_is_blue_verified': '1',
|
||||
'include_ext_verified_type': '1',
|
||||
'include_ext_profile_image_shape': '1',
|
||||
'skip_status': '1',
|
||||
'pc': 'true',
|
||||
'display_location': 'profile_accounts_sidebar',
|
||||
'limit': 100,
|
||||
'ext': 'mediaStats,highlightedLabel,hasNftAvatar,voiceInfo,birdwatchPivot,superFollowMetadata,unmentionInfo,editControl'
|
||||
}
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import re
|
||||
import sys
|
||||
|
||||
from httpx import Client
|
||||
|
||||
@@ -2,7 +2,6 @@ import asyncio
|
||||
import logging.config
|
||||
import math
|
||||
import platform
|
||||
import random
|
||||
|
||||
import aiofiles
|
||||
import websockets
|
||||
|
||||
Reference in New Issue
Block a user