core

package
v0.0.0-...-2198c2c Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 21, 2026 License: MIT Imports: 30 Imported by: 0

Documentation

Overview

Package core provides article operations for Twitter/X.

Package core provides batch operations for Twitter/X.

Package core provides bookmark folder operations for Twitter/X.

Package core provides community operations for Twitter/X.

Package core provides direct message operations for Twitter/X.

Package core provides job search operations for Twitter/X.

Package core provides list management operations for Twitter/X.

Package core provides media upload and download operations for Twitter/X.

Package core provides notification operations for Twitter/X. X.com uses REST API v2 for notifications (not GraphQL).

Package core provides poll operations for Twitter/X.

Package core provides quote tweet operations for Twitter/X.

Package core provides scheduled tweet operations for Twitter/X.

Package core provides social action operations (follow, block, mute) for Twitter/X.

Package core provides Twitter Spaces operations for Twitter/X.

Package core provides intelligent caching for API responses

Package core provides core functionality for the xsh Twitter/X client.

Package core provides dynamic GraphQL endpoint discovery from X.com This implementation extracts operation IDs and feature switches from JS bundles similar to the Python version but with Go's concurrency advantages.

Package core provides dynamic endpoint management with auto-discovery This file now delegates all operations to EndpointDiscovery for a unified cache system.

Package core provides proactive endpoint obsolescence detection and auto-update

Package core provides rate limit tracking for Twitter/X API.

Package core provides startup checks for endpoint validity.

Package core provides TLS fingerprinting and HTTP client with browser impersonation. This implements real TLS JA3 fingerprint spoofing using uTLS with HTTP/2 support.

Package core provides transaction ID generation for X.com API requests.

Index

Constants

View Source
const (
	// UploadURL is the Twitter media upload endpoint
	UploadURL = "https://upload.twitter.com/i/media/upload.json"
	// MaxImageSize is the maximum allowed image size (5 MB)
	MaxImageSize = 5 * 1024 * 1024
)
View Source
const (
	BaseURL     = "https://x.com"
	APIBase     = "https://x.com/i/api"
	GraphQLBase = APIBase + "/graphql"
)

Base URLs

View Source
const (
	DefaultCount     = 20
	MaxCount         = 100
	DefaultDelaySec  = 1.5
	MinWriteDelaySec = 1.5
	MaxWriteDelaySec = 4.0
)

Request defaults

View Source
const (
	ExitSuccess   = 0
	ExitError     = 1
	ExitAuthError = 2
	ExitRateLimit = 3
)

Exit codes

View Source
const (
	ConfigDirName  = "xsh"
	ConfigFileName = "config.toml"
	AuthFileName   = "auth.json"
)

Config paths

View Source
const (
	// CacheTTL is the time-to-live for cached endpoints (24 hours like Python)
	CacheTTL = 24 * time.Hour
	// MaxCacheAge is the maximum age before forced refresh
	MaxCacheAge = 7 * 24 * time.Hour
	// HomepageURL is used to discover JS bundles
	HomepageURL = "https://x.com/elonmusk"
	// BundleCDNBase is the base URL for JS bundles
	BundleCDNBase = "https://abs.twimg.com/responsive-web/client-web"
)
View Source
const (
	// APIBaseV1 is the base URL for Twitter REST API v1.1
	APIBaseV1 = "https://x.com/i/api/1.1"
)
View Source
const BearerToken = "AAAAAAAAAAAAAAAAAAAAANRILgAAAAAAnNwIzUejRCOuH5E6I8xnZz4puTs%3D1Zv7ttfk8LF81IUq16cHjhLTvJu4FA33AGWWjCpTnA"

Bearer token (public, embedded in Twitter web app)

View Source
const (
	// DMAPIBase is the base URL for DM API
	DMAPIBase = "https://x.com/i/api/1.1/dm"
)

Variables

View Source
var AllowedImageTypes = map[string]bool{
	"image/jpeg": true,
	"image/png":  true,
	"image/gif":  true,
	"image/webp": true,
}

Allowed image MIME types

ChromeVersions contains all supported Chrome versions for User-Agent rotation

View Source
var DefaultFeatures = map[string]bool{
	"rweb_tipjar_consumption_enabled":                                         true,
	"responsive_web_graphql_exclude_directive_enabled":                        true,
	"verified_phone_label_enabled":                                            false,
	"creator_subscriptions_tweet_preview_api_enabled":                         true,
	"responsive_web_graphql_timeline_navigation_enabled":                      true,
	"responsive_web_graphql_skip_user_profile_image_extensions_enabled":       false,
	"communities_web_enable_tweet_community_results_fetch":                    true,
	"c9s_tweet_anatomy_moderator_badge_enabled":                               true,
	"articles_preview_enabled":                                                true,
	"responsive_web_edit_tweet_api_enabled":                                   true,
	"graphql_is_translatable_rweb_tweet_is_translatable_enabled":              true,
	"view_counts_everywhere_api_enabled":                                      true,
	"longform_notetweets_consumption_enabled":                                 true,
	"responsive_web_twitter_article_tweet_consumption_enabled":                true,
	"tweet_awards_web_tipping_enabled":                                        false,
	"creator_subscriptions_quote_tweet_preview_enabled":                       false,
	"freedom_of_speech_not_reach_fetch_enabled":                               true,
	"standardized_nudges_misinfo":                                             true,
	"tweet_with_visibility_results_prefer_gql_limited_actions_policy_enabled": true,
	"rweb_video_timestamps_enabled":                                           true,
	"longform_notetweets_rich_text_read_enabled":                              true,
	"longform_notetweets_inline_media_enabled":                                true,
	"responsive_web_enhance_cards_enabled":                                    true,
}

DefaultFeatures for GraphQL requests

View Source
var DefaultFieldToggles = map[string]bool{
	"withArticlePlainText": false,
}

DefaultFieldToggles for GraphQL requests

