Skip to content

Latest commit

 

History

History
179 lines (116 loc) · 12.8 KB

File metadata and controls

179 lines (116 loc) · 12.8 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

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.timelines.tweets_and_replies(screen_name="elonmusk", count=50)

    # Handle response
    print(res)

Parameters

Parameter Type Required Description Example
screen_name str ✔️ The screen name (username) of the Twitter user to get all tweets and replies from. elonmusk
count int ✔️ Maximum number of tweets and replies to return. 50
retries Optional[utils.RetryConfig] Configuration to override the default retry behavior of the client.

Response

models.SearchResponse

Errors

Error Type Status Code Content Type
errors.HTTPValidationError 422 application/json
errors.XapiScraperDefaultError 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

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.timelines.user_page(screen_name="axiaisacat", next_cursor="DAAHCgABHFeD5h9__-cLAAIAAAATMjAzODIzMzA5NTM4ODY4MDU5NAgAAwAAAAIAAA", count=20)

    # Handle response
    print(res)

Parameters

Parameter Type Required Description Example
screen_name str ✔️ Twitter screen name of the target user (with or without @). axiaisacat
next_cursor OptionalNullable[str] Cursor returned by the previous page. Leave empty to fetch the first page. DAAHCgABHFeD5h9__-cLAAIAAAATMjAzODIzMzA5NTM4ODY4MDU5NAgAAwAAAAIAAA
count Optional[int] Maximum number of tweets to return for this page. 20
retries Optional[utils.RetryConfig] Configuration to override the default retry behavior of the client.

Response

models.UserTimelinePageResponse

Errors

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

user

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

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.timelines.user(screen_name="axiaisacat", count=20)

    # Handle response
    print(res)

Parameters

Parameter Type Required Description Example
screen_name str ✔️ Twitter screen name of the target user (with or without @). axiaisacat
count Optional[int] Maximum number of tweets to return across all pages. 20
retries Optional[utils.RetryConfig] Configuration to override the default retry behavior of the client.

Response

models.UserTimelineResponse

Errors

Error Type Status Code Content Type
errors.HTTPValidationError 422 application/json
errors.XapiScraperDefaultError 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

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.timelines.tweets_and_replies_page(screen_name="elonmusk", next_cursor="1234567890")

    # Handle response
    print(res)

Parameters

Parameter Type Required Description Example
screen_name str ✔️ Twitter screen name of the target user (with or without @). elonmusk
next_cursor OptionalNullable[str] Cursor returned by the previous page. Leave empty to fetch the first page. 1234567890
retries Optional[utils.RetryConfig] Configuration to override the default retry behavior of the client.

Response

models.GetAllTweetsRepliesCursorResponse

Errors

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