Twitter OpenAPI(Swagger) specification
This Python package is automatically generated by the OpenAPI Generator project:
- API version: 0.0.1
- Package version: 0.0.34
- Generator version: 7.22.0
- Build package: org.openapitools.codegen.languages.PythonClientCodegen
Python 3.10+
If the python package is hosted on a repository, you can install directly using:
pip install git+https://github.com/fa0311/twitter_openapi_python.git(you may need to run pip with root permission: sudo pip install git+https://github.com/fa0311/twitter_openapi_python.git)
Then import the package:
importtwitter_openapi_python_generatedInstall via Setuptools.
python setup.py install --user(or sudo python setup.py install to install the package for all users)
Then import the package:
importtwitter_openapi_python_generatedExecute pytest to run the tests.
Please follow the installation procedure and then run the following:
importtwitter_openapi_python_generatedfromtwitter_openapi_python_generated.restimportApiExceptionfrompprintimportpprint# Defining the host is optional and defaults to https://x.com/i/api# See configuration.py for a list of all supported configuration parameters.configuration=twitter_openapi_python_generated.Configuration(
host="https://x.com/i/api"
)
# The client must configure the authentication and authorization parameters# in accordance with the API server security policy.# Examples for each auth method are provided below, use the example that# satisfies your auth use case.# Configure API key authorization: Acceptconfiguration.api_key['Accept'] =os.environ["API_KEY"]
# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed# configuration.api_key_prefix['Accept'] = 'Bearer'# Configure API key authorization: ClientLanguageconfiguration.api_key['ClientLanguage'] =os.environ["API_KEY"]
# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed# configuration.api_key_prefix['ClientLanguage'] = 'Bearer'# Configure API key authorization: Priorityconfiguration.api_key['Priority'] =os.environ["API_KEY"]
# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed# configuration.api_key_prefix['Priority'] = 'Bearer'# Configure API key authorization: Refererconfiguration.api_key['Referer'] =os.environ["API_KEY"]
# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed# configuration.api_key_prefix['Referer'] = 'Bearer'# Configure API key authorization: SecFetchDestconfiguration.api_key['SecFetchDest'] =os.environ["API_KEY"]
# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed# configuration.api_key_prefix['SecFetchDest'] = 'Bearer'# Configure API key authorization: SecChUaPlatformconfiguration.api_key['SecChUaPlatform'] =os.environ["API_KEY"]
# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed# configuration.api_key_prefix['SecChUaPlatform'] = 'Bearer'# Configure API key authorization: SecFetchModeconfiguration.api_key['SecFetchMode'] =os.environ["API_KEY"]
# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed# configuration.api_key_prefix['SecFetchMode'] = 'Bearer'# Configure API key authorization: CsrfTokenconfiguration.api_key['CsrfToken'] =os.environ["API_KEY"]
# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed# configuration.api_key_prefix['CsrfToken'] = 'Bearer'# Configure API key authorization: ClientUuidconfiguration.api_key['ClientUuid'] =os.environ["API_KEY"]
# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed# configuration.api_key_prefix['ClientUuid'] = 'Bearer'# Configure Bearer authorization: BearerAuthconfiguration=twitter_openapi_python_generated.Configuration(
access_token=os.environ["BEARER_TOKEN"]
)
# Configure API key authorization: GuestTokenconfiguration.api_key['GuestToken'] =os.environ["API_KEY"]
# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed# configuration.api_key_prefix['GuestToken'] = 'Bearer'# Configure API key authorization: SecChUaconfiguration.api_key['SecChUa'] =os.environ["API_KEY"]
# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed# configuration.api_key_prefix['SecChUa'] = 'Bearer'# Configure API key authorization: CookieGt0configuration.api_key['CookieGt0'] =os.environ["API_KEY"]
# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed# configuration.api_key_prefix['CookieGt0'] = 'Bearer'# Configure API key authorization: ClientTransactionIdconfiguration.api_key['ClientTransactionId'] =os.environ["API_KEY"]
# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed# configuration.api_key_prefix['ClientTransactionId'] = 'Bearer'# Configure API key authorization: ActiveUserconfiguration.api_key['ActiveUser'] =os.environ["API_KEY"]
# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed# configuration.api_key_prefix['ActiveUser'] = 'Bearer'# Configure API key authorization: CookieCt0configuration.api_key['CookieCt0'] =os.environ["API_KEY"]
# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed# configuration.api_key_prefix['CookieCt0'] = 'Bearer'# Configure API key authorization: UserAgentconfiguration.api_key['UserAgent'] =os.environ["API_KEY"]
# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed# configuration.api_key_prefix['UserAgent'] = 'Bearer'# Configure API key authorization: AcceptLanguageconfiguration.api_key['AcceptLanguage'] =os.environ["API_KEY"]
# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed# configuration.api_key_prefix['AcceptLanguage'] = 'Bearer'# Configure API key authorization: SecFetchSiteconfiguration.api_key['SecFetchSite'] =os.environ["API_KEY"]
# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed# configuration.api_key_prefix['SecFetchSite'] = 'Bearer'# Configure API key authorization: AuthTypeconfiguration.api_key['AuthType'] =os.environ["API_KEY"]
# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed# configuration.api_key_prefix['AuthType'] = 'Bearer'# Configure API key authorization: CookieAuthTokenconfiguration.api_key['CookieAuthToken'] =os.environ["API_KEY"]
# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed# configuration.api_key_prefix['CookieAuthToken'] = 'Bearer'# Configure API key authorization: SecChUaMobileconfiguration.api_key['SecChUaMobile'] =os.environ["API_KEY"]
# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed# configuration.api_key_prefix['SecChUaMobile'] = 'Bearer'# Configure API key authorization: AcceptEncodingconfiguration.api_key['AcceptEncoding'] =os.environ["API_KEY"]
# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed# configuration.api_key_prefix['AcceptEncoding'] = 'Bearer'# Enter a context with an instance of the API clientwithtwitter_openapi_python_generated.ApiClient(configuration) asapi_client:
# Create an instance of the API classapi_instance=twitter_openapi_python_generated.DefaultApi(api_client)
path_query_id='mzoqrVGwk-YTSGME1dRfXQ'# str | (default to 'mzoqrVGwk-YTSGME1dRfXQ')variables='{"screen_name": "elonmusk"}'# str | (default to '{"screen_name": "elonmusk"}')features='{}'# str | (default to '{}')try:
api_response=api_instance.get_profile_spotlights_query(path_query_id, variables, features)
print("The response of DefaultApi->get_profile_spotlights_query:\n")
pprint(api_response)
exceptApiExceptionase:
print("Exception when calling DefaultApi->get_profile_spotlights_query: %s\n"%e)All URIs are relative to https://x.com/i/api
| Class | Method | HTTP request | Description |
|---|---|---|---|
| DefaultApi | get_profile_spotlights_query | GET /graphql/{pathQueryId}/ProfileSpotlightsQuery | |
| DefaultApi | get_tweet_result_by_rest_id | GET /graphql/{pathQueryId}/TweetResultByRestId | |
| OtherApi | other | GET /other | |
| PostApi | post_create_bookmark | POST /graphql/{pathQueryId}/CreateBookmark | |
| PostApi | post_create_retweet | POST /graphql/{pathQueryId}/CreateRetweet | |
| PostApi | post_create_tweet | POST /graphql/{pathQueryId}/CreateTweet | |
| PostApi | post_delete_bookmark | POST /graphql/{pathQueryId}/DeleteBookmark | |
| PostApi | post_delete_retweet | POST /graphql/{pathQueryId}/DeleteRetweet | |
| PostApi | post_delete_tweet | POST /graphql/{pathQueryId}/DeleteTweet | |
| PostApi | post_favorite_tweet | POST /graphql/{pathQueryId}/FavoriteTweet | |
| PostApi | post_unfavorite_tweet | POST /graphql/{pathQueryId}/UnfavoriteTweet | |
| TweetApi | get_bookmarks | GET /graphql/{pathQueryId}/Bookmarks | |
| TweetApi | get_community_about_timeline | GET /graphql/{pathQueryId}/CommunityAboutTimeline | |
| TweetApi | get_community_media_timeline | GET /graphql/{pathQueryId}/CommunityMediaTimeline | |
| TweetApi | get_community_tweets_timeline | GET /graphql/{pathQueryId}/CommunityTweetsTimeline | |
| TweetApi | get_home_latest_timeline | GET /graphql/{pathQueryId}/HomeLatestTimeline | |
| TweetApi | get_home_timeline | GET /graphql/{pathQueryId}/HomeTimeline | |
| TweetApi | get_likes | GET /graphql/{pathQueryId}/Likes | |
| TweetApi | get_list_latest_tweets_timeline | GET /graphql/{pathQueryId}/ListLatestTweetsTimeline | |
| TweetApi | get_notifications_timeline | GET /graphql/{pathQueryId}/NotificationsTimeline | |
| TweetApi | get_search_timeline | GET /graphql/{pathQueryId}/SearchTimeline | |
| TweetApi | get_tweet_detail | GET /graphql/{pathQueryId}/TweetDetail | |
| TweetApi | get_user_highlights_tweets | GET /graphql/{pathQueryId}/UserHighlightsTweets | |
| TweetApi | get_user_media | GET /graphql/{pathQueryId}/UserMedia | |
| TweetApi | get_user_tweets | GET /graphql/{pathQueryId}/UserTweets | |
| TweetApi | get_user_tweets_and_replies | GET /graphql/{pathQueryId}/UserTweetsAndReplies | |
| UserApi | get_user_by_rest_id | GET /graphql/{pathQueryId}/UserByRestId | |
| UserApi | get_user_by_screen_name | GET /graphql/{pathQueryId}/UserByScreenName | |
| UserListApi | get_blue_verified_followers | GET /graphql/{pathQueryId}/BlueVerifiedFollowers | |
| UserListApi | get_favoriters | GET /graphql/{pathQueryId}/Favoriters | |
| UserListApi | get_followers | GET /graphql/{pathQueryId}/Followers | |
| UserListApi | get_followers_you_know | GET /graphql/{pathQueryId}/FollowersYouKnow | |
| UserListApi | get_following | GET /graphql/{pathQueryId}/Following | |
| UserListApi | get_retweeters | GET /graphql/{pathQueryId}/Retweeters | |
| UsersApi | get_users_by_rest_ids | GET /graphql/{pathQueryId}/UsersByRestIds | |
| V11GetApi | get_friends_following_list | GET /1.1/friends/following/list.json | |
| V11GetApi | get_search_typeahead | GET /1.1/search/typeahead.json | |
| V11PostApi | post_create_friendships | POST /1.1/friendships/create.json | |
| V11PostApi | post_destroy_friendships | POST /1.1/friendships/destroy.json | |
| V20GetApi | get_search_adaptive | GET /2/search/adaptive.json |
- AboutCommunityResult
- AboutCommunityResults
- AboutCommunityTweetData
- AdditionalMediaInfo
- AdditionalMediaInfoCallToActions
- AdditionalMediaInfoCallToActionsUrl
- AllowDownloadStatus
- AnalysisResults
- Article
- ArticleCoverMedia
- ArticleCoverMediaColorInfo
- ArticleCoverMediaColorInfoPalette
- ArticleCoverMediaColorInfoPaletteRGB
- ArticleCoverMediaInfo
- ArticleLifecycleState
- ArticleMetadata
- ArticlePreview
- ArticleResult
- ArticleResults
- AuthorCommunityRelationship
- BirdwatchEntity
- BirdwatchEntityRef
- BirdwatchPivot
- BirdwatchPivotCallToAction
- BirdwatchPivotFooter
- BirdwatchPivotNote
- BirdwatchPivotSubtitle
- BookmarksResponse
- BookmarksResponseData
- BookmarksTimeline
- Callback
- ClientEventInfo
- CommunitiesActions
- Community
- CommunityAboutTimelineResponse
- CommunityActions
- CommunityDeleteActionResult
- CommunityInvitesResult
- CommunityJoinAction
- CommunityJoinActionResultUnion
- CommunityJoinActionUnavailable
- CommunityJoinRequestsResult
- CommunityLeaveActionResult
- CommunityMediaTimelineResponse
- CommunityPinActionResult
- CommunityRelationship
- CommunityResult
- CommunityRule
- CommunityTweetsTimelineResponse
- CommunityUnavailable
- CommunityUnion
- CommunityUnpinActionResult
- CommunityUrls
- CommunityUrlsPermalink
- ContentDisclosure
- ContentDisclosureAdvertisingDisclosure
- ContentDisclosureAiGeneratedDisclosure
- ContentEntryType
- ContentItemType
- ContentUnion
- ConversationControl
- CoverCta
- CreateBookmarkResponse
- CreateBookmarkResponseData
- CreateRetweet
- CreateRetweetResponse
- CreateRetweetResponseData
- CreateRetweetResponseResult
- CreateTweet
- CreateTweetResponse
- CreateTweetResponseData
- CreateTweetResponseResult
- CtaClientEventInfo
- CursorType
- DeleteBookmarkResponse
- DeleteBookmarkResponseData
- DeleteRetweet
- DeleteRetweetResponse
- DeleteRetweetResponseData
- DeleteRetweetResponseResult
- DeleteTweetResponse
- DeleteTweetResponseData
- DeleteTweetResponseResult
- DisplayTreatment
- DisplayType
- Entities
- ErrorExtensions
- ErrorResponse
- ErrorResponsePathInner
- ExtMediaAvailability
- ExtendedEntities
- FavoriteTweet
- FavoriteTweetResponse
- FeedbackInfo
- FollowResponse
- FollowResponseData
- FollowResponseResult
- FollowResponseUser
- FollowTimeline
- GrokAnnotation
- GrokEntity
- GrokEntityRef
- GrokImageAnnotation
- GrokShareAttachment
- GrokShareAttachmentItem
- GrokTranslatedCommunityNote
- GrokTranslatedCommunityNoteWithAvailability
- GrokTranslatedPost
- GrokTranslatedPostWithAvailability
- Highlight
- HomeTimelineHome
- HomeTimelineResponseData
- InstructionType
- InstructionUnion
- ItemContentUnion
- ItemResult
- LimitedActionResultsData
- ListLatestTweetsTimelineResponse
- ListTweetsTimelineData
- ListTweetsTimelineList
- Location
- Media
- MediaCommunityResult
- MediaCommunityResults
- MediaCommunityTweetData
- MediaExtended
- MediaOriginalInfo
- MediaOriginalInfoFocusRect
- MediaResult
- MediaResults
- MediaSize
- MediaSizes
- MediaStats
- MediaVideoInfo
- MediaVideoInfoVariant
- MediaVisibilityResults
- MediaVisibilityResultsBlurredImageInterstitial
- ModuleEntry
- ModuleItem
- NoteTweet
- NoteTweetResult
- NoteTweetResultData
- NoteTweetResultMedia
- NoteTweetResultMediaInlineMedia
- NoteTweetResultRichText
- NoteTweetResultRichTextTag
- NotificationTemplate
- NotificationsResult
- NotificationsTimelineData
- NotificationsTimelineResponse
- NotificationsUserResults
- NotificationsViewerV2
- OneFactorLoginEligibility
- OtherObjectAll
- PostCreateBookmarkRequest
- PostCreateBookmarkRequestVariables
- PostCreateRetweetRequest
- PostCreateRetweetRequestVariables
- PostCreateTweetRequest
- PostCreateTweetRequestFeatures
- PostCreateTweetRequestVariables
- PostCreateTweetRequestVariablesConversationControl
- PostCreateTweetRequestVariablesMedia
- PostCreateTweetRequestVariablesMediaMediaEntitiesInner
- PostCreateTweetRequestVariablesReply
- PostCta
- PostCtaTitleText
- PostCtaTitleTextEntity
- PostCtaTitleTextEntityRef
- PostCtaUserResults
- PostCtaUserResultsAvatar
- PostCtaUserResultsResult
- PostDeleteBookmarkRequest
- PostDeleteRetweetRequest
- PostDeleteRetweetRequestVariables
- PostDeleteTweetRequest
- PostFavoriteTweetRequest
- PostUnfavoriteTweetRequest
- PrimaryCommunityTopic
- ProfileBio
- ProfileResponse
- ProfileResponseData
- QuotedRefResult
- QuotedStatusPermalink
- RankedCommunityResult
- RankedCommunityResults
- RankedCommunityTweetData
- Retweet
- RetweetLegacy
- RichMessage
- SearchByRawQuery
- SearchTimeline
- SearchTimelineData
- SearchTimelineResponse
- SelfThread
- SensitiveMediaWarning
- Session
- Smarttag
- SmarttagTag
- SocialContextLandingUrl
- SocialContextUnion
- SocialContextUnionType
- SuperFollowUserProfile
- SuperFollowsReplyUserResult
- SuperFollowsReplyUserResultCore
- SuperFollowsReplyUserResultData
- SuperFollowsReplyUserResultLegacy
- Text
- TextEntity
- TextEntityRef
- TextHighlight
- ThumbnailImage
- Timeline
- TimelineAddEntries
- TimelineAddEntry
- TimelineAddToModule
- TimelineClearCache
- TimelineClearEntriesUnreadState
- TimelineCommunity
- TimelineCoverBehavior
- TimelineCoverBehaviorUrl
- TimelineGeneralContext
- TimelineHalfCover
- TimelineMarkEntriesUnreadGreaterThanSortIndex
- TimelineMessagePrompt
- TimelineNotification
- TimelinePinEntry
- TimelinePrompt
- TimelineReplaceEntry
- TimelineResponse
- TimelineResult
- TimelineShowAlert
- TimelineShowAlertRichText
- TimelineShowCover
- TimelineTerminateTimeline
- TimelineTimelineCursor
- TimelineTimelineItem
- TimelineTimelineModule
- TimelineTombstone
- TimelineTopicContext
- TimelineTrend
- TimelineTweet
- TimelineUser
- Timestamp
- TombstoneEntity
- TombstoneInfo
- TombstoneRef
- TombstoneRichText
- TopicContext
- Tracing
- TrendImage
- TrendMetadata
- TrendResults
- Tweet
- TweetCard
- TweetCardLegacy
- TweetCardLegacyBindingValue
- TweetCardLegacyBindingValueData
- TweetCardLegacyBindingValueDataImage
- TweetCardPlatform
- TweetCardPlatformAudience
- TweetCardPlatformData
- TweetCardPlatformDevice
- TweetDetailResponse
- TweetDetailResponseData
- TweetEditControl
- TweetEditControlInitial
- TweetEditPrespective
- TweetFavoritersResponse
- TweetFavoritersResponseData
- TweetInterstitial
- TweetInterstitialRevealText
- TweetInterstitialText
- TweetInterstitialTextEntity
- TweetInterstitialTextEntityRef
- TweetLegacy
- TweetLegacyScopes
- TweetLimitedActionResults
- TweetPostCta
- TweetPreviewDisplay
- TweetPreviewDisplayCta
- TweetPreviewDisplayCtaUrl
- TweetPreviewDisplayTweet
- TweetPreviewDisplayTweetViewCount
- TweetPreviousCounts
- TweetResultByRestIdData
- TweetResultByRestIdResponse
- TweetRetweetersResponse
- TweetRetweetersResponseData
- TweetTombstone
- TweetUnavailable
- TweetUnion
- TweetView
- TweetWithVisibilityResults
- TypeName
- UnfavoriteTweet
- UnfavoriteTweetResponse
- UnifiedCard
- Url
- UrtEndpointOptions
- UrtEndpointRequestParams
- User
- UserAvatar
- UserCore
- UserDmPermissions
- UserFeatures
- UserHighlightsInfo
- UserHighlightsTweetsData
- UserHighlightsTweetsResponse
- UserHighlightsTweetsResult
- UserHighlightsTweetsTimeline
- UserHighlightsTweetsUser
- UserLegacy
- UserLegacyExtendedProfile
- UserLegacyExtendedProfileBirthdate
- UserLocation
- UserMediaPermissions
- UserPrivacy
- UserProfessional
- UserProfessionalCategory
- UserProfile
- UserRelationshipPerspectives
- UserResponse
- UserResponseData
- UserResultByScreenName
- UserResultByScreenNameCore
- UserResultByScreenNameLegacy
- UserResultByScreenNameResult
- UserResultCore
- UserResultPrivacy
- UserResultRelationshipPerspectives
- UserResults
- UserTipJarSettings
- UserTweetsData
- UserTweetsResponse
- UserTweetsResultV1
- UserTweetsResultV2
- UserTweetsUser
- UserUnavailable
- UserUnion
- UserValue
- UserVerification
- UserVerificationInfo
- UserVerificationInfoReason
- UserVerificationInfoReasonDescription
- UserVerificationInfoReasonDescriptionEntities
- UserVerificationInfoReasonDescriptionEntitiesRef
- UsersResponse
- UsersResponseData
Authentication schemes defined for the API:
- Type: API key
- API key parameter name: Accept
- Location: HTTP header
- Type: API key
- API key parameter name: Accept-Encoding
- Location: HTTP header
- Type: API key
- API key parameter name: Accept-Language
- Location: HTTP header
- Type: API key
- API key parameter name: x-twitter-active-user
- Location: HTTP header
- Type: API key
- API key parameter name: x-twitter-auth-type
- Location: HTTP header
- Type: Bearer authentication
- Type: API key
- API key parameter name: x-twitter-client-language
- Location: HTTP header
- Type: API key
- API key parameter name: x-client-transaction-id
- Location: HTTP header
- Type: API key
- API key parameter name: x-client-uuid
- Location: HTTP header
- Type: API key
- API key parameter name: auth_token
- Location:
- Type: API key
- API key parameter name: ct0
- Location:
- Type: API key
- API key parameter name: gt0
- Location:
- Type: API key
- API key parameter name: x-csrf-token
- Location: HTTP header
- Type: API key
- API key parameter name: x-guest-token
- Location: HTTP header
- Type: API key
- API key parameter name: Priority
- Location: HTTP header
- Type: API key
- API key parameter name: Referer
- Location: HTTP header
- Type: API key
- API key parameter name: Sec-Ch-Ua
- Location: HTTP header
- Type: API key
- API key parameter name: Sec-Ch-Ua-Mobile
- Location: HTTP header
- Type: API key
- API key parameter name: Sec-Ch-Ua-Platform
- Location: HTTP header
- Type: API key
- API key parameter name: Sec-Fetch-Dest
- Location: HTTP header
- Type: API key
- API key parameter name: Sec-Fetch-Mode
- Location: HTTP header
- Type: API key
- API key parameter name: Sec-Fetch-Site
- Location: HTTP header
- Type: API key
- API key parameter name: user-agent
- Location: HTTP header