View Source
var GraphQLEndpoints = map[string]string{

	"HomeTimeline":       "gXtpuBkna6SRLFFKaT2OTg/HomeTimeline",
	"HomeLatestTimeline": "JVzDMxTXbT9bRXSpUR16CQ/HomeLatestTimeline",

	"SearchTimeline": "OFvapAUD5xrCWn9xcD0A6A/SearchTimeline",

	"TweetDetail":           "1eAGnXrtvTBUePpQfTXZzA/TweetDetail",
	"TweetResultByRestId":   "tcA4FFMIjGSDv48Cu_FS5Q/TweetResultByRestId",
	"TweetResultsByRestIds": "M441-7OPnT7o_TzVwteU3Q/TweetResultsByRestIds",

	"UserByScreenName":   "pLsOiyHJ1eFwPJlNmLp4Bg/UserByScreenName",
	"UserByRestId":       "FJ17ptkJuQAZGWilcySi5w/UserByRestId",
	"UsersByRestIds":     "8OKmcyotfczJb44QTTu5tQ/UsersByRestIds",
	"UsersByScreenNames": "Ats5GnHiQxT-Nnzw09raMw/UsersByScreenNames",

	"UserTweets":           "5M8UuGym7_VyIEggQIyjxQ/UserTweets",
	"UserTweetsAndReplies": "C3YpYjTsQZznJIdyy2JKuQ/UserTweetsAndReplies",
	"UserMedia":            "mWo2yKjZEaqK7_vKox_67Q/UserMedia",
	"Likes":                "dv5-II7_Bup_PHish7p6fw/Likes",

	"Followers":             "8sIMO3RbSCdvk2QzxcPpIg/Followers",
	"Following":             "lEJDj0bTio9-s0hSukCD9Q/Following",
	"FollowersYouKnow":      "fBi9FJP1haBdGoZuVfZVzQ/FollowersYouKnow",
	"BlueVerifiedFollowers": "ZH16zF8R8YAJAAfIGbef9A/BlueVerifiedFollowers",

	"Bookmarks":              "uKP9v_I31k0_VSBmlpq2Xg/Bookmarks",
	"BookmarkSearchTimeline": "vBCEp1KR36nwY3u2K-2nEA/BookmarkSearchTimeline",
	"BookmarkFoldersSlice":   "i78YDd0Tza-dV4SYs58kRg/BookmarkFoldersSlice",
	"BookmarkFolderTimeline": "hNY7X2xE2N7HVF6Qb_mu6w/BookmarkFolderTimeline",

	"ListLatestTweetsTimeline":    "gNXkRRRV67cSRJkmpgGPnA/ListLatestTweetsTimeline",
	"ListsManagementPageTimeline": "qXWhKTaNeJianB02_JovCg/ListsManagementPageTimeline",
	"ListByRestId":                "bSE1lqLBnovM86uu4p4Iqg/ListByRestId",
	"ListMembers":                 "fqecRWCF4EcSAOs5yXh7Ig/ListMembers",
	"ListMemberships":             "cRsrj8HASXYzxaf90wMDPQ/ListMemberships",

	"JobSearchQueryScreenJobsQuery": "jVMK9qcOUB5xQQdSLr5ECg/JobSearchQueryScreenJobsQuery",
	"JobScreenQuery":                "8uZH_OBKTFNIMzTJaV5lbQ/JobScreenQuery",

	"ExplorePage": "Z6s1tFEq4BveGOj0N80z8g/ExplorePage",
	"Trends":      "Z6s1tFEq4BveGOj0N80z8g/ExplorePage",

	"CreateTweet":     "BLx8gngFhHE5eBgLBCT_0Q/CreateTweet",
	"CreateNoteTweet": "4e-YHiuiNDaITMxa29cerw/CreateNoteTweet",
	"DeleteTweet":     "nxpZCY2K-I6QoFHAHeojFQ/DeleteTweet",

	"FavoriteTweet":   "lI07N6Otwv1PhnEgXILM7A/FavoriteTweet",
	"UnfavoriteTweet": "ZYKSe-w7KEslx3JhSIk5LA/UnfavoriteTweet",

	"CreateRetweet": "mbRO74GrOvSfRcJnlMapnQ/CreateRetweet",
	"DeleteRetweet": "ZyZigVsNiFO6v1dEks1eWg/DeleteRetweet",

	"CreateBookmark": "aoDbu3RHznuiSkQ9aNM67Q/CreateBookmark",
	"DeleteBookmark": "Wlmlj2-xzyS1GN3a6cj-mQ/DeleteBookmark",

	"DMMessageDeleteMutation": "BJ6DtxA2llfjnRoRjaiIiw/DMMessageDeleteMutation",

	"CreateScheduledTweet": "LCVzRQGxOaGnOnYH01NQXg/CreateScheduledTweet",
	"FetchScheduledTweets": "ITtjAzvlZni2wWXwf295Qg/FetchScheduledTweets",
	"DeleteScheduledTweet": "CTOVqej0JBXAZSwkp1US0g/DeleteScheduledTweet",

	"CreateList":       "QXil-VE8uEJPfUKFiO36Bg/CreateList",
	"UpdateList":       "qE2QVWL84jqa6CmH-m-D3w/UpdateList",
	"DeleteList":       "UnN9Th1BDbeLjpgjGSpL3Q/DeleteList",
	"ListAddMember":    "nAi8BAjn1xQOyCH0hWZpPA/ListAddMember",
	"ListRemoveMember": "pGMiwtWRMx08r4XCYxai4Q/ListRemoveMember",
	"PinTimeline":      "t-vQkLuhUq-GvXLbRXXMFA/PinTimeline",
	"UnpinTimeline":    "agrJf0pu-b_3p53wUjZEFA/UnpinTimeline",

	"FollowUser":   "iNZ4xPly3JveJqEshzJdLA/FollowUser",
	"UnfollowUser": "tTT1x7v4h9zLVzT1BA/UnfollowUser",

	"Viewer":             "zWQLM9HIVahRSUvzUH4lDw/Viewer",
	"BlockedAccountsAll": "tnGJ8xjxfnv032LSOpKYWQ/BlockedAccountsAll",
	"MutedAccounts":      "CI5MBQ8KdnNx87ZXOfTsBg/MutedAccounts",

	"CommunitiesMainPageTimeline": "ZYMHvNRSCYjfaxcK_XBIOQ/CommunitiesMainPageTimeline",
	"CommunityByRestId":           "nNjM4SaF_W1Hk0JQ8pOPQg/CommunityByRestId",
	"CommunityTweetsTimeline":     "aeJsV55JMPw15_-N4VCnPA/CommunityTweetsTimeline",
	"JoinCommunity":               "bTM1mhHSML-sKB9EjT0RRg/JoinCommunity",
	"LeaveCommunity":              "OoS6Nd__MZ0LHAiBbmc3gQ/LeaveCommunity",

	"AudioSpaceById":   "Uv5R_x2bBDPMVxfGjkzxtA/AudioSpaceById",
	"AudioSpaceSearch": "NTq79TuSz6fHj8lQaferJw/AudioSpaceSearch",

	"TweetQuotes": "kv6oBLVLyPi0JWVqrY4kJQ/TweetQuotes",
}

