Documentation
¶
Overview ¶
Package twitter is a dependency-free, best-effort read client for public Twitter/X profile timelines. It uses the public syndication timeline endpoint that powers embedded timeline widgets, extracting the tweets from the __NEXT_DATA__ JSON blob in the returned HTML.
This is inherently fragile: Twitter/X changes and locks these endpoints, and some profiles or rate states require a valid auth token. Requests that are blocked surface as errors rather than pretending to be reliable. Expect to need WithAuthToken for anything beyond light public reads.
Index ¶
Constants ¶
const DefaultBaseURL = "https://syndication.twitter.com"
DefaultBaseURL is the public syndication host.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// BaseURL is the syndication host; defaults to DefaultBaseURL.
BaseURL string
// HTTPClient is used for all requests; defaults to http.DefaultClient.
HTTPClient *http.Client
// UserAgent is sent with every request.
UserAgent string
// AuthToken, when set, is sent as a bearer token for authenticated reads.
AuthToken string
}
Client reads public profile timelines.
type Option ¶
type Option func(*Client)
Option configures a Client.
func WithAuthToken ¶
WithAuthToken sets an optional bearer token for authenticated reads.
func WithBaseURL ¶
WithBaseURL overrides the syndication host (used in tests).
func WithHTTPClient ¶
WithHTTPClient sets the http.Client used for requests.