1- # Xquik Ruby SDK: Twitter Search, Followers & X Automation
1+ # Xquik Ruby SDK: Twitter search, followers & X automation
22
33[ ![ OpenSSF Best Practices] ( https://www.bestpractices.dev/projects/13739/badge )] ( https://www.bestpractices.dev/projects/13739 )
44
@@ -8,7 +8,7 @@ Use documented Xquik REST routes as a Twitter API alternative.
88
99[ Ruby SDK Guide] ( https://docs.xquik.com/sdks/ruby ) | [ REST API] ( https://docs.xquik.com/api-reference/overview ) | [ RubyDoc] ( https://gemdocs.org/gems/x-twitter-scraper ) | [ Webhooks] ( https://docs.xquik.com/api-reference/webhooks/create )
1010
11- ## Common Twitter & X Tasks
11+ ## Common Twitter & X tasks
1212
1313| Task | REST Route | Usage |
1414| --- | --- | --- |
@@ -24,12 +24,14 @@ Use documented Xquik REST routes as a Twitter API alternative.
2424
2525## Installation
2626
27+ Requires Ruby 3.2.0 or higher.
28+
2729Add the gem to your ` Gemfile ` :
2830
2931<!-- x-release-please-start-version -->
3032
3133``` ruby
32- gem " x-twitter-scraper" , " ~> 0.10.3 "
34+ gem " x-twitter-scraper" , " ~> 0.10.4 "
3335```
3436
3537<!-- x-release-please-end -->
@@ -41,15 +43,15 @@ require "bundler/setup"
4143require " x_twitter_scraper"
4244
4345x_twitter_scraper = XTwitterScraper ::Client .new (
44- api_key: ENV [" X_TWITTER_SCRAPER_API_KEY" ] # This is the default and can be omitted
46+ api_key: ENV [" X_TWITTER_SCRAPER_API_KEY" ] # Optional; the client reads this variable.
4547)
4648
4749response = x_twitter_scraper.x.tweets.search(q: " from:elonmusk" , limit: 10 )
4850
4951puts (response)
5052```
5153
52- ### Handling Errors
54+ ### Handling errors
5355
5456The SDK raises an ` APIError ` subclass for connection failures and non-2xx responses:
5557
@@ -67,8 +69,6 @@ rescue XTwitterScraper::Errors::APIStatusError => e
6769end
6870```
6971
70- The SDK uses these error classes:
71-
7272| Cause | Error Type |
7373| ---------------- | -------------------------- |
7474| HTTP 400 | ` BadRequestError ` |
@@ -90,12 +90,12 @@ It uses exponential backoff with 2 retries by default.
9090Set ` max_retries ` to change or disable retries:
9191
9292``` ruby
93- # Set the client default:
93+ # Change the client default.
9494x_twitter_scraper = XTwitterScraper ::Client .new (
95- max_retries: 0 # default is 2
95+ max_retries: 0
9696)
9797
98- # Override one request:
98+ # Override one request.
9999x_twitter_scraper.account.retrieve(request_options: {max_retries: 5 })
100100```
101101
@@ -104,31 +104,28 @@ x_twitter_scraper.account.retrieve(request_options: {max_retries: 5})
104104Requests time out after 60 seconds. Set ` timeout ` to change or disable this limit:
105105
106106``` ruby
107- # Set the client default:
107+ # Change the client default.
108108x_twitter_scraper = XTwitterScraper ::Client .new (
109- timeout: nil # default is 60
109+ timeout: nil
110110)
111111
112- # Override one request:
112+ # Override one request.
113113x_twitter_scraper.account.retrieve(request_options: {timeout: 5 })
114114```
115115
116116Timeouts raise ` XTwitterScraper::Errors::APITimeoutError ` and follow the retry policy.
117117
118- ## Advanced Concepts
118+ ## BaseModel
119119
120- ### BaseModel
121-
122- All parameter and response objects inherit from ` XTwitterScraper::Internal::Type::BaseModel ` .
123- The base model provides these operations:
120+ All parameter and response objects inherit from ` XTwitterScraper::Internal::Type::BaseModel ` and support:
124121
1251221 . Access known and unknown fields with ` obj[:prop] ` .
1261232 . Destructure fields with ` obj => {prop: prop} ` or pattern matching.
1271243 . Compare objects by their field values with ` == ` .
1281254 . Print classes and instances in a readable format.
1291265 . Convert values with ` #to_h ` , ` #deep_to_h ` , ` #to_json ` , or ` #to_yaml ` .
130127
131- ### Custom Requests
128+ ## Custom requests
132129
133130Use ` extra_query ` , ` extra_body ` , or ` extra_headers ` under ` request_options ` .
134131Matching ` extra_ ` values override documented parameters.
@@ -158,7 +155,7 @@ response = client.request(
158155)
159156```
160157
161- ### Concurrency & Connection Pooling
158+ ## Concurrency & connection pooling
162159
163160Clients are thread-safe. Fork them only when no HTTP requests are in flight.
164161Each client has an HTTP connection pool with a default size of 99.
@@ -215,17 +212,10 @@ This package follows [SemVer](https://semver.org/spec/v2.0.0.html). Version `0`
215212
216213Changes to non-runtime ` *.rbi ` and ` *.rbs ` definitions remain non-breaking.
217214
218- ## Requirements
219-
220- Ruby 3.2.0 or higher.
221-
222- ## Security & Support
215+ ## Help & contributing
223216
224217- Report vulnerabilities through the [ security policy] ( SECURITY.md ) .
225218- Ask usage questions through the [ organization support policy] ( https://github.com/Xquik-dev/.github/blob/main/SUPPORT.md ) .
226-
227- ## Contributing
228-
229- Read the [ contribution guide] ( CONTRIBUTING.md ) .
219+ - Read the [ contribution guide] ( CONTRIBUTING.md ) .
230220
231221Xquik is an independent third-party service. Not affiliated with X Corp. "Twitter" and "X" are trademarks of X Corp.
0 commit comments