GraphQL operation IDs - extracted from X.com JS bundles (updated 2026-04-02) These are fallback values. The actual endpoints are fetched dynamically from X.com and cached in ~/.config/xsh/graphql_ops.json

View Source
var UserAgentVersions = []string{
	"120.0.0.0",
	"123.0.0.0",
	"124.0.0.0",
	"126.0.0.0",
	"127.0.0.0",
	"131.0.0.0",
	"133.0.0.0",
}

UserAgentVersions contains Chrome version strings for User-Agent rotation

View Source
var Verbose = false

Verbose enables detailed logging of HTTP requests and responses

Functions

func AddListMember

func AddListMember(client *XClient, listID, userID string) (map[string]interface{}, error)

AddListMember adds a user to a list

func ArticleToJSON

func ArticleToJSON(articleData map[string]interface{}, tweet *models.Tweet) (string, error)

ArticleToJSON serializes article data to JSON string

func BlockUser

func BlockUser(client *XClient, userID string) (map[string]interface{}, error)

BlockUser blocks a user by their user ID

func BookmarkTweet

func BookmarkTweet(client *XClient, tweetID string) (map[string]interface{}, error)

BookmarkTweet bookmarks a tweet

func CachedRequest

func CachedRequest(operation string, params map[string]interface{}, ttl time.Duration, fetchFunc func() (interface{}, error)) (interface{}, error)

CachedRequest makes a cached request

func CheckEndpointHealth

func CheckEndpointHealth(ctx context.Context, client *XClient) (bool, []string)

CheckEndpointHealth checks if the current endpoints are still valid

func CreateList

func CreateList(client *XClient, name, description string, isPrivate bool) (map[string]interface{}, error)

CreateList creates a new list

func CreatePollCard

func CreatePollCard(client *XClient, choices []string, durationMinutes int) (string, error)

CreatePollCard creates a poll card via the Twitter Cards API and returns the card_uri to be used with CreateTweet. Choices must be 2-4 items, duration is in minutes (min 5, max 10080 = 7 days).

func CreateScheduledTweet

func CreateScheduledTweet(client *XClient, text string, executeAt int64, mediaIDs []string) (map[string]interface{}, error)

CreateScheduledTweet schedules a tweet for future posting

func CreateTweet

func CreateTweet(client *XClient, text, replyToID, quoteTweetURL string, mediaIDs []string, cardURI string) (map[string]interface{}, error)

CreateTweet creates a new tweet

func DeleteDM

func DeleteDM(client *XClient, messageID string) (map[string]interface{}, error)

DeleteDM deletes a DM message

func DeleteList

func DeleteList(client *XClient, listID string) (map[string]interface{}, error)

DeleteList deletes a list

func DeleteScheduledTweet

func DeleteScheduledTweet(client *XClient, scheduledTweetID string) (map[string]interface{}, error)

DeleteScheduledTweet cancels a scheduled tweet

func DeleteTweet

func DeleteTweet(client *XClient, tweetID string) (map[string]interface{}, error)

DeleteTweet deletes a tweet

func DownloadMedia

func DownloadMedia(mediaURL, outputPath string) error

DownloadMedia downloads a file from a URL to the specified path

func DownloadTweetMedia

func DownloadTweetMedia(client *XClient, tweetID, outputDir string) ([]string, error)

DownloadTweetMedia downloads all media from a tweet

func ExportArticleToFile

func ExportArticleToFile(articleData map[string]interface{}, tweet *models.Tweet, outputPath string) error

ExportArticleToFile exports an article to a Markdown file

func FollowUser

func FollowUser(client *XClient, userID string) (map[string]interface{}, error)

FollowUser follows a user by their user ID

func GenerateTransactionIDForRequest

func GenerateTransactionIDForRequest(method, path, operation string) string

GenerateTransactionIDForRequest generates a transaction ID for a specific request

func GetAcceptLanguage

func GetAcceptLanguage() string

GetAcceptLanguage returns the Accept-Language header value

func GetArchitecture

func GetArchitecture() string

GetArchitecture returns the architecture for sec-ch-ua-arch

func GetArticle

func GetArticle(client *XClient, tweetID string) (map[string]interface{}, error)

GetArticle fetches article data for a tweet that contains an article

func GetAuthFile

func GetAuthFile() (string, error)

GetAuthFile returns the path to auth credentials file

func GetBookmarkFolderTimeline

func GetBookmarkFolderTimeline(client *XClient, folderID string, count int, cursor string) (*models.TimelineResponse, error)

GetBookmarkFolderTimeline fetches tweets from a bookmark folder

func GetBookmarks

func GetBookmarks(client *XClient, count int, cursor string) (*models.TimelineResponse, error)

GetBookmarks fetches bookmarked tweets

func GetBrowserCookiePaths

func GetBrowserCookiePaths() map[string][]string

GetBrowserCookiePaths returns possible browser cookie database paths based on OS

func GetCommunityTimeline

func GetCommunityTimeline(client *XClient, communityID string, count int, cursor string) (*models.TimelineResponse, error)

GetCommunityTimeline fetches tweets from a community

func GetConfigDir

func GetConfigDir() (string, error)

GetConfigDir returns the config directory, creating it if needed

func GetConfigPath

func GetConfigPath() (string, error)

GetConfigPath returns the path to the config file

func GetDMInbox

func GetDMInbox(client *XClient) ([]models.DMConversation, error)

GetDMInbox fetches the user's DM inbox

func GetDynamicFeatures

func GetDynamicFeatures() map[string]bool

GetDynamicFeatures returns feature flags from cache

func GetDynamicGraphQLEndpoints

func GetDynamicGraphQLEndpoints() map[string]string

GetDynamicGraphQLEndpoints returns endpoints from cache or fetches new ones

func GetDynamicOpFeatures

func GetDynamicOpFeatures(operation string) []string

GetDynamicOpFeatures returns operation-specific features

func GetEndpoint

func GetEndpoint(operation string) string

GetEndpoint returns a single endpoint

func GetEndpointSuggestion

func GetEndpointSuggestion(operation string) string

GetEndpointSuggestion returns a helpful message for updating endpoints

func GetFollowers

func GetFollowers(client *XClient, userID string, count int, cursor string) ([]*models.User, string, error)

GetFollowers fetches followers of a user

func GetFollowing

func GetFollowing(client *XClient, userID string, count int, cursor string) ([]*models.User, string, error)

GetFollowing fetches users followed by a user

func GetGraphQLEndpoints

func GetGraphQLEndpoints() map[string]string

