Skip to content

Latest commit

 

History

History
188 lines (129 loc) · 10.6 KB

File metadata and controls

188 lines (129 loc) · 10.6 KB

Timelines

Overview

Available Operations

tweets_and_replies

Get all tweets and replies posted by a specific Twitter user. Returns a comprehensive list including both original tweets and reply tweets posted by the user. $0.10/1000 items.

Example Usage

require 'x_api_scraper'

Models = ::XapiScraper::Models
s = ::XapiScraper::Client.new(
  bearer_auth: '<YOUR_BEARER_TOKEN_HERE>'
)

req = Models::Operations::TimelinesTweetsAndRepliesRequest.new(
  screen_name: 'elonmusk',
  count: 50
)
res = s.timelines.tweets_and_replies(request: req)

unless res.search_response.nil?
  # handle response
end

Parameters

Parameter Type Required Description
request Models::Operations::TimelinesTweetsAndRepliesRequest ✔️ The request object to use for the request.

Response

T.nilable(Models::Operations::TimelinesTweetsAndRepliesResponse)

Errors

Error Type Status Code Content Type
Models::Errors::HTTPValidationError 422 application/json
Errors::APIError 4XX, 5XX */*

user_page

Fetch a single page from a user's timeline using POST. Pass next_cursor in the body to continue.

Example Usage

require 'x_api_scraper'

Models = ::XapiScraper::Models
s = ::XapiScraper::Client.new(
  bearer_auth: '<YOUR_BEARER_TOKEN_HERE>'
)

req = Models::Operations::TimelinesUserPageRequest.new(
  screen_name: 'axiaisacat',
  body: Models::Components::UserTimelinePageQuery.new(
    next_cursor: 'DAAHCgABHFeD5h9__-cLAAIAAAATMjAzODIzMzA5NTM4ODY4MDU5NAgAAwAAAAIAAA'
  )
)
res = s.timelines.user_page(request: req)

unless res.user_timeline_page_response.nil?
  # handle response
end

Parameters

Parameter Type Required Description
request Models::Operations::TimelinesUserPageRequest ✔️ The request object to use for the request.

Response

T.nilable(Models::Operations::TimelinesUserPageResponse)

Errors

Error Type Status Code Content Type
Models::Errors::HTTPValidationError 422 application/json
Errors::APIError 4XX, 5XX */*

user

Fetch a user's timeline across pages using POST and try to fill the requested count.

Example Usage

require 'x_api_scraper'

Models = ::XapiScraper::Models
s = ::XapiScraper::Client.new(
  bearer_auth: '<YOUR_BEARER_TOKEN_HERE>'
)

req = Models::Operations::TimelinesUserRequest.new(
  screen_name: 'axiaisacat',
  body: Models::Components::UserTimelineFillQuery.new
)
res = s.timelines.user(request: req)

unless res.user_timeline_response.nil?
  # handle response
end

Parameters

Parameter Type Required Description
request Models::Operations::TimelinesUserRequest ✔️ The request object to use for the request.

Response

T.nilable(Models::Operations::TimelinesUserResponse)

Errors

Error Type Status Code Content Type
Models::Errors::HTTPValidationError 422 application/json
Errors::APIError 4XX, 5XX */*

tweets_and_replies_page

Retrieve a paginated list of a user's tweets and replies using cursor-based pagination. Each page returns up to 20 items. Pass next_cursor from the previous response to continue. Pricing: $0.10 per 1,000 items.

Example Usage

require 'x_api_scraper'

Models = ::XapiScraper::Models
s = ::XapiScraper::Client.new(
  bearer_auth: '<YOUR_BEARER_TOKEN_HERE>'
)

req = Models::Components::GetAllTweetsRepliesCursorQuery.new(
  next_cursor: '1234567890',
  screen_name: 'elonmusk'
)
res = s.timelines.tweets_and_replies_page(request: req)

unless res.get_all_tweets_replies_cursor_response.nil?
  # handle response
end

Parameters

Parameter Type Required Description
request Models::Components::GetAllTweetsRepliesCursorQuery ✔️ The request object to use for the request.

Response

T.nilable(Models::Operations::TimelinesTweetsAndRepliesPageResponse)

Errors

Error Type Status Code Content Type
Models::Errors::HTTPValidationError 422 application/json
Errors::APIError 4XX, 5XX */*