Skip to content

Latest commit

 

History

History
180 lines (117 loc) · 15.7 KB

File metadata and controls

180 lines (117 loc) · 15.7 KB

Tweets.Engagement

Overview

Available Operations

retweeters

Retrieve retweeters in a single request. Automatically paginates until count is reached or no more results. Minimum 10, maximum 5000 users.

Example Usage

import os
from x_api_scraper import XapiScraper


with XapiScraper(
    bearer_auth=os.getenv("X_API_SCRAPER_BEARER_AUTH", ""),
) as xapi_scraper:

    res = xapi_scraper.tweets.engagement.retweeters(tweet_id="<id>", target_count=100)

    # Handle response
    print(res)

Parameters

Parameter Type Required Description Example
tweet_id str ✔️ The ID of the tweet to get retweeters for.
target_count int ✔️ Number of retweeters to return (minimum 10, maximum 5000). 100
retries Optional[utils.RetryConfig] Configuration to override the default retry behavior of the client.

Response

models.SearchUserResponse

Errors

Error Type Status Code Content Type
errors.HTTPValidationError 422 application/json
errors.XapiScraperDefaultError 4XX, 5XX */*

retweeters_page

Retrieve retweeters using cursor-based pagination. Each page returns up to 20 users. Pass next_cursor from the previous response to continue.

Example Usage

import os
from x_api_scraper import XapiScraper


with XapiScraper(
    bearer_auth=os.getenv("X_API_SCRAPER_BEARER_AUTH", ""),
) as xapi_scraper:

    res = xapi_scraper.tweets.engagement.retweeters_page(tweet_id="<id>", next_cursor="eyJpZCI6IjIwNjAwNTE1Mzg3OTQ0Mzg2NzciLCJmbG9ja0N1cnNvciI6IjQ2MTE2ODYwMTg2Mjg5ODcxNzkiLCJvcmlnaW5hbERpcmVjdGlvbiI6IkRlc2NlbmRpbmcifQ==-999995")

    # Handle response
    print(res)

Parameters

Parameter Type Required Description Example
tweet_id str ✔️ The ID of the tweet to get retweeters for.
next_cursor OptionalNullable[str] Cursor returned by the previous page. Leave empty to fetch the first page. eyJpZCI6IjIwNjAwNTE1Mzg3OTQ0Mzg2NzciLCJmbG9ja0N1cnNvciI6IjQ2MTE2ODYwMTg2Mjg5ODcxNzkiLCJvcmlnaW5hbERpcmVjdGlvbiI6IkRlc2NlbmRpbmcifQ==-999995
retries Optional[utils.RetryConfig] Configuration to override the default retry behavior of the client.

Response

models.GetRetweetersCursorResponse

Errors

Error Type Status Code Content Type
errors.HTTPValidationError 422 application/json
errors.XapiScraperDefaultError 4XX, 5XX */*

quotes

Retrieve quote tweets in a single request. Automatically paginates until count is reached or no more results. Use Latest for chronological order or Top for ranked results. Minimum 10, maximum 5000 tweets.

Example Usage

import os
from x_api_scraper import XapiScraper


with XapiScraper(
    bearer_auth=os.getenv("X_API_SCRAPER_BEARER_AUTH", ""),
) as xapi_scraper:

    res = xapi_scraper.tweets.engagement.quotes(tweet_id="<id>", count=100, sort_by="Top")

    # Handle response
    print(res)

Parameters

Parameter Type Required Description Example
tweet_id str ✔️ The ID of the tweet to get quote tweets for.
count int ✔️ Number of quote tweets to return (minimum 10, maximum 5000). 100
sort_by Optional[models.GetQuotesQuerySortBy] Sort order for quote tweets. Latest for chronological order or Top for ranked results.
retries Optional[utils.RetryConfig] Configuration to override the default retry behavior of the client.

Response

models.GetQuotesResponse

Errors

Error Type Status Code Content Type
errors.HTTPValidationError 422 application/json
errors.XapiScraperDefaultError 4XX, 5XX */*

quotes_page

Retrieve quote tweets using cursor-based pagination. Each page returns up to 20 tweets. Use Latest for chronological order or Top for ranked results. Pass next_cursor from the previous response to continue.

Example Usage

import os
from x_api_scraper import XapiScraper


with XapiScraper(
    bearer_auth=os.getenv("X_API_SCRAPER_BEARER_AUTH", ""),
) as xapi_scraper:

    res = xapi_scraper.tweets.engagement.quotes_page(tweet_id="<id>", sort_by="Top", next_cursor="scroll:thGQYTMwMjU5NDA4ODc4ODc6MjU5NDA4ODc4ODc6")

    # Handle response
    print(res)

Parameters

Parameter Type Required Description Example
tweet_id str ✔️ The ID of the tweet to get quote tweets for.
sort_by Optional[models.GetQuotesCursorQuerySortBy] Sort order for quote tweets. Latest for chronological order or Top for ranked results.
next_cursor OptionalNullable[str] Cursor returned by the previous page. Leave empty to fetch the first page. scroll:thGQYTMwMjU5NDA4ODc4ODc6MjU5NDA4ODc4ODc6
retries Optional[utils.RetryConfig] Configuration to override the default retry behavior of the client.

Response

models.GetQuotesCursorResponse

Errors

Error Type Status Code Content Type
errors.HTTPValidationError 422 application/json
errors.XapiScraperDefaultError 4XX, 5XX */*