GetGraphQLEndpoints returns the current endpoint map

func GetHomeTimeline

func GetHomeTimeline(client *XClient, timelineType string, count int, cursor string) (*models.TimelineResponse, error)

GetHomeTimeline fetches home timeline

func GetJobDetail

func GetJobDetail(client *XClient, jobID string) (*models.Job, error)

GetJobDetail fetches detailed information about a specific job

func GetListMembers

func GetListMembers(client *XClient, listID string, count int, cursor string) ([]*models.User, string, error)

GetListMembers fetches members of a list

func GetListTweets

func GetListTweets(client *XClient, listID string, count int, cursor string) (*models.TimelineResponse, error)

GetListTweets fetches tweets from a list

func GetPlatform

func GetPlatform() string

GetPlatform returns the platform string for sec-ch-ua-platform

func GetPlatformVersion

func GetPlatformVersion() string

GetPlatformVersion returns the platform version for sec-ch-ua-platform-version

func GetQuoteTweets

func GetQuoteTweets(client *XClient, tweetID string, count int, cursor string) (*models.TimelineResponse, error)

GetQuoteTweets fetches tweets that quote a specific tweet

func GetSecChUa

func GetSecChUa() string

GetSecChUa returns the current sec-ch-ua header

func GetSecChUaForVersion

func GetSecChUaForVersion(target TLSFingerprintType) string

GetSecChUaForVersion returns the sec-ch-ua header for a specific version

func GetSecChUaFullVersionList

func GetSecChUaFullVersionList() string

GetSecChUaFullVersionList returns the full version list header

func GetSecChUaFullVersionListForVersion

func GetSecChUaFullVersionListForVersion(target TLSFingerprintType) string

GetSecChUaFullVersionListForVersion returns the full version list header for a specific version

func GetTrends

func GetTrends(client *XClient, woeid int) ([]*models.Trend, error)

GetTrends fetches trending topics

func GetTweetDetail

func GetTweetDetail(client *XClient, tweetID string, count int) ([]*models.Tweet, error)

GetTweetDetail fetches a tweet and its conversation thread

func GetTweetsByIDs

func GetTweetsByIDs(client *XClient, tweetIDs []string) ([]*models.Tweet, error)

GetTweetsByIDs fetches multiple tweets by their IDs in a single request

func GetUserAgent

func GetUserAgent() string

GetUserAgent returns the current User-Agent string

func GetUserAgentForVersion

func GetUserAgentForVersion(version TLSFingerprintType) string

GetUserAgentForVersion returns a Chrome User-Agent string for the given version

func GetUserByHandle

func GetUserByHandle(client *XClient, handle string) (*models.User, error)

GetUserByHandle fetches user profile by screen name

func GetUserLikes

func GetUserLikes(client *XClient, userID string, count int, cursor string) (*models.TimelineResponse, error)

GetUserLikes fetches likes from a user

func GetUserTweets

func GetUserTweets(client *XClient, userID string, count int, cursor string, includeReplies bool) (*models.TimelineResponse, error)

GetUserTweets fetches tweets from a user

func GetUsersByHandles

func GetUsersByHandles(client *XClient, handles []string) ([]*models.User, error)

GetUsersByHandles fetches multiple users by their handles

func GetUsersByIDs

func GetUsersByIDs(client *XClient, userIDs []string) ([]*models.User, error)

GetUsersByIDs fetches multiple users by their IDs

func InitializeTransactionGenerator

func InitializeTransactionGenerator(client *http.Client) error

InitializeTransactionGenerator initializes the global transaction generator

func InvalidateCache

func InvalidateCache()

InvalidateCache clears all cached endpoints

func IsEndpointObsolete

func IsEndpointObsolete(err error) bool

IsEndpointObsolete checks if an error indicates an obsolete endpoint

func IsWriteOperation

func IsWriteOperation(operation string) bool

IsWriteOperation returns true for write operations

func JoinCommunity

func JoinCommunity(client *XClient, communityID string) (map[string]interface{}, error)

JoinCommunity joins a community

func LeaveCommunity

func LeaveCommunity(client *XClient, communityID string) (map[string]interface{}, error)

LeaveCommunity leaves a community

func LikeTweet

func LikeTweet(client *XClient, tweetID string) (map[string]interface{}, error)

LikeTweet likes a tweet

func ListAccounts

func ListAccounts() ([]string, error)

ListAccounts lists all stored account names

func MuteUser

func MuteUser(client *XClient, userID string) (map[string]interface{}, error)

MuteUser mutes a user by their user ID

func NeedsTransactionID

func NeedsTransactionID(operation string) bool

NeedsTransactionID returns true for operations that require x-client-transaction-id

func PinList

func PinList(client *XClient, listID string) (map[string]interface{}, error)

PinList pins a list to the user's profile

func RefreshEndpoints

func RefreshEndpoints() error

RefreshEndpoints forces a refresh of all endpoints

func RefreshEndpointsGlobal

func RefreshEndpointsGlobal() error

RefreshEndpointsGlobal triggers a refresh of all endpoints

func RemoveAuth

func RemoveAuth(account string) error

RemoveAuth removes an account from storage

func RemoveListMember

func RemoveListMember(client *XClient, listID, userID string) (map[string]interface{}, error)

RemoveListMember removes a user from a list

func Retweet

func Retweet(client *XClient, tweetID string) (map[string]interface{}, error)

Retweet retweets a tweet

func RunStartupCheck

func RunStartupCheck()

RunStartupCheck performs the full startup check workflow

func SanitizeCookieValue

func SanitizeCookieValue(value string) string

SanitizeCookieValue removes invalid characters from cookie values according to RFC 6265. Go's net/http package strictly enforces valid cookie characters and rejects: - Double quotes (") - Control characters - Commas, semicolons, backslashes in certain contexts

func SanitizeCookies

func SanitizeCookies(cookies map[string]string) map[string]string

SanitizeCookies sanitizes all cookie values in a map

func SaveAuth

func SaveAuth(creds *AuthCredentials, account string) error

SaveAuth saves credentials to auth file

func SearchJobs

func SearchJobs(
	client *XClient,
	keyword,
	location string,
	locationType,
	employmentType,
	seniorityLevel []string,
	company,
	industry string,
	count int,
	cursor string,
) (*models.JobSearchResponse, error)

SearchJobs searches for job listings on Twitter/X

func SearchTweets

func SearchTweets(client *XClient, query, searchType string, count int, cursor string) (*models.TimelineResponse, error)

SearchTweets searches for tweets

func SendDM

