A TypeScript SDK client for the x.com API.
First, install the SDK from npm.
npm install twitter-openapi-typescript-generated --saveNext, try it out.
import {
Configuration,
DefaultApi,
} from 'twitter-openapi-typescript-generated';
import type { GetProfileSpotlightsQueryRequest } from 'twitter-openapi-typescript-generated';
async function example() {
console.log("🚀 Testing twitter-openapi-typescript-generated SDK...");
const config = new Configuration({
// To configure API key authorization: Accept
apiKey: "YOUR API KEY",
// To configure API key authorization: ClientLanguage
apiKey: "YOUR API KEY",
// To configure API key authorization: Priority
apiKey: "YOUR API KEY",
// To configure API key authorization: Referer
apiKey: "YOUR API KEY",
// To configure API key authorization: SecFetchDest
apiKey: "YOUR API KEY",
// To configure API key authorization: SecChUaPlatform
apiKey: "YOUR API KEY",
// To configure API key authorization: SecFetchMode
apiKey: "YOUR API KEY",
// To configure API key authorization: CsrfToken
apiKey: "YOUR API KEY",
// To configure API key authorization: ClientUuid
apiKey: "YOUR API KEY",
// Configure HTTP bearer authorization: BearerAuth
accessToken: "YOUR BEARER TOKEN",
// To configure API key authorization: GuestToken
apiKey: "YOUR API KEY",
// To configure API key authorization: SecChUa
apiKey: "YOUR API KEY",
// To configure API key authorization: CookieGt0
apiKey: "YOUR API KEY",
// To configure API key authorization: ClientTransactionId
apiKey: "YOUR API KEY",
// To configure API key authorization: ActiveUser
apiKey: "YOUR API KEY",
// To configure API key authorization: CookieCt0
apiKey: "YOUR API KEY",
// To configure API key authorization: UserAgent
apiKey: "YOUR API KEY",
// To configure API key authorization: AcceptLanguage
apiKey: "YOUR API KEY",
// To configure API key authorization: SecFetchSite
apiKey: "YOUR API KEY",
// To configure API key authorization: AuthType
apiKey: "YOUR API KEY",
// To configure API key authorization: CookieAuthToken
apiKey: "YOUR API KEY",
// To configure API key authorization: SecChUaMobile
apiKey: "YOUR API KEY",
// To configure API key authorization: AcceptEncoding
apiKey: "YOUR API KEY",
});
const api = new DefaultApi(config);
const body = {
// string
pathQueryId: mzoqrVGwk-YTSGME1dRfXQ,
// string
variables: {"screen_name": "elonmusk"},
// string
features: {},
} satisfies GetProfileSpotlightsQueryRequest;
try {
const data = await api.getProfileSpotlightsQuery(body);
console.log(data);
} catch (error) {
console.error(error);
}
}
// Run the test
example().catch(console.error);All URIs are relative to https://x.com/i/api
| Class | Method | HTTP request | Description |
|---|---|---|---|
| DefaultApi | getProfileSpotlightsQuery | GET /graphql/{pathQueryId}/ProfileSpotlightsQuery | |
| DefaultApi | getTweetResultByRestId | GET /graphql/{pathQueryId}/TweetResultByRestId | |
| OtherApi | other | GET /other | |
| PostApi | postCreateBookmark | POST /graphql/{pathQueryId}/CreateBookmark | |
| PostApi | postCreateRetweet | POST /graphql/{pathQueryId}/CreateRetweet | |
| PostApi | postCreateTweet | POST /graphql/{pathQueryId}/CreateTweet | |
| PostApi | postDeleteBookmark | POST /graphql/{pathQueryId}/DeleteBookmark | |
| PostApi | postDeleteRetweet | POST /graphql/{pathQueryId}/DeleteRetweet | |
| PostApi | postDeleteTweet | POST /graphql/{pathQueryId}/DeleteTweet | |
| PostApi | postFavoriteTweet | POST /graphql/{pathQueryId}/FavoriteTweet | |
| PostApi | postUnfavoriteTweet | POST /graphql/{pathQueryId}/UnfavoriteTweet | |
| TweetApi | getBookmarks | GET /graphql/{pathQueryId}/Bookmarks | |
| TweetApi | getCommunityAboutTimeline | GET /graphql/{pathQueryId}/CommunityAboutTimeline | |
| TweetApi | getCommunityMediaTimeline | GET /graphql/{pathQueryId}/CommunityMediaTimeline | |
| TweetApi | getCommunityTweetsTimeline | GET /graphql/{pathQueryId}/CommunityTweetsTimeline | |
| TweetApi | getHomeLatestTimeline | GET /graphql/{pathQueryId}/HomeLatestTimeline | |
| TweetApi | getHomeTimeline | GET /graphql/{pathQueryId}/HomeTimeline | |
| TweetApi | getLikes | GET /graphql/{pathQueryId}/Likes | |
| TweetApi | getListLatestTweetsTimeline | GET /graphql/{pathQueryId}/ListLatestTweetsTimeline | |
| TweetApi | getNotificationsTimeline | GET /graphql/{pathQueryId}/NotificationsTimeline | |
| TweetApi | getSearchTimeline | GET /graphql/{pathQueryId}/SearchTimeline | |
| TweetApi | getTweetDetail | GET /graphql/{pathQueryId}/TweetDetail | |
| TweetApi | getUserHighlightsTweets | GET /graphql/{pathQueryId}/UserHighlightsTweets | |
| TweetApi | getUserMedia | GET /graphql/{pathQueryId}/UserMedia | |
| TweetApi | getUserTweets | GET /graphql/{pathQueryId}/UserTweets | |
| TweetApi | getUserTweetsAndReplies | GET /graphql/{pathQueryId}/UserTweetsAndReplies | |
| UserApi | getUserByRestId | GET /graphql/{pathQueryId}/UserByRestId | |
| UserApi | getUserByScreenName | GET /graphql/{pathQueryId}/UserByScreenName | |
| UserListApi | getBlueVerifiedFollowers | GET /graphql/{pathQueryId}/BlueVerifiedFollowers | |
| UserListApi | getFavoriters | GET /graphql/{pathQueryId}/Favoriters | |
| UserListApi | getFollowers | GET /graphql/{pathQueryId}/Followers | |
| UserListApi | getFollowersYouKnow | GET /graphql/{pathQueryId}/FollowersYouKnow | |
| UserListApi | getFollowing | GET /graphql/{pathQueryId}/Following | |
| UserListApi | getRetweeters | GET /graphql/{pathQueryId}/Retweeters | |
| UsersApi | getUsersByRestIds | GET /graphql/{pathQueryId}/UsersByRestIds | |
| V11GetApi | getFriendsFollowingList | GET /1.1/friends/following/list.json | |
| V11GetApi | getSearchTypeahead | GET /1.1/search/typeahead.json | |
| V11PostApi | postCreateFriendships | POST /1.1/friendships/create.json | |
| V11PostApi | postDestroyFriendships | POST /1.1/friendships/destroy.json | |
| V20GetApi | getSearchAdaptive | 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:
user-agent - Location: HTTP header
This TypeScript SDK client supports the Fetch API and is automatically generated by the OpenAPI Generator project:
- API version:
0.0.1 - Package version:
0.0.40 - Generator version:
7.22.0 - Build package:
org.openapitools.codegen.languages.TypeScriptFetchClientCodegen
The generated npm module supports the following:
- Environments
- Node.js
- Webpack
- Browserify
- Language levels
- ES5 - you must have a Promises/A+ library installed
- ES6
- Module systems
- CommonJS
- ES6 module system
To build the TypeScript source code, you need to have Node.js and npm installed. After cloning the repository, navigate to the project directory and run:
npm install
npm run buildOnce you've built the package, you can publish it to npm:
npm publish