Class: XTwitterScraper::Client
- Inherits:
-
Internal::Transport::BaseClient
- Object
- Internal::Transport::BaseClient
- XTwitterScraper::Client
- Defined in:
- lib/x_twitter_scraper/client.rb
Constant Summary collapse
- DEFAULT_MAX_RETRIES =
Default max number of retries to attempt after a failed retryable request.
2- DEFAULT_TIMEOUT_IN_SECONDS =
Default per-request timeout.
60.0- DEFAULT_INITIAL_RETRY_DELAY =
Default initial retry delay in seconds. Overall delay is calculated using exponential backoff + jitter.
0.5- DEFAULT_MAX_RETRY_DELAY =
Default max retry delay in seconds.
8.0
Constants inherited from Internal::Transport::BaseClient
Internal::Transport::BaseClient::MAX_REDIRECTS, Internal::Transport::BaseClient::PLATFORM_HEADERS
Instance Attribute Summary collapse
-
#account ⇒ XTwitterScraper::Resources::Account
readonly
Account info & settings.
- #api_key ⇒ String? readonly
-
#api_keys ⇒ XTwitterScraper::Resources::APIKeys
readonly
API key management (session auth only).
-
#bearer_token ⇒ String?
readonly
OAuth 2.1 access token.
- #bot ⇒ XTwitterScraper::Resources::Bot readonly
-
#compose ⇒ XTwitterScraper::Resources::Compose
readonly
Tweet composition, drafts, writing styles & radar.
-
#credits ⇒ XTwitterScraper::Resources::Credits
readonly
Subscription & billing.
-
#drafts ⇒ XTwitterScraper::Resources::Drafts
readonly
Tweet composition, drafts, writing styles & radar.
-
#draws ⇒ XTwitterScraper::Resources::Draws
readonly
Giveaway draws from tweet replies.
-
#events ⇒ XTwitterScraper::Resources::Events
readonly
Activity events from monitored accounts.
-
#extractions ⇒ XTwitterScraper::Resources::Extractions
readonly
Bulk data extraction (20 tool types).
-
#integrations ⇒ XTwitterScraper::Resources::Integrations
readonly
Push notification integrations (Telegram).
-
#monitors ⇒ XTwitterScraper::Resources::Monitors
readonly
Real-time X account monitoring.
-
#radar ⇒ XTwitterScraper::Resources::Radar
readonly
Tweet composition, drafts, writing styles & radar.
-
#styles ⇒ XTwitterScraper::Resources::Styles
readonly
Tweet composition, drafts, writing styles & radar.
-
#subscribe ⇒ XTwitterScraper::Resources::Subscribe
readonly
Subscription & billing.
- #support ⇒ XTwitterScraper::Resources::Support readonly
-
#trends ⇒ XTwitterScraper::Resources::Trends
readonly
Trending topics by region.
-
#webhooks ⇒ XTwitterScraper::Resources::Webhooks
readonly
Webhook endpoint management & delivery.
-
#x ⇒ XTwitterScraper::Resources::X
readonly
X data lookups (subscription required).
Attributes inherited from Internal::Transport::BaseClient
#base_url, #headers, #idempotency_header, #initial_retry_delay, #max_retries, #max_retry_delay, #requester, #timeout
Instance Method Summary collapse
-
#initialize(api_key: ENV["X_TWITTER_SCRAPER_API_KEY"], bearer_token: ENV["X_TWITTER_SCRAPER_BEARER_TOKEN"], base_url: ENV["X_TWITTER_SCRAPER_BASE_URL"], max_retries: self.class::DEFAULT_MAX_RETRIES, timeout: self.class::DEFAULT_TIMEOUT_IN_SECONDS, initial_retry_delay: self.class::DEFAULT_INITIAL_RETRY_DELAY, max_retry_delay: self.class::DEFAULT_MAX_RETRY_DELAY) ⇒ Client
constructor
Creates and returns a new client for interacting with the API.
Methods inherited from Internal::Transport::BaseClient
follow_redirect, #inspect, reap_connection!, #request, #send_request, should_retry?, validate!
Methods included from Internal::Util::SorbetRuntimeSupport
#const_missing, #define_sorbet_constant!, #sorbet_constant_defined?, #to_sorbet_type, to_sorbet_type
Constructor Details
#initialize(api_key: ENV["X_TWITTER_SCRAPER_API_KEY"], bearer_token: ENV["X_TWITTER_SCRAPER_BEARER_TOKEN"], base_url: ENV["X_TWITTER_SCRAPER_BASE_URL"], max_retries: self.class::DEFAULT_MAX_RETRIES, timeout: self.class::DEFAULT_TIMEOUT_IN_SECONDS, initial_retry_delay: self.class::DEFAULT_INITIAL_RETRY_DELAY, max_retry_delay: self.class::DEFAULT_MAX_RETRY_DELAY) ⇒ Client
Creates and returns a new client for interacting with the API.
‘“api.example.com/v2/”`. Defaults to `ENV`
136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 |
# File 'lib/x_twitter_scraper/client.rb', line 136 def initialize( api_key: ENV["X_TWITTER_SCRAPER_API_KEY"], bearer_token: ENV["X_TWITTER_SCRAPER_BEARER_TOKEN"], base_url: ENV["X_TWITTER_SCRAPER_BASE_URL"], max_retries: self.class::DEFAULT_MAX_RETRIES, timeout: self.class::DEFAULT_TIMEOUT_IN_SECONDS, initial_retry_delay: self.class::DEFAULT_INITIAL_RETRY_DELAY, max_retry_delay: self.class::DEFAULT_MAX_RETRY_DELAY ) base_url ||= "https://xquik.com/api/v1" @api_key = api_key&.to_s @bearer_token = bearer_token&.to_s super( base_url: base_url, timeout: timeout, max_retries: max_retries, initial_retry_delay: initial_retry_delay, max_retry_delay: max_retry_delay ) @account = XTwitterScraper::Resources::Account.new(client: self) @api_keys = XTwitterScraper::Resources::APIKeys.new(client: self) @subscribe = XTwitterScraper::Resources::Subscribe.new(client: self) @compose = XTwitterScraper::Resources::Compose.new(client: self) @drafts = XTwitterScraper::Resources::Drafts.new(client: self) @styles = XTwitterScraper::Resources::Styles.new(client: self) @radar = XTwitterScraper::Resources::Radar.new(client: self) @monitors = XTwitterScraper::Resources::Monitors.new(client: self) @events = XTwitterScraper::Resources::Events.new(client: self) @extractions = XTwitterScraper::Resources::Extractions.new(client: self) @draws = XTwitterScraper::Resources::Draws.new(client: self) @webhooks = XTwitterScraper::Resources::Webhooks.new(client: self) @integrations = XTwitterScraper::Resources::Integrations.new(client: self) @x = XTwitterScraper::Resources::X.new(client: self) @trends = XTwitterScraper::Resources::Trends.new(client: self) @bot = XTwitterScraper::Resources::Bot.new(client: self) @support = XTwitterScraper::Resources::Support.new(client: self) @credits = XTwitterScraper::Resources::Credits.new(client: self) end |
Instance Attribute Details
#account ⇒ XTwitterScraper::Resources::Account (readonly)
Account info & settings
27 28 29 |
# File 'lib/x_twitter_scraper/client.rb', line 27 def account @account end |
#api_key ⇒ String? (readonly)
19 20 21 |
# File 'lib/x_twitter_scraper/client.rb', line 19 def api_key @api_key end |
#api_keys ⇒ XTwitterScraper::Resources::APIKeys (readonly)
API key management (session auth only)
31 32 33 |
# File 'lib/x_twitter_scraper/client.rb', line 31 def api_keys @api_keys end |
#bearer_token ⇒ String? (readonly)
OAuth 2.1 access token
23 24 25 |
# File 'lib/x_twitter_scraper/client.rb', line 23 def bearer_token @bearer_token end |
#bot ⇒ XTwitterScraper::Resources::Bot (readonly)
86 87 88 |
# File 'lib/x_twitter_scraper/client.rb', line 86 def bot @bot end |
#compose ⇒ XTwitterScraper::Resources::Compose (readonly)
Tweet composition, drafts, writing styles & radar
39 40 41 |
# File 'lib/x_twitter_scraper/client.rb', line 39 def compose @compose end |
#credits ⇒ XTwitterScraper::Resources::Credits (readonly)
Subscription & billing
93 94 95 |
# File 'lib/x_twitter_scraper/client.rb', line 93 def credits @credits end |
#drafts ⇒ XTwitterScraper::Resources::Drafts (readonly)
Tweet composition, drafts, writing styles & radar
43 44 45 |
# File 'lib/x_twitter_scraper/client.rb', line 43 def drafts @drafts end |
#draws ⇒ XTwitterScraper::Resources::Draws (readonly)
Giveaway draws from tweet replies
67 68 69 |
# File 'lib/x_twitter_scraper/client.rb', line 67 def draws @draws end |
#events ⇒ XTwitterScraper::Resources::Events (readonly)
Activity events from monitored accounts
59 60 61 |
# File 'lib/x_twitter_scraper/client.rb', line 59 def events @events end |
#extractions ⇒ XTwitterScraper::Resources::Extractions (readonly)
Bulk data extraction (20 tool types)
63 64 65 |
# File 'lib/x_twitter_scraper/client.rb', line 63 def extractions @extractions end |
#integrations ⇒ XTwitterScraper::Resources::Integrations (readonly)
Push notification integrations (Telegram)
75 76 77 |
# File 'lib/x_twitter_scraper/client.rb', line 75 def integrations @integrations end |
#monitors ⇒ XTwitterScraper::Resources::Monitors (readonly)
Real-time X account monitoring
55 56 57 |
# File 'lib/x_twitter_scraper/client.rb', line 55 def monitors @monitors end |
#radar ⇒ XTwitterScraper::Resources::Radar (readonly)
Tweet composition, drafts, writing styles & radar
51 52 53 |
# File 'lib/x_twitter_scraper/client.rb', line 51 def radar @radar end |
#styles ⇒ XTwitterScraper::Resources::Styles (readonly)
Tweet composition, drafts, writing styles & radar
47 48 49 |
# File 'lib/x_twitter_scraper/client.rb', line 47 def styles @styles end |
#subscribe ⇒ XTwitterScraper::Resources::Subscribe (readonly)
Subscription & billing
35 36 37 |
# File 'lib/x_twitter_scraper/client.rb', line 35 def subscribe @subscribe end |
#support ⇒ XTwitterScraper::Resources::Support (readonly)
89 90 91 |
# File 'lib/x_twitter_scraper/client.rb', line 89 def support @support end |
#trends ⇒ XTwitterScraper::Resources::Trends (readonly)
Trending topics by region
83 84 85 |
# File 'lib/x_twitter_scraper/client.rb', line 83 def trends @trends end |
#webhooks ⇒ XTwitterScraper::Resources::Webhooks (readonly)
Webhook endpoint management & delivery
71 72 73 |
# File 'lib/x_twitter_scraper/client.rb', line 71 def webhooks @webhooks end |
#x ⇒ XTwitterScraper::Resources::X (readonly)
X data lookups (subscription required)
79 80 81 |
# File 'lib/x_twitter_scraper/client.rb', line 79 def x @x end |