func SendDM(client *XClient, userID, text string) (map[string]interface{}, error)

SendDM sends a direct message to a user

func SetBrowserExtractionFunc

func SetBrowserExtractionFunc(fn func() (*AuthCredentials, string, error))

SetBrowserExtractionFunc allows the browser package to register its extraction function

func SetDefaultAccount

func SetDefaultAccount(account string) error

SetDefaultAccount sets the default account

func StartupCheck

func StartupCheck()

StartupCheck performs a quick check at startup

func UnblockUser

func UnblockUser(client *XClient, userID string) (map[string]interface{}, error)

UnblockUser unblocks a user by their user ID

func UnbookmarkTweet

func UnbookmarkTweet(client *XClient, tweetID string) (map[string]interface{}, error)

UnbookmarkTweet removes a bookmark

func UnfollowUser

func UnfollowUser(client *XClient, userID string) (map[string]interface{}, error)

UnfollowUser unfollows a user by their user ID

func UnlikeTweet

func UnlikeTweet(client *XClient, tweetID string) (map[string]interface{}, error)

UnlikeTweet unlikes a tweet

func UnmuteUser

func UnmuteUser(client *XClient, userID string) (map[string]interface{}, error)

UnmuteUser unmutes a user by their user ID

func UnpinList

func UnpinList(client *XClient, listID string) (map[string]interface{}, error)

UnpinList unpins a list from the user's profile

func Unretweet

func Unretweet(client *XClient, tweetID string) (map[string]interface{}, error)

Unretweet undoes a retweet

func UploadMediaFile

func UploadMediaFile(client *XClient, filePath string) (string, error)

UploadMediaFile uploads an image to Twitter/X and returns the media ID Uses the chunked upload protocol: INIT -> APPEND -> FINALIZE

func ValidateMediaFile

func ValidateMediaFile(filePath string) (int64, string, error)

ValidateMediaFile validates a media file for upload

Types

type APIError

type APIError struct {
	Message      string
	StatusCode   int
	ResponseData string
}

APIError is raised when an API call fails

func (*APIError) Error

func (e *APIError) Error() string

type ArticleResult

type ArticleResult struct {
	ID        string                 `json:"id"`
	Title     string                 `json:"title"`
	Content   string                 `json:"content"`
	Metadata  map[string]interface{} `json:"metadata"`
	Author    string                 `json:"author"`
	CreatedAt *time.Time             `json:"created_at,omitempty"`
}

ArticleResult represents a Twitter/X article (long-form content)

type AuthCredentials

type AuthCredentials struct {
	AuthToken   string            `json:"auth_token"`
	Ct0         string            `json:"ct0"`
	Cookies     map[string]string `json:"cookies,omitempty"`
	AccountName string            `json:"account_name,omitempty"`
}

AuthCredentials stores authentication credentials

func ExtractCookiesManual

func ExtractCookiesManual() (*AuthCredentials, error)

ExtractCookiesManual prompts user for manual cookie entry

func GetAuthFromEnv

func GetAuthFromEnv() *AuthCredentials

GetAuthFromEnv gets credentials from environment variables

func GetCredentials

func GetCredentials(account string) (*AuthCredentials, error)

GetCredentials gets credentials using priority: env vars > stored > browser > error

func ImportCookiesFromFile

func ImportCookiesFromFile(filePath string) (*AuthCredentials, error)

ImportCookiesFromFile imports cookies from a Cookie Editor JSON export file

func LoadStoredAuth

func LoadStoredAuth(account string) (*AuthCredentials, error)

LoadStoredAuth loads credentials from stored auth file

func (*AuthCredentials) GetSanitizedAuthToken

func (a *AuthCredentials) GetSanitizedAuthToken() string

GetSanitizedAuthToken returns the sanitized auth_token

func (*AuthCredentials) GetSanitizedCookies

func (a *AuthCredentials) GetSanitizedCookies() map[string]string

GetSanitizedCookies returns all cookies with sanitized values

func (*AuthCredentials) GetSanitizedCt0

func (a *AuthCredentials) GetSanitizedCt0() string

GetSanitizedCt0 returns the sanitized ct0

func (*AuthCredentials) IsValid

func (a *AuthCredentials) IsValid() bool

IsValid checks if credentials look valid (non-empty)

type AuthData

type AuthData struct {
	Default  string                      `json:"default"`
	Accounts map[string]*AuthCredentials `json:"accounts"`
}

AuthData represents the stored auth file structure

type AuthError

type AuthError struct {
	Message string
}

AuthError is raised when authentication fails

func (*AuthError) Error

func (e *AuthError) Error() string

type BookmarkFolder

type BookmarkFolder struct {
	ID   string `json:"id"`
	Name string `json:"name"`
}

BookmarkFolder represents a bookmark folder

func GetBookmarkFolders

func GetBookmarkFolders(client *XClient) ([]BookmarkFolder, error)

GetBookmarkFolders fetches the user's bookmark folders

type CacheEntry

type CacheEntry struct {
	Data      interface{}   `json:"data"`
	Timestamp time.Time     `json:"timestamp"`
	Key       string        `json:"key"`
	TTL       time.Duration `json:"ttl"`
}

CacheEntry represents a cached response

func (*CacheEntry) IsValid

func (e *CacheEntry) IsValid() bool

IsValid checks if cache entry is still valid

type Community

type Community struct {
	ID             string          `json:"id"`
	Name           string          `json:"name"`
	Description    string          `json:"description"`
	MemberCount    int             `json:"member_count"`
	ModeratorCount int             `json:"moderator_count"`
	CreatedAt      string          `json:"created_at,omitempty"`
	Role           string          `json:"role,omitempty"` // Member, Moderator, Admin, NonMember
	IsNSFW         bool            `json:"is_nsfw"`
	Rules          []CommunityRule `json:"rules,omitempty"`
}

Community represents a Twitter/X community

func GetCommunity

func GetCommunity(client *XClient, communityID string) (*Community, error)

GetCommunity fetches a community by ID

type CommunityRule

type CommunityRule struct {
	Name        string `json:"name"`
	Description string `json:"description"`
}

CommunityRule represents a community rule

type Config

type Config struct {
	DefaultCount   int                `toml:"default_count"`
	DefaultAccount string             `toml:"default_account,omitempty"`
	Display        DisplayConfig      `toml:"display"`
	Request        RequestConfig      `toml:"request"`
	Network        NetworkConfig      `toml:"network"`
	Filter         utils.FilterConfig `toml:"filter"`
}

Config is the root configuration

func DefaultConfig

func DefaultConfig() *Config

DefaultConfig returns a Config with default values

func LoadConfig

func LoadConfig() (*Config, error)

LoadConfig loads config from TOML file, with defaults for missing values

func (*Config) Save

func (c *Config) Save() error

Save saves config to TOML file

type DisplayConfig

type DisplayConfig struct {
	Theme          string `toml:"theme"`
	ShowEngagement bool   `toml:"show_engagement"`
	ShowTimestamps bool   `toml:"show_timestamps"`
	MaxWidth       int    `toml:"max_width"`
}

DisplayConfig contains display settings

type EndpointCache

type EndpointCache struct {
	Endpoints   map[string]string   `json:"endpoints"`
	Features    map[string]bool     `json:"features"`
	OpFeatures  map[string][]string `json:"op_features"`
	Timestamp   time.Time           `json:"timestamp"`
	Version     string              `json:"version"`
	Fingerprint string              `json:"fingerprint"` // Hash of X.com response for change detection
}

EndpointCache represents the cached endpoint data

func GetMemoryCache

func GetMemoryCache() *EndpointCache

GetMemoryCache returns the singleton memory cache

func (*EndpointCache) GetEndpoint

func (ec *EndpointCache) GetEndpoint(operation string) (string, bool)

GetEndpoint returns the endpoint for an operation

func (*EndpointCache) GetOpFeatures

func (ec *EndpointCache) GetOpFeatures(operation string) map[string]bool

GetOpFeatures returns feature switches for an operation

func (*EndpointCache) IsStale

func (ec *EndpointCache) IsStale() bool

IsStale checks if cache is getting old (over 50% of TTL)

func (*EndpointCache) IsValid

func (ec *EndpointCache) IsValid() bool

IsValid checks if cache is still valid (not expired)

type EndpointDiscovery

type EndpointDiscovery struct {
	// contains filtered or unexported fields
}

EndpointDiscovery manages dynamic endpoint extraction

func NewEndpointDiscovery

func NewEndpointDiscovery(verbose bool) (*EndpointDiscovery, error)

NewEndpointDiscovery creates a new endpoint discovery instance

func (*EndpointDiscovery) DiscoverEndpoints

func (ed *EndpointDiscovery) DiscoverEndpoints(ctx context.Context) (*EndpointCache, error)

DiscoverEndpoints performs full endpoint discovery from X.com This is the main entry point equivalent to Python's _fetch_and_extract

func (*EndpointDiscovery) GetCachedEndpoints

func (ed *EndpointDiscovery) GetCachedEndpoints(ctx context.Context) (*EndpointCache, error)

GetCachedEndpoints returns cached endpoints, fetching if necessary

func (*EndpointDiscovery) GetMemoryCache

func (ed *EndpointDiscovery) GetMemoryCache() *EndpointCache

GetMemoryCache retrieves the memory cache (public for EndpointManager)

func (*EndpointDiscovery) InvalidateCache

func (ed *EndpointDiscovery) InvalidateCache()

InvalidateCache clears all caches

func (*EndpointDiscovery) LoadCache

func (ed *EndpointDiscovery) LoadCache() (*EndpointCache, error)

LoadCache loads cache from disk (public for EndpointManager)

func (*EndpointDiscovery) SaveCache

func (ed *EndpointDiscovery) SaveCache(cache *EndpointCache) error

SaveCache saves cache to disk (public for EndpointManager)

func (*EndpointDiscovery) UpdateMemoryCache

func (ed *EndpointDiscovery) UpdateMemoryCache(cache *EndpointCache)

UpdateMemoryCache updates the global memory cache (public for EndpointManager)

type EndpointManager

type EndpointManager struct {
	// contains filtered or unexported fields
}

EndpointManager manages GraphQL endpoints with automatic discovery and updates Now uses EndpointDiscovery as the single source of truth for caching.

func GetEndpointManager

func GetEndpointManager() *EndpointManager

GetEndpointManager returns the singleton endpoint manager

func (*EndpointManager) CheckAndUpdate

func (em *EndpointManager) CheckAndUpdate(ctx context.Context) error

CheckAndUpdate checks if endpoints need updating and updates if necessary

func (*EndpointManager) CheckEndpoint

func (em *EndpointManager) CheckEndpoint(operation string) (bool, string)

CheckEndpoint checks if an endpoint is valid

func (*EndpointManager) GetEndpoint

func (em *EndpointManager) GetEndpoint(operation string) string

GetEndpoint returns the endpoint for an operation, with auto-discovery

func (*EndpointManager) GetEndpointWithRefresh

func (em *EndpointManager) GetEndpointWithRefresh(ctx context.Context, operation string) (string, error)

GetEndpointWithRefresh returns endpoint, refreshing if necessary

func (*EndpointManager) GetOpFeatures

func (em *EndpointManager) GetOpFeatures(operation string) map[string]bool

GetOpFeatures returns feature switches for a specific operation

func (*EndpointManager) GetStats

func (em *EndpointManager) GetStats() EndpointStats

GetStats returns statistics about endpoints

func (*EndpointManager) Invalidate

func (em *EndpointManager) Invalidate()

Invalidate clears all dynamic endpoints

func (*EndpointManager) ListEndpoints

func (em *EndpointManager) ListEndpoints() map[string]string

ListEndpoints returns all current endpoints

func (*EndpointManager) RefreshEndpoints

func (em *EndpointManager) RefreshEndpoints(ctx context.Context) error

RefreshEndpoints fetches fresh endpoints from X.com

func (*EndpointManager) ResetEndpoint

func (em *EndpointManager) ResetEndpoint(operation string)

ResetEndpoint resets an endpoint to its default value

func (*EndpointManager) UpdateEndpoint

func (em *EndpointManager) UpdateEndpoint(operation, endpoint string)

UpdateEndpoint manually updates a single endpoint

type EndpointMonitor

type EndpointMonitor struct {
	// contains filtered or unexported fields
}

EndpointMonitor continuously monitors endpoint health and auto-updates

func NewEndpointMonitor

func NewEndpointMonitor(client *XClient, verbose bool) (*EndpointMonitor, error)

NewEndpointMonitor creates a new endpoint monitor

func (*EndpointMonitor) AutoUpdate

func (em *EndpointMonitor) AutoUpdate(ctx context.Context) error

AutoUpdate fetches new endpoints and updates the cache

func (*EndpointMonitor) GetStatus

func (em *EndpointMonitor) GetStatus() MonitorStatus

GetStatus returns the current monitor status

func (*EndpointMonitor) SetCheckInterval

func (em *EndpointMonitor) SetCheckInterval(interval time.Duration)

SetCheckInterval changes the check interval

func (*EndpointMonitor) Start

func (em *EndpointMonitor) Start()

Start begins background monitoring

func (*EndpointMonitor) Stop

func (em *EndpointMonitor) Stop()

Stop halts background monitoring

type EndpointStats

type EndpointStats struct {
	TotalCount   int           `json:"total_count"`
	FeatureCount int           `json:"feature_count"`
	LastUpdated  time.Time     `json:"last_updated"`
	CacheAge     time.Duration `json:"cache_age"`
}

EndpointStats represents endpoint statistics

type EndpointStatusDetail

type EndpointStatusDetail struct {
	Operation    string `json:"operation"`
	Endpoint     string `json:"endpoint"`
	Source       string `json:"source"`
	HasFeatures  bool   `json:"has_features"`
	FeatureCount int    `json:"feature_count"`
}

EndpointStatusDetail represents detailed status for a single endpoint

func GetEndpointStatus

func GetEndpointStatus() ([]EndpointStatusDetail, error)

GetEndpointStatus returns detailed status for all endpoints

type ListInfo

type ListInfo struct {
	ID              string `json:"id"`
	Name            string `json:"name"`
	Description     string `json:"description"`
	MemberCount     int    `json:"member_count"`
	SubscriberCount int    `json:"subscriber_count"`
	Mode            string `json:"mode"` // "Private" or "Public"
	IsPinned        bool   `json:"is_pinned"`
}

ListInfo represents information about a Twitter list

func GetUserLists

func GetUserLists(client *XClient) ([]ListInfo, error)

GetUserLists fetches the authenticated user's lists

type MediaUploadResult

type MediaUploadResult struct {
	MediaID          string `json:"media_id"`
	MediaIDString    string `json:"media_id_string"`
	Size             int64  `json:"size"`
	ExpiresAfterSecs int    `json:"expires_after_secs,omitempty"`
}

MediaUploadResult contains the result of a media upload

type MonitorStatus

type MonitorStatus struct {
	IsHealthy       bool      `json:"is_healthy"`
	LastCheck       time.Time `json:"last_check"`
	EndpointsCount  int       `json:"endpoints_count"`
	FailedEndpoints []string  `json:"failed_endpoints,omitempty"`
	NeedsUpdate     bool      `json:"needs_update"`
	Message         string    `json:"message"`
}

MonitorStatus represents the current monitoring status

type NetworkConfig

type NetworkConfig struct {
	Proxy string `toml:"proxy,omitempty"`
}

NetworkConfig contains network settings

type Notification

type Notification struct {
	ID         string `json:"id"`
	Type       string `json:"type"` // like, retweet, follow, reply, mention, quote
	Message    string `json:"message"`
	Timestamp  string `json:"timestamp,omitempty"`
	UserID     string `json:"user_id,omitempty"`
	UserName   string `json:"user_name,omitempty"`
	UserHandle string `json:"user_handle,omitempty"`
	TweetID    string `json:"tweet_id,omitempty"`
	TweetText  string `json:"tweet_text,omitempty"`
	Icon       string `json:"icon,omitempty"`
}

Notification represents a Twitter/X notification

type NotificationsResponse

type NotificationsResponse struct {
	Notifications []Notification `json:"notifications"`
	CursorTop     string         `json:"cursor_top,omitempty"`
	CursorBottom  string         `json:"cursor_bottom,omitempty"`
	HasMore       bool           `json:"has_more"`
}

NotificationsResponse holds a page of notifications

func GetNotifications

func GetNotifications(client *XClient, count int, cursor string) (*NotificationsResponse, error)

GetNotifications fetches the user's notification timeline via REST API v2. X.com does not use GraphQL for notifications; it uses the /i/api/2/notifications/all.json endpoint.

type RateLimitError

type RateLimitError struct {
	APIError
}

RateLimitError is raised when rate limited

type RateLimitInfo

type RateLimitInfo struct {
	Endpoint  string    `json:"endpoint"`
	Limit     int       `json:"limit"`
	Remaining int       `json:"remaining"`
	Reset     time.Time `json:"reset"`
	UpdatedAt time.Time `json:"updated_at"`
}

RateLimitInfo holds rate limit data from response headers

func GetRateLimits

func GetRateLimits() []*RateLimitInfo

GetRateLimits returns all tracked rate limit info (exported for cmd layer)

func (*RateLimitInfo) SecondsUntilReset

func (r *RateLimitInfo) SecondsUntilReset() int

SecondsUntilReset returns seconds until the rate limit resets

func (*RateLimitInfo) UsagePercent

func (r *RateLimitInfo) UsagePercent() float64

UsagePercent returns the percentage of rate limit used

type RequestConfig

type RequestConfig struct {
	Delay      float64 `toml:"delay"`
	Timeout    int     `toml:"timeout"`
	MaxRetries int     `toml:"max_retries"`
}

RequestConfig contains request settings

type ResponseCache

type ResponseCache struct {
	// contains filtered or unexported fields
}

ResponseCache provides intelligent caching for API responses

func GetResponseCache

func GetResponseCache() *ResponseCache

GetResponseCache returns the global response cache

func NewResponseCache

func NewResponseCache(maxSize int, maxAge time.Duration) (*ResponseCache, error)

NewResponseCache creates a new response cache

func (*ResponseCache) Get

func (rc *ResponseCache) Get(key string) (interface{}, bool)

Get retrieves a cached response

func (*ResponseCache) Invalidate

func (rc *ResponseCache) Invalidate(key string)

Invalidate removes an entry from cache

func (*ResponseCache) InvalidateAll

func (rc *ResponseCache) InvalidateAll()

InvalidateAll clears all cache

func (*ResponseCache) Set

func (rc *ResponseCache) Set(key string, data interface{}, ttl time.Duration)

Set stores a response in cache

type ScheduledTweet

type ScheduledTweet struct {
	ID        string   `json:"id"`
	Text      string   `json:"text"`
	ExecuteAt int64    `json:"execute_at"` // Unix timestamp
	State     string   `json:"state"`
	MediaIDs  []string `json:"media_ids"`
}

ScheduledTweet represents a scheduled tweet

func GetScheduledTweets

func GetScheduledTweets(client *XClient) ([]ScheduledTweet, error)

GetScheduledTweets lists all scheduled tweets

type Space

type Space struct {
	ID                  string      `json:"id"`
	Title               string      `json:"title"`
	State               string      `json:"state"` // Running, Ended, Scheduled, NotStarted
	CreatedAt           string      `json:"created_at,omitempty"`
	ScheduledStart      string      `json:"scheduled_start,omitempty"`
	StartedAt           string      `json:"started_at,omitempty"`
	EndedAt             string      `json:"ended_at,omitempty"`
	HostIDs             []string    `json:"host_ids"`
	SpeakerIDs          []string    `json:"speaker_ids"`
	ParticipantCount    int         `json:"participant_count"`
	IsTicketed          bool        `json:"is_ticketed"`
	NarrowCastSpaceType int         `json:"narrow_cast_space_type"`
	Hosts               []SpaceUser `json:"hosts,omitempty"`
}

Space represents a Twitter Space

func GetSpace

func GetSpace(client *XClient, spaceID string) (*Space, error)

GetSpace fetches a Space by ID

type SpaceSearchResponse

type SpaceSearchResponse struct {
	Spaces  []Space `json:"spaces"`
	HasMore bool    `json:"has_more"`
}

SpaceSearchResponse represents search results for Spaces

func SearchSpaces

func SearchSpaces(client *XClient, query string, count int) (*SpaceSearchResponse, error)

SearchSpaces searches for Twitter Spaces

type SpaceUser

type SpaceUser struct {
	ID     string `json:"id"`
	Name   string `json:"name"`
	Handle string `json:"handle"`
}

SpaceUser represents a user in a Space context

type StaleEndpointError

type StaleEndpointError struct {
	APIError
}

StaleEndpointError is raised when a GraphQL endpoint returns 404 (stale operation ID)

type StartupChecker

type StartupChecker struct {
	// contains filtered or unexported fields
}

StartupChecker handles automatic endpoint checks on CLI startup

func NewStartupChecker

func NewStartupChecker() *StartupChecker

NewStartupChecker creates a new startup checker

func (*StartupChecker) MarkChecked

func (sc *StartupChecker) MarkChecked()

MarkChecked marks that we've done a check

func (*StartupChecker) QuickCheckEndpoints

func (sc *StartupChecker) QuickCheckEndpoints() ([]string, error)

QuickCheckEndpoints performs a quick check of critical endpoints

func (*StartupChecker) ShouldCheck

func (sc *StartupChecker) ShouldCheck() bool

ShouldCheck returns true if we should perform an endpoint check

func (*StartupChecker) ShowUpdatePrompt

func (sc *StartupChecker) ShowUpdatePrompt(obsoleteEndpoints []string)

ShowUpdatePrompt shows a prompt to update endpoints if needed

type TLSClientConfig

type TLSClientConfig struct {
	FingerprintType TLSFingerprintType
	Proxy           string
	Timeout         time.Duration
}

TLSClientConfig holds configuration for TLS client

func DefaultTLSClientConfig

func DefaultTLSClientConfig() *TLSClientConfig

DefaultTLSClientConfig returns default TLS configuration

type TLSFingerprintType

type TLSFingerprintType string

TLSFingerprintType represents different browser fingerprint types

const (
	Chrome120 TLSFingerprintType = "chrome120"
	Chrome123 TLSFingerprintType = "chrome123"
	Chrome124 TLSFingerprintType = "chrome124"
	Chrome126 TLSFingerprintType = "chrome126"
	Chrome127 TLSFingerprintType = "chrome127"
	Chrome131 TLSFingerprintType = "chrome131"
	Chrome133 TLSFingerprintType = "chrome133"
)

func BestChromeTarget

func BestChromeTarget() TLSFingerprintType

BestChromeTarget returns the best available Chrome target

type TransactionGenerator

type TransactionGenerator struct {
	// contains filtered or unexported fields
}

TransactionGenerator generates x-client-transaction-id headers

func GetTransactionGenerator

func GetTransactionGenerator() *TransactionGenerator

GetTransactionGenerator returns the global transaction generator instance

func (*TransactionGenerator) Generate

func (tg *TransactionGenerator) Generate(method, path string) string

Generate creates a transaction ID for the given method and path

func (*TransactionGenerator) Initialize

func (tg *TransactionGenerator) Initialize(client *http.Client) error

Initialize fetches and caches the necessary data from X.com

type XClient

type XClient struct {
	// contains filtered or unexported fields
}

XClient is the HTTP client for Twitter/X GraphQL API

func NewXClient

func NewXClient(credentials *AuthCredentials, account, proxy string) (*XClient, error)

NewXClient creates a new XClient with a consistent Chrome fingerprint

func (*XClient) Close

func (c *XClient) Close()

Close closes the HTTP client

func (*XClient) GraphQLGet

func (c *XClient) GraphQLGet(operation string, variables map[string]interface{}) (map[string]interface{}, error)

GraphQLGet makes a GraphQL GET request with auto-retry on stale endpoint IDs. Matches Python's _graphql_request behavior exactly.

func (*XClient) GraphQLGetWithReferer

func (c *XClient) GraphQLGetWithReferer(operation string, variables map[string]interface{}, referer string) (map[string]interface{}, error)

GraphQLGetWithReferer makes a GraphQL GET request with a custom referer header.

func (*XClient) GraphQLPost

func (c *XClient) GraphQLPost(operation string, variables map[string]interface{}) (map[string]interface{}, error)

GraphQLPost makes a GraphQL POST request (for write operations) with auto-retry on stale endpoint IDs. Matches Python's behavior exactly: sends variables, features (from op_features), and queryId

func (*XClient) GraphQLPostWithReferer

func (c *XClient) GraphQLPostWithReferer(operation string, variables map[string]interface{}, referer string) (map[string]interface{}, error)

GraphQLPostWithReferer makes a GraphQL POST request with a custom referer header.

func (*XClient) RestGet

func (c *XClient) RestGet(urlStr string, params map[string]interface{}) (map[string]interface{}, error)

RestGet makes an authenticated GET request to a REST API endpoint (v1.1 or v2)

func (*XClient) RestPost

func (c *XClient) RestPost(urlStr string, data map[string]string) (map[string]interface{}, error)

RestPost makes a POST request to the REST API v1.1 (used for media upload, social actions)

func (*XClient) RestPostWithOptions

func (c *XClient) RestPostWithOptions(urlStr string, data map[string]string, jsonBody map[string]interface{}, timeout int) (map[string]interface{}, error)

RestPostWithOptions makes a REST POST request with full control

func (*XClient) TryRefreshCredentials

func (c *XClient) TryRefreshCredentials() bool

TryRefreshCredentials attempts to refresh credentials from browser cookies on auth failure. Returns true if credentials were successfully refreshed. Bhavior for auto-refresh on 401/403.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL